TheThingsNetwork / arduino-device-lib

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

called reset() in personalize() #42

Closed n2jn closed 8 years ago

n2jn commented 8 years ago

Added a bool in parameter: true does a reset, false doesn't.#6

FokkeZB commented 8 years ago

@johanstokking can't we just call reset() unless personalize() was called with no arguments? Or am I not understanding the reason for reset()?

johanstokking commented 8 years ago

Yep. I think if you want to personalize with custom keys, that it's good to reset first. Otherwise, when you want to personalize with whatever is in the RN module, you don't reset first.

n2jn commented 8 years ago

Should I put reset() in the private section, now that we only use it in personalize() and join() ?#39

johanstokking commented 8 years ago

@Nicolasdejean no it's OK like this

Code is approved

@FokkeZB can you test?

FokkeZB commented 8 years ago

I've successfully tested with this in setup()

  ttn.init(loraSerial, debugSerial);

  debugPrintLn("Personalize with keys");
  ttn.personalize(devAddr, nwkSKey, appSKey);

  debugPrintLn("Send 0x11");
  byte payload[] = { 0x11 };
  ttn.sendBytes(payload, sizeof(payload));

  debugPrintLn("Personalize without keys");
  ttn.personalize();

  debugPrintLn("Send 0x22");
  byte payload2[] = { 0x22 };
  ttn.sendBytes(payload2, sizeof(payload2));

Both messages came through fine.