LoRaCTP: LoRa Content Transfer Protocol
June 25, 2021 ยท View on GitHub
The code in this repository allows to transfer blocks of bytes ("content") over a LoRa (pure LoRa, no LoRaWAN) channel. The library was tested with content of the size of up to 600kB.
Details of the protocol can be found in this paper:
K. Nakamura, P. Manzoni, M. Zennaro, J. -C. Cano and C. T. Calafate, "[Invited] LoRaCTP: a LoRa based Content Transfer Protocol for sustainable edge computing," 2020 16th International Conference on Mobility, Sensing and Networking (MSN), 2020, pp. 539-545, doi: 10.1109/MSN50589.2020.00090.
Folder loractp
The code in this folder is written in MicroPython and tested on:
- LoPy4 quadruple bearer MicroPython enabled development board.
- Pysense board
Firmware version: Pycom MicroPython 1.20.0.rc13 [v1.9.4-94bb382] on 2019-08-22
Files contained:
-
File
boot.pysimply disables the WiFi to limit interferences. -
File
loractp.pyincludes the class definition. -
File
pingXXX.pyandpong.pyare an example of a request/response interaction. Basically,pingXXX.pysends a message andpong.pywaits for a message and once received it replies it.pingrnd.pysends a random number,pingtext.pysends a text input by user. -
File
plainreceiver.pyshows an example of a basic receiving node.
Experimental: folder lopyserialproxy
The code in this folder offers the same functionalities of loractp.py but to be used by a generic python3 capable device (we tested it with a Raspberry Pi 3 Model B+) using the LoPy4 (connected via USB) only as a LoRa adaptor.
Remember to sudo apt install python3-serial
Code in subfolder lopy4code must be loaded in a LoPy and it starts immediately when the device is powered (ready after a 3 seconds red led blink followed by a green blink).
Code in subfolder p3code is basically the rewriting of the code in the main repository (Folder loractp).
-
subfolder
lspcontains:- file
loractp.pythe generic python3 version - file
seriallopy.pythe code to interface with the LoPy via serial channel.
- file
-
File
ping.pycan be tested with theloractp/pong.pyfile and is an example of a request/response interaction. -
File
rndsender.pyshows the example of a sender randomly sending messages in broadcast.
The ping/pong example.
To execute this example you need to have a LoPy4 (lopyA)

and a Raspberry Pi with a LoPy4 (lopyB) connected via USB

Copy files boot.py, loractp.py, and pong.py in folder loractp in the lopyA, copy all files in lopyserialproxy/lopy4code in the lopyB, and copy all files in lopyserialproxy/p3code in the Raspberry Pi.
Execute pong.py in the lopyA.
The lopyB, if plugged in the Raspberry Pi should be already ready (if you have seen the 3 seconds red led blink followed by a green blink).
Before executing the code in the Raspberry Pi, be sure that the serial port lopyB is connected to is '/dev/ttyACM0'. Otherwise you have to explicitely indicate it in the code when creating the CTPendpoint. Like for example:
ctpc = loractp.CTPendpoint(port='/dev/ttyACM1')
Now run in the Raspberry Pi shell:
$ python3 ping.py
You should now see a message going from the Raspberry Pi to the lopyA (ping)... and the response (pong) coming form the lopyA to the Raspberry Pi.
Caveats
- Code based on
seriallopy.pycan fail to connect to the UART the first time. It is simply a matter of trying twice