Initalize the OSCOAP context just before sending the Join Request.
@@ -74,7 +74,6 @@ void cjoin_init() {
cjoin_vars.timerId = opentimers_create();
idmanager_setJoinKey((uint8_t *) masterSecret);
- cjoin_init_security_context();
cjoin_schedule();
}
@@ -192,6 +191,10 @@ void cjoin_task_cb() {
// cancel the startup timer but do not destroy it as we reuse it for retransmissions
opentimers_cancel(cjoin_vars.timerId);
+ // init the security context only here in order to use the latest joinKey
+ // that may be set over the serial
+ cjoin_init_security_context();
+
cjoin_sendJoinRequest(joinProxy);
return;
