Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
John-Mark Gurney eef68ad27b add a CLI, for both initiator and respondent... 3 years ago
loramac add pin description, and use the analog pin to provide randomness.. 3 years ago
stm32 add support for saving PRNG state to EEPROM... 3 years ago
strobe add the start of the C version for the uC... 3 years ago
.gitignore add recommended build dir to be ignored.. 3 years ago
LICENSE.txt talk about the special ST license.. 3 years ago
Makefile add a server/gateway between multicast and the lora TX/RX... 3 years ago
NOTES.md add notes about unix dgrams.. 3 years ago
PROTOCOL.md add support for replying last message if it was lost.. 3 years ago
README.md explain a bit why Lorawan wasn't used, and clarify compiler issue.. 3 years ago
board-config.h get tx/rx working between two Node151's.. 3 years ago
board.c missed setting up routing for the analog pin.. 3 years ago
comms.c make sure that comms.c enforces handshake messages.. 3 years ago
comms.h add support for starting a new session... 3 years ago
lora.py add a CLI, for both initiator and respondent... 3 years ago
lora_comms.py support importing this w/o the lib... 3 years ago
loraserv.py add a server/gateway between multicast and the lora TX/RX... 3 years ago
main.c add pin description, and use the analog pin to provide randomness.. 3 years ago
misc.c add copyright statement to various files as needed.. 3 years ago
misc.h get tx/rx working between two Node151's.. 3 years ago
multicast.py break out some util functions, implement multicast adapter for LORANode... 3 years ago
requirements.txt add the required python packages.. 3 years ago
strobe_rng_init.c add support for saving PRNG state to EEPROM... 3 years ago
strobe_rng_init.h add support for saving PRNG state to EEPROM... 3 years ago
sysIrqHandlers.h get tx/rx working between two Node151's.. 3 years ago
util.py forgot to add the copyright for this file.. 3 years ago
util_load.py add a CLI, for both initiator and respondent... 3 years ago

README.md

LoRa Irrigation System

This project is to build an irrigation system from LoRa capable microcontrollers. The Heltec Node151 was chosen due to it’s small size and inexpensive cost.

Design Decisions

While investigating this, the LoraWAN protocol was investigated, but after looking at the code complexity and other operational requirements, if was decided that for this project, it was safer to target a direct Node to Node style communication system. This would allow the implementation to be more simple, and security to be built in (LoRaWAN does have a crypto layer, BUT, trusting/auditing it and any library that implements it would be a larger task than I want to undertake). It could also be used for other projects that need security.

One of the other requirements is that the code be 100% open sourced, not GPL licensed, and no proprietary components. This meant that using IDE’s like ST’s STM32CubeIDE which is only available in binary form was not a choice, as that would preclude building on an operating system other than Windows/MaxOS/Linux.

Building

The build system uses the BSD flavor of make. This is the default make on the BSDs, originally called pmake, but also available as bsdmake for MacOSX, and likely other operating systems as well.

It also depends upon ARM’s GNU Arm Embedded Toolchain, which uses gcc as the compiler. It would be good to get it cross-compile with clang as well, but that requires finding a libc like the nano libc that is provided by the toolchain.

Once ARM’s toolchain is in your path, the following should work:

export MAKEOBJDIR=build
mkdir $MAKEOBJDIR
bsdmake all

And in the directory build, a file lora.irr.elf should be present.

Flashing

Flashing can be done via the open source tool OpenOCD. For this, I use a Digilent HS1 JTAG programmer utilizing the resistor hack to allow an FTDI JTAG programmer to control the bi-directional SWIO pin.

One caveat w/ MacOSX, is that it may be necessary to unload the kext com.apple.driver.AppleUSBFTDI via the command:

sudo kextunload -b com.apple.driver.AppleUSBFTDI

as OpenOCD wants direct access to the FTDI driver.

Once that happens, the device can be programmed using the following command:

sudo openocd -f interface/ftdi/digilent-hs1.cfg -f interface/ftdi/swd-resistor-hack.cfg -f target/stm32l1.cfg -c "init" -c "reset init" -c "program build/lora.irr.elf verify reset exit"

Pins

The pinout guide for the Node151.

The pins PB5-7,9 are used as active low controls for the relays.

The pin PB15 is used as an analog input for an RNG source. This pin should be grounded.