@@ -966,11 +966,9 @@ int16_t LoRaWANNode::activateOTAA(LoRaWANJoinEvent_t *joinEvent) {
966966 this ->devNonce += 1 ;
967967 LoRaWANNode::hton<uint16_t >(&this ->bufferNonces [RADIOLIB_LORAWAN_NONCES_DEV_NONCE ], this ->devNonce );
968968
969- // generate the signature of the Nonces buffer, and store it in the last two bytes of the Nonces buffer
970- // also store this signature in the Session buffer to make sure these buffers match
971- uint16_t signature = LoRaWANNode::checkSum16 (this ->bufferNonces , RADIOLIB_LORAWAN_NONCES_BUF_SIZE - 2 );
972- LoRaWANNode::hton<uint16_t >(&this ->bufferNonces [RADIOLIB_LORAWAN_NONCES_SIGNATURE ], signature);
973- LoRaWANNode::hton<uint16_t >(&this ->bufferSession [RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE ], signature);
969+ // update the Nonces buffer and generate its signature - also store it in the Session buffer
970+ (void )this ->getBufferNonces ();
971+ memcpy (&this ->bufferSession [RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE ], &this ->bufferNonces [RADIOLIB_LORAWAN_NONCES_SIGNATURE ], 2 );
974972
975973 // configure Rx1 and Rx2 delay for JoinAccept message - these are re-configured once a valid JoinAccept is received
976974 this ->rxDelays [1 ] = RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_1_MS ;
@@ -988,10 +986,9 @@ int16_t LoRaWANNode::activateOTAA(LoRaWANJoinEvent_t *joinEvent) {
988986 state = this ->processJoinAccept (joinEvent);
989987 RADIOLIB_ASSERT (state);
990988
991- // regenerate the Nonces signature as we received new Nonces in the JoinAccept
992- signature = LoRaWANNode::checkSum16 (this ->bufferNonces , RADIOLIB_LORAWAN_NONCES_BUF_SIZE - 2 );
993- LoRaWANNode::hton<uint16_t >(&this ->bufferNonces [RADIOLIB_LORAWAN_NONCES_SIGNATURE ], signature);
994- LoRaWANNode::hton<uint16_t >(&this ->bufferSession [RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE ], signature);
989+ // regenerate the Nonces buffer as we received a new JoinNonce in the JoinAccept
990+ (void )this ->getBufferNonces ();
991+ memcpy (&this ->bufferSession [RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE ], &this ->bufferNonces [RADIOLIB_LORAWAN_NONCES_SIGNATURE ], 2 );
995992
996993 this ->sessionStatus = RADIOLIB_LORAWAN_SESSION_ACTIVE ;
997994
@@ -1025,11 +1022,10 @@ int16_t LoRaWANNode::activateABP() {
10251022 this ->createSession ();
10261023 }
10271024
1028- // generate the signature of the Nonces buffer, and store it in the last two bytes of the Nonces buffer
1029- // also store this signature in the Session buffer to make sure these buffers match
1030- uint16_t signature = LoRaWANNode::checkSum16 (this ->bufferNonces , RADIOLIB_LORAWAN_NONCES_BUF_SIZE - 2 );
1031- LoRaWANNode::hton<uint16_t >(&this ->bufferNonces [RADIOLIB_LORAWAN_NONCES_SIGNATURE ], signature);
1032- LoRaWANNode::hton<uint16_t >(&this ->bufferSession [RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE ], signature);
1025+ // update the Nonces buffer and generate its signature - also store it in the Session buffer
1026+ (void )this ->getBufferNonces ();
1027+ memcpy (&this ->bufferSession [RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE ], &this ->bufferNonces [RADIOLIB_LORAWAN_NONCES_SIGNATURE ], 2 );
1028+
10331029
10341030 // store DevAddr and all keys
10351031 LoRaWANNode::hton<uint32_t >(&this ->bufferSession [RADIOLIB_LORAWAN_SESSION_DEV_ADDR ], this ->devAddr );
0 commit comments