Skip to content

Commit

Permalink
Add functions to get network session key and app session key after join
Browse files Browse the repository at this point in the history
  • Loading branch information
beegee-tokyo committed Oct 17, 2024
1 parent 5c28c50 commit 943d4ef
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Arduino library for LoRa communication with Semtech SX126x chips. It is based on

# Release Notes

# V2.0.27 Access to NWsKey and AppsKey
- Add functions to get network session key and app session key after join

# V2.0.26 Add missing header file
- Fix compilation error

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----
## Changelog
[Code releases](CHANGELOG.md)
- 2024-10-17 Access to NWsKey and AppsKey
- Add functions to get network session key and app session key after join
- 2024-07-02 Add missing header file
- Fix compilation error
- 2024-06-26
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SX126x-Arduino",
"version": "2.0.26",
"version": "2.0.27",
"keywords": [
"lora",
"Semtech",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SX126x-Arduino
version=2.0.26
version=2.0.27
author=Bernd Giesecke <[email protected]>
maintainer=Bernd Giesecke <[email protected]>
sentence=Arduino library to use Semtech SX126x LoRa chips and modules to communicate
Expand Down
4 changes: 2 additions & 2 deletions src/boards/mcu/rak11300/SimpleTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class SimpleTimer
volatile timer_callback callbacks[MAX_TIMERS];

// delay values
volatile unsigned long delays[MAX_TIMERS];
volatile long delays[MAX_TIMERS];

// number of runs to be executed for each timer
volatile int maxNumRuns[MAX_TIMERS];
Expand All @@ -129,4 +129,4 @@ class SimpleTimer
int numTimers;
};

#endif
#endif
6 changes: 3 additions & 3 deletions src/mac/LoRaMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ static uint8_t *LoRaMacAppKey;
/*!
* AES encryption/decryption cipher network session key
*/
static uint8_t LoRaMacNwkSKey[] =
uint8_t LoRaMacNwkSKey[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

/*!
* AES encryption/decryption cipher application session key
*/
static uint8_t LoRaMacAppSKey[] =
uint8_t LoRaMacAppSKey[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Expand All @@ -111,7 +111,7 @@ static uint32_t LoRaMacNetID;
/*!
* Mote Address
*/
static uint32_t LoRaMacDevAddr;
uint32_t LoRaMacDevAddr;

/*!
* Multicast channels linked list
Expand Down
4 changes: 4 additions & 0 deletions src/mac/LoRaMac.h
Original file line number Diff line number Diff line change
Expand Up @@ -1960,4 +1960,8 @@ LoRaMacStatus_t LoRaMacMcpsRequest(McpsReq_t *mcpsRequest);

void ResetMacCounters(void);

extern uint8_t LoRaMacNwkSKey[];
extern uint8_t LoRaMacAppSKey[];
extern uint32_t LoRaMacDevAddr;

#endif // __LORAMAC_H__
16 changes: 16 additions & 0 deletions src/mac/LoRaMacHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,22 @@ uint32_t lmh_getDevAddr(void)
return LoRaMacGetOTAADevId();
}

void lmh_getNwSkey(uint8_t * key)
{
for (int idx=0; idx<16; idx++)
{
key[idx] = LoRaMacNwkSKey[idx];
}
}

void lmh_getAppSkey(uint8_t *key)
{
for (int idx = 0; idx < 16; idx++)
{
key[idx] = LoRaMacAppSKey[idx];
}
}

/**
* @brief Set the AS923 frequency variant
*
Expand Down
3 changes: 3 additions & 0 deletions src/mac/LoRaMacHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,7 @@ uint8_t lmh_getConfRetries(void);
*/
void lmh_reset_mac(void);

void lmh_getNwSkey(uint8_t *key);
void lmh_getAppSkey(uint8_t *key);

#endif

0 comments on commit 943d4ef

Please sign in to comment.