mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
net/gnrc_lorawan : String keywords for keys
Swapped hex input for keys with string keywords.
This commit is contained in:
parent
8e47621e7c
commit
3ecd304354
@ -25,16 +25,16 @@ USEMODULE += $(DRIVER)
|
||||
# `ifconfig`
|
||||
|
||||
# OTAA compile time configuration keys
|
||||
CFLAGS += -DLORAMAC_APP_KEY_DEFAULT=\{0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\}
|
||||
CFLAGS += -DLORAMAC_APP_EUI_DEFAULT=\{0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\}
|
||||
CFLAGS += -DLORAMAC_DEV_EUI_DEFAULT=\{0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\}
|
||||
CFLAGS += -DLORAMAC_APP_KEY_DEFAULT=\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"
|
||||
CFLAGS += -DLORAMAC_APP_EUI_DEFAULT=\"BBBBBBBBBBBBBBBB\"
|
||||
CFLAGS += -DLORAMAC_DEV_EUI_DEFAULT=\"CCCCCCCCCCCCCCCC\"
|
||||
|
||||
# Uncomment and replace with proper keys for joining with ABP
|
||||
# For TTN, It's necessary to set the RX2 DR to 3
|
||||
# NOTE: This values will be overriten in case of OTAA.
|
||||
#CFLAGS += -DLORAMAC_DEV_ADDR_DEFAULT=\{0x00\,0x00\,0x00\,0x00\}
|
||||
#CFLAGS += -DLORAMAC_NWK_SKEY_DEFAULT=\{0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\}
|
||||
#CFLAGS += -DLORAMAC_APP_SKEY_DEFAULT=\{0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\,0x00\}
|
||||
#CFLAGS += -DLORAMAC_DEV_ADDR_DEFAULT=\"00000000\"
|
||||
#CFLAGS += -DLORAMAC_NWK_SKEY_DEFAULT=\"00000000000000000000000000000000\"
|
||||
#CFLAGS += -DLORAMAC_APP_SKEY_DEFAULT=\"00000000000000000000000000000000\"
|
||||
#CFLAGS += -DLORAMAC_DEFAULT_RX2_DR=LORAMAC_DR_3
|
||||
|
||||
# Comment/uncomment as necessary
|
||||
|
@ -63,12 +63,12 @@ select join mode and type `ifconfig <if_pid> up`.
|
||||
E.g in the application Makefile:
|
||||
|
||||
```
|
||||
CFLAGS += -DLORAMAC_DEV_EUI_DEFAULT=\{0xAA\,0xAA\,0xAA\,0xAA\,0xAA\,0xAA\,0xAA\,0xAA\}
|
||||
CFLAGS += -DLORAMAC_APP_EUI_DEFAULT=\{0xBB\,0xBB\,0xBB\,0xBB\,0xBB\,0xBB\,0xBB\,0xBB\}
|
||||
CFLAGS += -DLORAMAC_APP_KEY_DEFAULT=\{0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\,0xCC\}
|
||||
CFLAGS += -DLORAMAC_APP_SKEY_DEFAULT=\{0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\,0xDD\}
|
||||
CFLAGS += -DLORAMAC_NWK_SKEY_DEFAULT=\{0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\,0xEE\}
|
||||
CFLAGS += -DLORAMAC_DEV_ADDR_DEFAULT=\{0xFF\,0xFF\,0xFF\,0xFF\}
|
||||
CFLAGS += -DLORAMAC_DEV_EUI_DEFAULT=\"AAAAAAAAAAAAAAAA\"
|
||||
CFLAGS += -DLORAMAC_APP_EUI_DEFAULT=\"BBBBBBBBBBBBBBBB\"
|
||||
CFLAGS += -DLORAMAC_APP_KEY_DEFAULT=\"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\"
|
||||
CFLAGS += -DLORAMAC_APP_SKEY_DEFAULT=\"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\"
|
||||
CFLAGS += -DLORAMAC_NWK_SKEY_DEFAULT=\"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\"
|
||||
CFLAGS += -DLORAMAC_DEV_ADDR_DEFAULT=\"FFFFFFFF\"
|
||||
```
|
||||
|
||||
## Send data
|
||||
|
@ -42,8 +42,7 @@ extern "C" {
|
||||
* 8 bytes key, required for join procedure
|
||||
*/
|
||||
#ifndef LORAMAC_DEV_EUI_DEFAULT
|
||||
#define LORAMAC_DEV_EUI_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00 }
|
||||
#define LORAMAC_DEV_EUI_DEFAULT "0000000000000000"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -52,8 +51,7 @@ extern "C" {
|
||||
* 8 bytes key, required for join procedure
|
||||
*/
|
||||
#ifndef LORAMAC_APP_EUI_DEFAULT
|
||||
#define LORAMAC_APP_EUI_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00 }
|
||||
#define LORAMAC_APP_EUI_DEFAULT "0000000000000000"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -62,10 +60,7 @@ extern "C" {
|
||||
* 16 bytes key, required for join procedure
|
||||
*/
|
||||
#ifndef LORAMAC_APP_KEY_DEFAULT
|
||||
#define LORAMAC_APP_KEY_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00 }
|
||||
#define LORAMAC_APP_KEY_DEFAULT "00000000000000000000000000000000"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -74,10 +69,7 @@ extern "C" {
|
||||
* 16 bytes key, only required for ABP join procedure type
|
||||
*/
|
||||
#ifndef LORAMAC_APP_SKEY_DEFAULT
|
||||
#define LORAMAC_APP_SKEY_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00 }
|
||||
#define LORAMAC_APP_SKEY_DEFAULT "00000000000000000000000000000000"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -86,17 +78,14 @@ extern "C" {
|
||||
* 16 bytes key, only required for ABP join procedure type.
|
||||
*/
|
||||
#ifndef LORAMAC_NWK_SKEY_DEFAULT
|
||||
#define LORAMAC_NWK_SKEY_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00 }
|
||||
#define LORAMAC_NWK_SKEY_DEFAULT "00000000000000000000000000000000"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default device address
|
||||
*/
|
||||
#ifndef LORAMAC_DEV_ADDR_DEFAULT
|
||||
#define LORAMAC_DEV_ADDR_DEFAULT { 0x00, 0x00, 0x00, 0x00 }
|
||||
#define LORAMAC_DEV_ADDR_DEFAULT "00000000"
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include "fmt.h"
|
||||
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
@ -28,12 +29,12 @@
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
static uint8_t _nwkskey[LORAMAC_NWKSKEY_LEN] = LORAMAC_NWK_SKEY_DEFAULT;
|
||||
static uint8_t _appskey[LORAMAC_APPSKEY_LEN] = LORAMAC_APP_SKEY_DEFAULT;
|
||||
static uint8_t _appkey[LORAMAC_APPKEY_LEN] = LORAMAC_APP_KEY_DEFAULT;
|
||||
static uint8_t _deveui[LORAMAC_DEVEUI_LEN] = LORAMAC_DEV_EUI_DEFAULT;
|
||||
static uint8_t _appeui[LORAMAC_APPEUI_LEN] = LORAMAC_APP_EUI_DEFAULT;
|
||||
static uint8_t _devaddr[LORAMAC_DEVADDR_LEN] = LORAMAC_DEV_ADDR_DEFAULT;
|
||||
static uint8_t _nwkskey[LORAMAC_NWKSKEY_LEN];
|
||||
static uint8_t _appskey[LORAMAC_APPSKEY_LEN];
|
||||
static uint8_t _appkey[LORAMAC_APPKEY_LEN];
|
||||
static uint8_t _deveui[LORAMAC_DEVEUI_LEN];
|
||||
static uint8_t _appeui[LORAMAC_APPEUI_LEN];
|
||||
static uint8_t _devaddr[LORAMAC_DEVADDR_LEN];
|
||||
|
||||
static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt);
|
||||
static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif);
|
||||
@ -206,6 +207,14 @@ static void _init(gnrc_netif_t *netif)
|
||||
netif->dev->event_callback = _driver_cb;
|
||||
_reset(netif);
|
||||
|
||||
/* Convert default keys, address and EUIs to hex */
|
||||
fmt_hex_bytes(_nwkskey, LORAMAC_NWK_SKEY_DEFAULT);
|
||||
fmt_hex_bytes(_appskey, LORAMAC_APP_SKEY_DEFAULT);
|
||||
fmt_hex_bytes(_appkey, LORAMAC_APP_KEY_DEFAULT);
|
||||
fmt_hex_bytes(_deveui, LORAMAC_DEV_EUI_DEFAULT);
|
||||
fmt_hex_bytes(_appeui, LORAMAC_APP_EUI_DEFAULT);
|
||||
fmt_hex_bytes(_devaddr, LORAMAC_DEV_ADDR_DEFAULT);
|
||||
|
||||
/* Initialize default keys, address and EUIs */
|
||||
memcpy(netif->lorawan.nwkskey, _nwkskey, sizeof(_nwkskey));
|
||||
memcpy(netif->lorawan.appskey, _appskey, sizeof(_appskey));
|
||||
|
Loading…
Reference in New Issue
Block a user