manuelbl / ttn-esp32

The Things Network device library for ESP32 (ESP-IDF) and SX127x based devices
MIT License
309 stars 64 forks source link

ttn_hal: LMIC failed and stopped #67

Closed mdede439 closed 1 year ago

mdede439 commented 1 year ago

Hi. I discovered your repository to assist me with getting my LoRa project off the ground, thank you for your work, but I am running into an issue with one of your examples - power_off. I am able to get hello_world and deep_sleep working properly but the power_off example always fails just as it begins to Join. Here is output as the ESP32S3 was reset.

I (0) cpu_start: App cpu up. I (207) cpu_start: Pro cpu start user code I (207) cpu_start: cpu freq: 160000000 Hz I (208) cpu_start: Application information: I (210) cpu_start: Project name: power_off I (216) cpu_start: App version: 1 I (220) cpu_start: Compile time: Jun 7 2023 15:41:14 I (226) cpu_start: ELF file SHA256: a484f80128cd60a1... I (232) cpu_start: ESP-IDF: v5.1-rc1-dirty I (238) cpu_start: Min chip rev: v0.0 I (242) cpu_start: Max chip rev: v0.99 I (247) cpu_start: Chip rev: v0.1 I (252) heap_init: Initializing. RAM available for dynamic allocation: I (259) heap_init: At 3FC96F50 len 000527C0 (329 KiB): DRAM I (265) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM I (272) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM I (278) heap_init: At 600FE010 len 00001FF0 (7 KiB): RTCRAM I (285) spi_flash: detected chip: gd I (289) spi_flash: flash io: dio I (293) sleep: Configure to isolate all GPIO pins in sleep state I (300) sleep: Enable automatic switching of GPIO sleep configuration I (307) app_start: Starting scheduler on CPU0 I (312) app_start: Starting scheduler on CPU1 I (312) main_task: Started on CPU0 I (322) main_task: Calling app_main() I (342) ttn_prov: DevEUI, AppEUI/JoinEUI and AppKey saved in NVS storage I (342) gpio: GPIO[5]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (342) gpio: GPIO[6]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (352) gpio: GPIO[10]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:1 I (362) gpio: GPIO[11]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:1 I (372) ttn_hal: IO initialized I (382) ttn_hal: SPI initialized I (382) ttn_hal: Timer initialized Joining... E (422) ttn_hal: LMIC failed and stopped: ./components/ttn-esp32/src/lmic/lmic_us_like.c:51

I assume that all the examples use the same lmic_us_like.c file when compiling so why would the power_off example fail in this way but not the other two examples??

manuelbl commented 1 year ago

I can reproduce this problem. It is specific to American frequencies (and possibly similar ones). I'll investigate it further.

mdede439 commented 1 year ago

That's great! I have had similar issues like this before with other libraries. Unfortunately most of the LoRa code I want to use is developed in Europe and using frequency bands I can't use.

I appreciate you looking in to this.

Mike

manuelbl commented 1 year ago

A commit to the master branch likely fixes this issue.

I cannot fully test America frequencies. But I think I understood and fixed the bug, and it no longer occurs in my limited tests.

mdede439 commented 1 year ago

Thank you so much! I have verified that the updated library works with the power_off example code. I was even able to power my board via battery and pull the battery and reconnect it and the device was able to send another message without the need for rejoining!! For reference my setup was an Adafruit ESP32S3 with an Adafruit LoRa Feather and I was using ESP-IDF ver 5,02.

Thank you again for the quick work!!

Mike