Closed n2jn closed 7 years ago
@Nicolasdejean Have a look at how reset()
was earlier:
https://github.com/TheThingsNetwork/arduino-device-lib/blob/eb431599d2e980c29264807cd0eca582fcdb991f/src/TheThingsNetwork.cpp#L83
You need to read the result of sys reset
before you do sys get hweui
@johanstokking I tried to fix this by changing reset()
to:
void TheThingsNetwork::reset(bool adr, int sf, int fsb) {
#if !TTN_ADR_SUPPORTED
adr = false;
#endif
modemStream->println(F("sys reset"));
String version = readLine(3000);
if (version == "") {
debugPrintLn(F("Invalid version"));
return;
}
model = version.substring(0, version.indexOf(' '));
debugPrint(F("Version is "));
debugPrint(version);
debugPrint(F(", model is "));
debugPrintLn(model);
String devEui = readValue(F("sys get hweui"));
String str = "";
str.concat(F("mac set deveui "));
str.concat(devEui);
sendCommand(str);
str = "";
str.concat(F("mac set adr "));
if(adr){
str.concat(F("on"));
} else {
str.concat(F("off"));
}
sendCommand(str);
// ..
But now I get an ok
in response to sys get hweui
:
-- STATUS
EUI: 0004A30B001B7AD2
Battery: 3213
AppEUI: 70B3D57EF0000028
DevEUI: 0004A30B001B7AD2
DevAddr: 00000000
Data Rate: 5
RX Delay 1: 1000
RX Delay 2: 2000
-- JOIN
Version is RN2483 1.0.1 Dec 15 2015 09:38:09, model is RN2483
Sending: mac set deveui 0004A30B001B7AD2
Sending: mac set adr off
Sending: mac set pwridx 1
Sending: mac set dr 5
Sending: mac set appeui with 8 bytes
Sending: mac set appkey with 16 bytes
Sending: mac save
Wait for OK time-out expired
Sending: mac set deveui ok
Response is not OK: invalid_param
Any idea?
@FokkeZB the mac save
takes a while, it times out (see message). You should enlarge the time-out. The ok
you get is a late response from mac save
, the result of sys get hweui
follows after.
Best is to debug these things with a serial passthrough.
@johanstokking it works, but I do get a timeout after mac save
still.
@FokkeZB I put a higher wait-time for sendCommand, it works for me, try if it works for you
Yes, that fixes it! @johanstokking good to merge
added provision() #50