The device now contains a Device EUI which can be read out with the new API call LoRaWAN_GetInfo
It can be used in the key structure as follows:
LoRaWAN_keys_t someKeys = {
.KeyType = OTAA_10x_key,
.PublicNetwork = true,
.OTAA_10x.DevEui = thisDevEUI,
.OTAA_10x.AppEui = { 0xC0, 0x01, 0xCA, 0xFE, 0xBA, 0xBE, 0xC0, 0xDE },
.OTAA_10x.AppKey = { 0xBA, 0xDD, 0xBE, 0xEF, 0xC0, 0x01, 0xBA, 0xBE, 0xC0, 0x01, 0xFE, 0xED, 0xF0, 0x0D, 0xC0, 0xDE }
};
The following API functionality has changed since version 0x000000B0:
The addition of the configuration of two sub-bands ( .Join.SubBand_1st and .Join.SubBand_2nd ).
This configuration is to accommodate the LoRaWAN US specifications and reduce joining time, and NEEDS to be configured for all versions since 0x000000B0.
For LoRaWAN EU region, a total of 16 channels are possible where the sub-band 1 represents channels 0-7 and sub-band 2 represents channels 8-15.
The default configuration is:
- sub-band 1 enabled
- sub-band 2 disabled
EU configuration example:
coreConfiguration_t coreConfig = {
.Join.KeysPtr = &TTN_OTAAkeys,
.Join.DataRate = DR_AUTO,
.Join.Power = PWR_MAX,
.Join.MAXTries = 100,
.Join.SubBand_1st = EU_SUB_BANDS_DEFAULT,
.Join.SubBand_2nd = EU_SUB_BANDS_DEFAULT,
.TX.Confirmed = false,
.TX.DataRate = DR_0,
.TX.Power = PWR_MAX,
.TX.FPort = 1,
};
For LoRaWAN US region, a total of 64 uplink channels plus 8 downlink channels are possible where: Sub-band 1 represents uplink channels 0-7 + downlink channel 0 Sub-band 2 represents uplink channels 8-15 + downlink channel 1 and so on...
US configuration example:
coreConfiguration_t coreConfig = {
.Join.KeysPtr = &TTN_OTAAkeys,
.Join.DataRate = DR_AUTO,
.Join.Power = PWR_MAX,
.Join.MAXTries = 100,
.Join.SubBand_1st = US_SUB_BAND_2,
.Join.SubBand_2nd = US_SUB_BAND_NONE,
.TX.Confirmed = false,
.TX.DataRate = DR_0,
.TX.Power = PWR_MAX,
.TX.FPort = 1,
};
coreStatus_t LoRaWAN_GetInfo(coreInfo_t * coreInfo);
coreStatus_t LoRaWAN_GetInfo(coreInfo_t * coreInfo);
Returns the device info:
buildYear Core firmware Year of build
buildMonth Core firmware Month of build
buildDayOfMonth Core firmware Day of build
buildHour Core firmware Hour of build (24h mode)
buildMinute Core firmware Minute of build
buildSecond Core firmware Second of build
buildNumber Core firmware incremental build number
devEUI[8] Core devEUI
buildType Core firmware build type
stackRegion Core firmware stack region
stackOption Core firmware stack option: 'S'ecure, 'P'SA, 'C'onfigurable
stackStage Core firmware lifecycle stage: 'a' pre-alpha, 'A' Alpha, 'b' perputual beta, 'B' Beta, 'r' release candidate, 'R' Release
codeName[16] Core firmware code name
In order to make debugging on the CM4 core more convinient in sleep mode the following optinons are added to the SleepConfog.sleepMode member:
.sleepmode:
modeSleep
modeDeepSleep
modeHibernate
modeSleepDebugOn /**< Keeping debug active consumes extra power, use only for debugging purposes */
modeDeepSleepDebugOn /**< Keeping debug active consumes extra power, use only for debugging purposes */
modeHibernateDebugOn /**< Keeping debug active consumes extra power, use only for debugging purposes */
coreStatus_t LoRaWAN_Reset();
coreStatus_t LoRaWAN_MacSave();
coreStatus_t LoRaWAN_FlashRead(uint8_t* buffer, uint8_t block, uint8_t length);
coreStatus_t LoRaWAN_FlashWrite(uint8_t* buffer, uint8_t block, uint8_t length);
coreStatus_t LoRaWAN_Sleep(sleepConfig_t * sleepConfig);
coreStatus_t LoRaWAN_Reset();
Resets the MAC configuration (rejoin needed).
coreStatus_t LoRaWAN_MacSave();
Saves the MAC configuration.
coreStatus_t LoRaWAN_FlashRead(uint8_t* buffer, uint8_t block, uint8_t length);
Reads data of a maximum of 256 bytes per block from EEPROM memory. A total of 8 blocks are available.
coreStatus_t LoRaWAN_FlashWrite(uint8_t* buffer, uint8_t block, uint8_t length);
Writes data of a maximum of 256 bytes per block in EEPROM memory. A total of 8 blocks are available.
coreStatus_t LoRaWAN_Sleep();
Puts the device to sleep
The following API call is used for hibernate, deepsleep and sleep:
coreStatus_t status = LoRaWAN_Sleep(&sleepConfig);
Where sleepConfig is configured:
sleepConfig_t sleepConfig = {
.sleepMode = modeDeepSleep,
.sleepCores = coresBoth,
.wakeUpPin = wakeUpPinOff,
.wakeUpTime = wakeUpDelay(0, 0, 0, 15)
};
Caution: All members of the sleepConfig structure have to be assigned!
The following members have to be assigned with one of the parameters:
.sleepmode:
modeSleep
modeDeepSleep
modeHibernate
.sleepCores:
coresM0p
coresM4
coresBoth
.wakeUpPin:
wakeUpPinHigh(bool pullDown)
wakeUpPinDown(bool pullUp)
wakeUpPinOff
.wakeUpTime:
wakeUpDelay(uint8 days, uint8 hours, uint8 minutes, uint8 seconds)
wakeUpTimestamp(uint32 timestamp)
wakeUpTimeOff
Examples:
DeepSleep on both cores and wake up on pin P0_4 falling edge with internal pull-up
sleepConfig_t sleepConfig = {
.sleepMode = modeDeepSleep,
.sleepCores = coresBoth,
.wakeUpPin = wakeUpPinDown(true),
.wakeUpTime = wakeUpTimeOff
};
Sleep on CM0+ and wake up on pin P0_4 rising edge without internal pull down
sleepConfig_t sleepConfig = {
.sleepMode = modeSleep,
.sleepCores = coresM0p,
.wakeUpPin = wakeUpPinUp(false),
.wakeUpTime = wakeUpTimeOff
};
Hibernate and wakeup after 180 seconds
Note: Hibernate always shuts down most parts of the system including both cores. Member .sleepCores will be ignored when using hibernate sleepmode.
The device will wake up which includes a device reset. SRAM will not be preserved.
sleepConfig_t sleepConfig = {
.sleepMode = modeHibernate,
.sleepCores = coresBoth,
.wakeUpPin = wakeUpPinOff,
.wakeUpTime = wakeUpDelay(0, 0, 0, 180)
};
wakeUpDelay(days, hours, minutes, seconds) adds all four parameters
eg. a delay of 12 days, 4 hours, 3 minutes and 0 seconds can be created in multiple ways:
wakeUpDelay(12, 4, 3, 0), or
wakeUpDelay(12, 4, 0, 180), or
wakeUpDelay(11, 26, 120, 180),
as long as each parameter fits in 8 bits (< 256)