Hi,
I am trying a network joiner session from the API. First I do a factory reset to clear any previous network data in memory. However when I run the following code, it seems like the program reset
as well, which prevents the rest of my code from being executed.
// this is a custom cli command
otError cli_prov_joiner (void *aContext, uint8_t aArgsLength, char *aArgs[]) {
otError error;
otJoinerDiscerner discerner;
#define pskd "J01NME"
memset(&discerner, 0, sizeof(discerner));
discerner.mValue = 0x1234; // this will be replaced by aArgs[1]
discerner.mLength = 16;
otInstance *instance = openthread_get_default_instance();
if (instance == NULL) {
otCliOutputFormat ("get instantace error");
return OT_ERROR_FAILED;
}
otCliOutputFormat ("\n\r factory reset ");
otInstanceFactoryReset(instance);
// following doesnt get a chance to execute
otCliOutputFormat ("done factory reset");
error = otJoinerSetDiscerner (instance, &discerner);
if (error != OT_ERROR_NONE) {
otCliOutputFormat ("joiner descerner set error");
return (error);
}
otCliOutputFormat ("\n\r ifconfig up ");
error = otIp6SetEnabled(instance, true); // ifconfig up
if (error != OT_ERROR_NONE) {
otCliOutputFormat ("ifconfig up error");
return (error);
}
error = otJoinerStart(instance,
pskd,
NULL,
NULL,
NULL,
NULL,
NULL,
joiner_callback,
NULL);
if (error != OT_ERROR_NONE) {
otCliOutputFormat ("joiner start error");
return (error);
}
return (OT_ERROR_NONE);
}
I have tried following instead of factory reset, but the joining fails.
1. ifconfig down
2. thread stop
3. panid set to 0xffff
4. set joiner discerner to 1234/16
4. ifconfig up
5. joiner start "J01NME"
What can I do?
Cheers,
Kaushalya