BNNorman / dragino-1

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

Issue with Missing Method in Dragino Library #4

Closed Alixpat closed 2 months ago

Alixpat commented 2 months ago

Dear @BNNorman,

I hope this message finds you well. I am currently working with the Dragino library on a Raspberry Pi project, and I have encountered this error that seems to stem from a missing method within the library.

Here is the error message:

Traceback (most recent call last):
  File "/home/pi/dragino-1/./test.py", line 27, in <module>
    D.join()
  File "/home/pi/dragino-1/dragino/dragino.py", line 493, in join
    self.configureRadio(radioSettings.JOIN)
  File "/home/pi/dragino-1/dragino/dragino.py", line 185, in configureRadio
    self.set_spreading_factor(sf)
  File "/home/pi/dragino-1/dragino/SX127x/LoRa.py", line 663, in set_spreading_factor
    self.set_low_data_rate()
AttributeError: 'Dragino' object has no attribute 'set_low_data_rate'

The issue arises when trying to configure the radio settings using the set_spreading_factor method, which in turn attempts to call set_low_data_rate. However, it appears that the set_low_data_rate method does not exist in the Dragino class.

Could you please provide guidance on whether there is a fix or a workaround for this issue? Alternatively, if there is an updated version of the library that addresses this, could you point me in the right direction?

Thank you for your assistance.

Best regards,

BNNorman commented 2 months ago

Yes it's a bug. I extended the set_low_data_rate here but forgot to put an underscore in the calls. image I probably didn't see the bug because my GW is only 20 feet away so I never needed that flag.

I have fixed the typo and pushed a new LoRa.py to the repo.

Alixpat commented 2 months ago

Firstly, I want to thank you for your swift response and solution to the previous issue with the set_low_data_rate method. It has helped progress my project considerably.

However, I have encountered a new issue following the recent fix. Here is the error output when I attempt to run the test.py script:

Configuring GPIOs
BOARD SpiDev created
SX127x chip version is 0x12
initial mode is HF_LORA_SLEEP
set_mode : HF_FSK_STDBY
initial mode changed to HF_FSK_STDBY
set_mode : HF_LORA_SLEEP
Traceback (most recent call last):
  File "/home/pi/dragino-1/./test.py", line 27, in <module>
    D.join()
  File "/home/pi/dragino-1/dragino/dragino.py", line 493, in join
    self.configureRadio(radioSettings.JOIN)
  File "/home/pi/dragino-1/dragino/dragino.py", line 185, in configureRadio
    self.set_spreading_factor(sf)
  File "/home/pi/dragino-1/dragino/SX127x/LoRa.py", line 663, in set_spreading_factor
    self._set_low_data_rate()
  File "/home/pi/dragino-1/dragino/SX127x/LoRa.py", line 1068, in _set_low_data_rate
    sf=cfg2["sf"]
KeyError: 'sf'

The script fails with a KeyError while trying to access the sf key in a configuration dictionary. It appears that the sf key may not be set in cfg2 before it's accessed. Could you please assist in resolving this new error?

Looking forward to your guidance.

BNNorman commented 2 months ago

It should be "spreading_factor" not "sf" - another bug. "bw" is correct. Many thanks. I have updated LoRa.py again

Alixpat commented 2 months ago

The bug is now fixed. I am planning to reinstall a gateway to fully test the entire library under more varied conditions. Thank you once again for your dedicated support and swift responses. I look forward to continuing to work with your software and possibly reaching out in the future should any more questions or issues arise.

Best regards,

BNNorman commented 2 months ago

Good to hear - have fun. As you can see it's been a few years since I developed that. The original creator stopped developing before TTN went to V3, I just added MAC handling, and a few other things (including broken code LOL).