4 Programming via STM-Nucleo/Discovery Board (J-Tag):

Here we are using an STM32 Nucleo board to programme the device.


3.1 DevEUI and device keys
DevEUI blocks will be provided to you for the number of devices you need. Just contact info@pervasivenation.ie.

The file for providing keys and devEUI for the devices is located:
main.c -> Commissioning.h


Enter your DevEUI, AppEUI and AppKey* in {0x00, ..., ...} format as seen below.


*Generate AppEUI & AppKey:
Follow the link below and choose 8 (AppEUI) or 16 (AppKey) bytes and generate random bytes for keys.
https://www.random.org/bytes/


3.2 Main.c

A brief look at the main.c file, we can identify 3 areas of interest.


1. The APP_TX_DUTYCYCLE determines at what interval the device will send messages.


2. The HALL sensor will wait until a magnet is passed over the board (where the LEDS are) to start the programme. If you do not want this behavior, simply comment out these lines.


3. The LoraTxData function is the data sent on every transmission. This is used to construct your payload message dependent on your needs.



Default payload is:


These refer to the various parts on the PN Board as seen below.


On start up, the device will run through the following sequence in the firmware.


3.3 Build Target and Load
Connect the programmer(STM32 Nucleo) to the PN Board as seen in section 3. Then connect your programmer via USB to the computer.

On the build toolbar, click on Options for Target button as seen below.


In the dialog box, navigate to Debug and Settings.


If your board is connected properly, you should see it listed in the SW Device window below. You can exit out of the dialog.


Click on Build button to build the target files as seen below


Once the files build without any errors or warnings, then click on the Load button to upload your firmware to the PN board.