computenodes / dragino

LoRaWAN implementation in python
GNU Affero General Public License v3.0
27 stars 10 forks source link

Added support for downlink messages #11

Closed BNNorman closed 3 years ago

BNNorman commented 3 years ago

Please take a look at my changes. I have added a new test: test_downlink.py I have added logfile names to test.py and test_downlink.py. I have updated README.md, a bit. I have modified dragino.py to enable the capture of data down messages.

regards Brian Norman

pjb304 commented 3 years ago

Thanks for working on this. I'll have a look later in the week when I get some time.

BNNorman commented 3 years ago

I'm happy with those changes.

Glad to help. On 21/05/2021 15:01:58, Philip Basford @.***> wrote: @pjb304 requested changes on this pull request. Hi Brian, Many thanks for submitting this pull request. It looks good and behaves on my device. I've made a couple of suggestions for changes to be made. If you're happy with them I'll do the merge. Phil In README.md [https://github.com/computenodes/dragino/pull/11#discussion_r636927781]:

  1. Install the required packages sudo apt install device-tree-compiler git python3-crypto python3-nmea2 python3-rpi.gpio python3-serial python3-spidev python3-configobj 5. Download the git repo git clone https://github.com/computenodes/LoRaWAN.git + 1. make a copy of dragingo.ini.default 'cp dragino.ini.default dragino.ini' ⬇️ Suggested change
  2. Enable additional CS lines (See section below for explanation) 1. Change into the overlay directory cd dragino/overlay 2. Compile the overlay dtc -@ -I dts -O dtb -o spi-gpio-cs.dtbo spi-gpio-cs-overlay.dts. This might generate a couple of warnings, but seems to work ok 3. Copy the output file to the required folder sudo cp spi-gpio-cs.dtbo /boot/overlays/ 4. Enable the overlay at next reboot echo "dtoverlay=spi-gpio-cs" | sudo tee -a /boot/config.txt 5. Reboot the Pi sudo reboot 6. Check that the new cs lines are enabled ls /dev/spidev0.* should output /dev/spidev0.0 /dev/spidev0.1 /dev/spidev0.2. In which case the required SPI CS line now exists -7. Create a new device in The Things Network console and copy the details into the config file +7. Create a new device in The Things Network console and copy the details into the config file dragino.ini ⬇️ Suggested change -7. Create a new device in The Things Network console and copy the details into the config file dragino.ini +7. Create a new device in The Things Network console and copy the details into the config file dragino.ini In test_downlink.py [https://github.com/computenodes/dragino/pull/11#discussion_r636942713]: +logging.basicConfig(filename="test_downlink.log", format='%(asctime)s - %(funcName)s - %(lineno)d - %(levelname)s - %(message)s', level=logLevel) + +logging.info("Starting session") + +callbackReceived=False + +def downlinkCallback(payload,mtype): + ''' + Called by dragino.on_rx_done() when an UNCONF_DATA_DOWN or CONF_DATA_DOWN downlink message arrives. + Scheduling a CONF_DATA_DOW message requires an uplink response which + impacts on the fair use policy. Not recommended! + + payload: bytearray + mtype: one of UNCONF_DATA_DOWN or CONF_DATA_DOWN + ''' + print("downlink message received") ⬇️ Suggested change