Best way to establish a socket connection with MKR GSM 1400


My goal is to establish a TCP socket connection with an MKR GSM 1400 board to that I can send an updated firmware image and perform OTA updates.

I’m running a rudimentary server on the MKR board and can send data to the board via an inbound webhook and curl. This seems to work well. However, to implement a state machine I’ll need to know if my previous task was successfully completed so I need to receive data from the MKR board, not just send data to it. Seems like I could create a webhook and implement an http server to catch data sent from the MKR board but this solution seems kludgy.

A simpler solution would be to create a direct TCP socket connection between my localhost and the MKR board. However, I don’t necessarily know the IP address of the MKR board, so I’m wondering if spacebridge will help me here? Can I use spacebridge to create a tunnel to the MKR board so that I can open a TCP socket connection between my localhost and the MKR board or does spacebridge require an SSH server running on the MKR board - an unrealistic expectation?

If spacebridge isn’t the answer, how would you suggest I configure a system to send data via TCP sockets to an MKR board and receive acknowledgments in a relatively straightforward manner?

Thanks in advance.


After struggling with trying to push OTA updates to the MKR GSM 1400 board I found the simpler solution for the MKR board is to pull files from a webserver. This has several advantages: 1) only users that want updates can get them, 2) there’s no need to struggle with trying to communicate with each board via Hologram, and 3) the webserver can easily handle multiple simultaneous requests in the event multiple MKR boards request updates at the same time. I was able to complete the entire OTA process with the following approach:

  1. Add a MicroSD connector tied into the SPI bus of the MKR board. Provided that the previously loaded program was complied with SDU.h, the presence of UPDATE.bin in the root of the SD card will be automatically loaded on boot.
  2. Prepare a webserver with the following files, bin, version, and hash. bin is the binary compiled image, version contains the firmware version number and hash currently contains the CRC32 checksum.
  3. When an OTA update is required, the MKR board creates a GSMClient connection to my webserver (currently just an old raspberry pi) and first downloads version to see whether or not the firmware needs updating. If so, the program continues to download the remaining files onto the SD card using the SdFat library.
  4. Once all the files are received, calculate the bin file’s CRC32 and if it matches the contents of the hash file, rename bin to UPDATE.bin and then reboot the MKR board.

I would have liked to calculate a hash like MD5 but couldn’t figure out how to calculate tzikis’ MD5 library on a stream.

Otherwise the process works fine. Hopefully others might find this useful.

closed #3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.