tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
587 stars 182 forks source link

lora/lorawan: better errors and provisioning #507

Closed deadprogram closed 1 year ago

deadprogram commented 1 year ago

This PR extracts all of the errors into a single place, also removing unneeded heap allocations.

The LoRaWAN atcmd examples should now output to the console after AT+JOIN all of the information needed to simply send from that device in the future without joining again, as long as the same keys are used.

ofauchon commented 1 year ago

Ok works on LoraE5...

+ID: AppEui, 0000000000000000
+ID: DevEui, a84041000181b365
+KEY: APPKEY, <hiddensecret>
+JOIN: Starting
+JOIN: no JoinAccept packet received
+ID: AppEui, 0000000000000000
+ID: DevEui, a84041000181b365
+KEY: APPKEY, <hiddensecret>
+JOIN: Starting
+JOIN: Network joined
+JOIN: DevEui, a84041000181b365
+JOIN: AppEui, 0000000000000000
+JOIN: DevAddr, <hiddensecret>
+JOIN: NetID, 000000
+JOIN: NwkSKey, <hiddensecret>
+JOIN: AppSKey, <hiddensecret>
+JOIN: Done

....
Errors handling as well....

+ID: invalid EUI length
+ID: invalid EUI length
+ID: invalid EUI length
+ID: invalid EUI length
+KEY: invalid AppKey length
deadprogram commented 1 year ago

I have made some pretty large refactoring changes, but now I am done.

The interface to the sx126x should be a lot clearer now, and also not having to re-implement any interrupt code should make it a lot easier for users.

@ofauchon please take a look!

ofauchon commented 1 year ago

Two latest commits tested again on LoraE5 dev board. atcmd and basic-demo example still working (join and uplink)

LGTM

deadprogram commented 1 year ago

Merging, and then we can make further changes from there. Thank you very much for all your help with this @ofauchon !!!