Seeed-Studio / Seeed_Platform

27 stars 24 forks source link

sketch get stuck with LoRaWAN #9

Closed nichis closed 3 years ago

nichis commented 6 years ago

Please check the library LoRaWAN.cpp, there is a problem with the debug print since the sketch get stuck if I close the serial monitor. If I disable the debug print (_DEBUGSERIAL = 0) everything works fine

lanselambor commented 6 years ago

@nichis which sketch did you run? ABP, TOAA, p2prx, ptp_tx? I've tried these sketch but didn't go to that situation. Or can you explain the reason?

nichis commented 6 years ago

I'm using a custom sketch.. However also trying with the OTAA, when I close the Serial Monitor no more data are received from my LoraWAN gateway. If I set #define _DEBUG_SERIAL_ 0 into LoRaWan.h everything works..

Of course have to be removed also the line while(!SerialUSB); into the default sketch

WayenWeng commented 6 years ago

@nichis Hi, could you share some logs when run the sketch with debugs on?

nichis commented 6 years ago

@WayenWeng here is the output of my OTAA sketch:

+VER: 2.0.10 +ID: DevAddr, 06:00:00:07 +ID: DevEui, 47:86:C5:8B:00:53:00:2F +ID: AppEui, 01:02:03:04:05:06:07:08 +KEY: NWKSKEY 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 +KEY: APPSKEY 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 +KEY: APPKEY 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 +MODE: LWOTAA +DR: EU868 +DR: DR0 +DR: EU868 DR0 SF12 BW125K +CH: 0,868100000,DR0:DR5 +CH: 1,868300000,DR0:DR5 +CH: 2,868500000,DR0:DR5 +RXWIN1: 0,868100000 +RXWIN2: 869500000,DR3 +LW: DC, OFF, 0 +LW: ERROR(-2) +POWER: 14 +JOIN: Start +JOIN: NORMAL +JOIN: Network joined +JOIN: NetID 010203 DevAddr 06:00:00:07 +JOIN: Done +MSG: Start +MSG: TX "Hello World!" +MSG: Done +MSG: Start +MSG: TX "Hello World!" +MSG: Done +MSG: Start +MSG: TX "Hello World!" +MSG: Done +MSG: Start +MSG: TX "Hello World!" +MSG: Done +MSG: Start +MSG: TX "Hello World!" +MSG: Done

WayenWeng commented 6 years ago

@nichis, please use the api "transferPacketWithConfirmed()" test again and share the log.

nichis commented 6 years ago

@WayenWeng here the output of OTAA sketch with transferPacketWithConfirmed() +VER: 2.0.10 +ID: DevAddr, 01:D5:A5:F6 +ID: DevEui, 47:86:C5:8B:00:53:00:2F +ID: AppEui, 01:02:03:04:05:06:07:08 +KEY: NWKSKEY 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 +KEY: APPSKEY 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 +KEY: APPKEY 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 +MODE: LWOTAA +DR: EU868 +DR: DR0 +DR: EU868 DR0 SF12 BW125K +CH: 0,868100000,DR0:DR5 +CH: 1,868300000,DR0:DR5 +CH: 2,868500000,DR0:DR5 +RXWIN1: 0,868100000 +RXWIN2: 869500000,DR3 +LW: DC, OFF, 0 +LW: ERROR(-2) +POWER: 14 +JOIN: Start +JOIN: NORMAL +JOIN: Network joined +JOIN: NetID 010203 DevAddr 06:00:00:07 +JOIN: Done +CMSG: Start +CMSG: TX "Hello World!" +CMSG: Wait ACK +CMSG: ACK Received +CMSG: RXWIN2, RSSI -95, SNR 4.8 +CMSG: Done +CMSG: Start +CMSG: TX "Hello World!" +CMSG: Wait ACK +CMSG: ACK Received +CMSG: RXWIN2, RSSI -94, SNR 6.0 +CMSG: Done +CMSG: Start +CMSG: TX "Hello World!" +CMSG: Wait ACK +CMSG: ACK Received +CMSG: RXWIN1, RSSI -92, SNR 6.8 +CMSG: Done

WayenWeng commented 6 years ago

@nichis It seems works fine with gateway. It can joined the network and get a network id. It can receive a confirmed message from RXWIN2 after transfer a packet. Is it possible some problems on gateway get raw data? And is it possible to show the original data on gateway? The only issue "+LW: ERROR(-2)" is case the firmware version is not the latest(2.1.16). You can update the firmware and solve it. Wiki link http://wiki.seeedstudio.com/Seeeduino_LoRAWAN/ Firmware link https://raw.githubusercontent.com/SeeedDocument/Seeeduino_LoRa/master/res/rhf76-052am-v2.1.16-20171203.ebin.bin

nichis commented 6 years ago

@WayenWeng thank you but the problem is not about receiving the data on the gateway. The problem is with the debug print since the sketch get stuck if I close the serial monitor of the Arduino IDE, and so if I try to execute the sketch without opening the serial monitor.

Bjoerns-TB commented 5 years ago

I had a similar problem and narrowed it down to the for loop in the transferPacket function. i was going from 0 to 254 in a loop without stopping. I fixed it by declaring it as int. From for(unsigned char i = 0; i < length; i++) to for(int i = 0; i < length; i++)