TheThingsNetwork / arduino-device-lib

Arduino Library for TTN Devices
MIT License
207 stars 96 forks source link

Node: LoRa module unreachable after upload #114

Closed FokkeZB closed 7 years ago

FokkeZB commented 7 years ago

When I upload the following:

#include <TheThingsNetwork.h>

const byte appEui[8] = { 0x70, 0xB3, 0xD5, 0x7E, 0xF0, 0x00, 0x00, 0xF0 };
const byte appKey[16] =  { 0x42, 0x95, 0x3C, 0x34, 0xB2, 0xAB, 0x0E, 0x03, 0x1B, 0x09, 0xDB, 0x09, 0x6C, 0x08, 0x63, 0x41 };

#define lora Serial1
#define debug Serial

TheThingsNetwork ttn(lora, debug, TTN_FP_EU868);

void setup() {  
  lora.begin(57600);
  debug.begin(9600);

  while (!debug);
  ttn.showStatus();
}

void loop()
{
  ttn.showStatus();

  delay(10000);
}

The Serial Monitor shows that the LoRa module is unreachable here:

EUI: 

When I power off/on it works fine.

This does not seem to happen with the Tweetonig_RN2483 library. But once the LoRa module is unreachable and I upload a sketch with the Tweetonig_RN2483 library it also hangs. So it seems our library can get the LoRa module in a bad state.

FokkeZB commented 7 years ago

As suggested by @svenhaitjema, calling this before anything else, seems to fixes it..

lora.write(0x55);

... meaning I get something, be it:

Joining...
EUI: invalid_par
Battery: lid_paam
_invalidpararnivalid_paam
a
AppEUI: invalid_param
DevEUI: lid_paam
_invali_para
Data Rate: id_paam