Skip to content

Commit ed493ce

Browse files
committedJan 29, 2018
Fix ABP activiation procedure
1 parent bf7dcef commit ed493ce

File tree

8 files changed

+114
-95
lines changed

8 files changed

+114
-95
lines changed
 

‎Projects/Multi/Applications/LoRa/AT_Slave/SW4STM32/B-L072Z-LRWAN1/mlm32l07x01/.settings/language.settings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
77
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
88
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
9-
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="848516111187429693" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
9+
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="-1061497626167655012" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
1010
<language-scope id="org.eclipse.cdt.core.gcc"/>
1111
<language-scope id="org.eclipse.cdt.core.g++"/>
1212
</provider>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This is an B-L072Z-LRWAN1 board with a single STM32L072CZYx chip
2+
#
3+
# Generated by System Workbench for STM32
4+
# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
5+
6+
source [find interface/stlink.cfg]
7+
8+
set WORKAREASIZE 0x5000
9+
10+
transport select "hla_swd"
11+
12+
set CHIPNAME STM32L072CZYx
13+
14+
# Enable debug when in low power modes
15+
set ENABLE_LOW_POWER 1
16+
17+
# Stop Watchdog counters when halt
18+
set STOP_WATCHDOG 1
19+
20+
# STlink Debug clock frequency
21+
set CLOCK_FREQ 4000
22+
23+
# use hardware reset, connect under reset
24+
# connect_assert_srst needed if low power mode application running (WFI...)
25+
reset_config srst_only srst_nogate connect_assert_srst
26+
set CONNECT_UNDER_RESET 1
27+
28+
source [find target/stm32l0x.cfg]

‎Projects/Multi/Applications/LoRa/AT_Slave/inc/at.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ typedef enum eATEerror
100100
#define AT_JN1DL "+JN1DL"
101101
#define AT_JN2DL "+JN2DL"
102102
#define AT_NJM "+MODE"
103-
#define AT_NWKID "+NWKID"
103+
#define AT_NWKID "+IDNWK"
104104
#define AT_FCU "+FCU"
105105
#define AT_FCD "+FCD"
106106
#define AT_CLASS "+CLASS"

‎Projects/Multi/Applications/LoRa/AT_Slave/inc/lora.h

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ Maintainer: Miguel Luis, Gregory Cristian and Wael Guibene
8686
uint8_t DevEui[8]; /*< Device EUI */
8787
uint8_t AppEui[8]; /*< Application EUI */
8888
uint8_t AppKey[16]; /*< Application Key */
89+
uint32_t NetworkID; /*< Network ID */
90+
uint32_t DevAddr; /*< Device Address */
8991
uint8_t NwkSKey[16]; /*< Network Session Key */
9092
uint8_t AppSKey[16]; /*< Application Session Key */
9193
int16_t Rssi; /*< Rssi of the received packet */

‎Projects/Multi/Applications/LoRa/AT_Slave/inc/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ extern "C" {
7272
#define TEST_VERSION (uint32_t) 0x00000000 /*1 lsb is always 0 in releases */
7373
#define LRWAN_VERSION (uint32_t) 0x00001120 /*3 next hex is i_cube release*/
7474
#define VERSION (uint32_t) (LORA_MAC_VERSION | LRWAN_VERSION | TEST_VERSION)
75-
#define AT_VERSION_STRING "1.1.2"
75+
#define AT_VERSION_STRING "1.1.3"
7676
#define AT_DEVICE_STRING "ARD-078"
7777

7878
/* Exported types ------------------------------------------------------------*/

‎Projects/Multi/Applications/LoRa/AT_Slave/src/at.c

+36-87
Original file line numberDiff line numberDiff line change
@@ -210,29 +210,34 @@ ATEerror_t at_AppEUI_set(const char *param)
210210

211211
ATEerror_t at_DevAddr_set(const char *param)
212212
{
213-
MibRequestConfirm_t mib;
214-
LoRaMacStatus_t status;
213+
uint32_t DevAddr;
214+
sscanf_uint32_as_hhx(param, &DevAddr);
215215

216-
mib.Type = MIB_DEV_ADDR;
217-
if (sscanf_uint32_as_hhx(param, &mib.Param.DevAddr) != 4)
218-
{
219-
return AT_PARAM_ERROR;
220-
}
221-
status = LoRaMacMibSetRequestConfirm(&mib);
222-
CHECK_STATUS(status);
223-
return AT_OK;
216+
lora_config_devaddr_set(DevAddr);
217+
return AT_OK;
224218
}
225219

226220
ATEerror_t at_DevAddr_get(const char *param)
227221
{
228-
MibRequestConfirm_t mib;
229-
LoRaMacStatus_t status;
230222

231-
mib.Type = MIB_DEV_ADDR;
232-
status = LoRaMacMibGetRequestConfirm(&mib);
233-
CHECK_STATUS(status);
234223
AT_PRINTF("+OK=");
235-
print_uint32_as_02x(mib.Param.DevAddr);
224+
print_uint32_as_02x(lora_config_devaddr_get());
225+
return AT_OK;
226+
}
227+
228+
ATEerror_t at_NetworkID_get(const char *param)
229+
{
230+
AT_PRINTF("+OK=");
231+
print_uint32_as_02x(lora_config_networkid_get());
232+
return AT_OK;
233+
}
234+
235+
ATEerror_t at_NetworkID_set(const char *param)
236+
{
237+
uint32_t NetworkID;
238+
sscanf_uint32_as_hhx(param, &NetworkID);
239+
240+
lora_config_networkid_set(NetworkID);
236241
return AT_OK;
237242
}
238243

@@ -280,67 +285,41 @@ ATEerror_t at_Band_set(const char *param)
280285

281286
ATEerror_t at_NwkSKey_get(const char *param)
282287
{
283-
MibRequestConfirm_t mib;
284-
LoRaMacStatus_t status;
285-
286-
mib.Type = MIB_NWK_SKEY;
287-
status = LoRaMacMibGetRequestConfirm(&mib);
288-
CHECK_STATUS(status);
289288
AT_PRINTF("+OK=");
290-
print_16_02x(mib.Param.NwkSKey);
291-
289+
print_16_02x(lora_config_nwkskey_get());
292290
return AT_OK;
293291
}
294292

295293
ATEerror_t at_NwkSKey_set(const char *param)
296294
{
297-
MibRequestConfirm_t mib;
298-
LoRaMacStatus_t status;
299-
uint8_t NwkSKey[16];
300-
301-
mib.Type = MIB_NWK_SKEY;
302-
303-
if (sscanf_16_hhx(param, NwkSKey) != 16)
295+
uint8_t NwkSkey[16];
296+
int ret = sscanf_16_hhx(param, NwkSkey);
297+
if (ret != 16)
304298
{
305299
return AT_PARAM_ERROR;
306300
}
307301

308-
mib.Param.NwkSKey = NwkSKey;
309-
status = LoRaMacMibSetRequestConfirm(&mib);
310-
CHECK_STATUS(status);
311-
302+
lora_config_nwkskey_set(NwkSkey);
312303
return AT_OK;
313304
}
314305

315306
ATEerror_t at_AppSKey_get(const char *param)
316307
{
317-
MibRequestConfirm_t mib;
318-
LoRaMacStatus_t status;
319-
320-
mib.Type = MIB_APP_SKEY;
321-
status = LoRaMacMibGetRequestConfirm(&mib);
322-
CHECK_STATUS(status);
323308
AT_PRINTF("+OK=");
324-
print_16_02x(mib.Param.AppSKey);
325-
309+
print_16_02x(lora_config_appskey_get());
326310
return AT_OK;
327311
}
328312

329313
ATEerror_t at_AppSKey_set(const char *param)
330314
{
331-
MibRequestConfirm_t mib;
332-
LoRaMacStatus_t status;
333315
uint8_t AppSKey[16];
334-
335-
mib.Type = MIB_APP_SKEY;
336-
if (sscanf_16_hhx(param, AppSKey) != 16)
316+
int ret = sscanf_16_hhx(param, AppSKey);
317+
if (ret != 16)
337318
{
338319
return AT_PARAM_ERROR;
339320
}
340-
mib.Param.AppSKey = AppSKey;
341-
status = LoRaMacMibSetRequestConfirm(&mib);
342-
CHECK_STATUS(status);
343321

322+
lora_config_appskey_set(AppSKey);
344323
return AT_OK;
345324
}
346325

@@ -720,36 +699,6 @@ ATEerror_t at_NetworkJoinMode_set(const char *param)
720699
return AT_OK;
721700
}
722701

723-
ATEerror_t at_NetworkID_get(const char *param)
724-
{
725-
MibRequestConfirm_t mib;
726-
LoRaMacStatus_t status;
727-
728-
mib.Type = MIB_NET_ID;
729-
status = LoRaMacMibGetRequestConfirm(&mib);
730-
CHECK_STATUS(status);
731-
AT_PRINTF("+OK=");
732-
print_uint32_as_02x(mib.Param.NetID);
733-
734-
return AT_OK;
735-
}
736-
737-
ATEerror_t at_NetworkID_set(const char *param)
738-
{
739-
MibRequestConfirm_t mib;
740-
LoRaMacStatus_t status;
741-
742-
mib.Type = MIB_NET_ID;
743-
if (sscanf_uint32_as_hhx(param, &mib.Param.NetID) != 4)
744-
{
745-
return AT_PARAM_ERROR;
746-
}
747-
status = LoRaMacMibSetRequestConfirm(&mib);
748-
CHECK_STATUS(status);
749-
750-
return AT_OK;
751-
}
752-
753702
ATEerror_t at_UplinkCounter_get(const char *param)
754703
{
755704
MibRequestConfirm_t mib;
@@ -1138,19 +1087,19 @@ static void print_16_02x(uint8_t *pt)
11381087
static int sscanf_uint32_as_hhx(const char *from, uint32_t *value)
11391088
{
11401089
return tiny_sscanf(from, "%02hhx%02hhx%02hhx%02hhx",
1141-
&((unsigned char *)(value))[0],
1142-
&((unsigned char *)(value))[1],
1090+
&((unsigned char *)(value))[3],
11431091
&((unsigned char *)(value))[2],
1144-
&((unsigned char *)(value))[3]);
1092+
&((unsigned char *)(value))[1],
1093+
&((unsigned char *)(value))[0]);
11451094
}
11461095

11471096
static void print_uint32_as_02x(uint32_t value)
11481097
{
11491098
AT_PRINTF("%02x%02x%02x%02x\r",
1150-
(unsigned)((unsigned char *)(&value))[0],
1151-
(unsigned)((unsigned char *)(&value))[1],
1099+
(unsigned)((unsigned char *)(&value))[3],
11521100
(unsigned)((unsigned char *)(&value))[2],
1153-
(unsigned)((unsigned char *)(&value))[3]);
1101+
(unsigned)((unsigned char *)(&value))[1],
1102+
(unsigned)((unsigned char *)(&value))[0]);
11541103
}
11551104

11561105
static void print_8_02x(uint8_t *pt)

‎Projects/Multi/Applications/LoRa/AT_Slave/src/command.c

-2
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ static const struct ATCommand_s ATCommand[] =
331331
.run = at_return_error,
332332
},
333333

334-
#ifndef NO_KEY_ADDR_EUI
335334
{
336335
.string = AT_NWKID,
337336
.size_string = sizeof(AT_NWKID) - 1,
@@ -342,7 +341,6 @@ static const struct ATCommand_s ATCommand[] =
342341
.set = at_NetworkID_set,
343342
.run = at_return_error,
344343
},
345-
#endif
346344

347345
{
348346
.string = AT_FCU,

‎Projects/Multi/Applications/LoRa/AT_Slave/src/lora.c

+45-3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ static lora_configuration_t lora_config =
7272
.DevEui = LORAWAN_DEVICE_EUI,
7373
.AppEui = LORAWAN_APPLICATION_EUI,
7474
.AppKey = LORAWAN_APPLICATION_KEY,
75+
.NetworkID = LORAWAN_NETWORK_ID,
76+
.DevAddr = LORAWAN_DEVICE_ADDRESS,
7577
.NwkSKey = LORAWAN_NWKSKEY,
7678
.AppSKey = LORAWAN_APPSKEY,
7779
.Rssi = 0,
@@ -851,11 +853,11 @@ void lora_fsm( LoRaMacRegion_t region )
851853
else
852854
{
853855
mibReq.Type = MIB_NET_ID;
854-
mibReq.Param.NetID = LORAWAN_NETWORK_ID;
856+
mibReq.Param.NetID = lora_config.NetworkID;
855857
LoRaMacMibSetRequestConfirm( &mibReq );
856858

857859
mibReq.Type = MIB_DEV_ADDR;
858-
mibReq.Param.DevAddr = DevAddr;
860+
mibReq.Param.DevAddr = lora_config.DevAddr;
859861
LoRaMacMibSetRequestConfirm( &mibReq );
860862

861863
mibReq.Type = MIB_NWK_SKEY;
@@ -871,7 +873,7 @@ void lora_fsm( LoRaMacRegion_t region )
871873
LoRaMacMibSetRequestConfirm( &mibReq );
872874
}
873875

874-
DeviceState = DEVICE_STATE_SLEEP;
876+
DeviceState = DEVICE_STATE_JOINED;
875877
break;
876878
}
877879
case DEVICE_STATE_JOINED:
@@ -961,6 +963,46 @@ void lora_config_appeui_set(uint8_t appeui[8])
961963
memcpy1(lora_config.AppEui, appeui, sizeof(lora_config.AppEui));
962964
}
963965

966+
uint32_t lora_config_devaddr_get(void)
967+
{
968+
return lora_config.DevAddr;
969+
}
970+
971+
void lora_config_devaddr_set(uint32_t devaddr)
972+
{
973+
lora_config.DevAddr= devaddr;
974+
}
975+
976+
void lora_config_networkid_set(uint32_t networkid)
977+
{
978+
lora_config.NetworkID = networkid;
979+
}
980+
981+
uint32_t lora_config_networkid_get(void)
982+
{
983+
return lora_config.NetworkID;
984+
}
985+
986+
uint8_t *lora_config_nwkskey_get(void)
987+
{
988+
return lora_config.NwkSKey;
989+
}
990+
991+
void lora_config_nwkskey_set(uint8_t nwkSKey[16])
992+
{
993+
memcpy1(lora_config.NwkSKey, nwkSKey, sizeof(lora_config.NwkSKey));
994+
}
995+
996+
uint8_t *lora_config_appskey_get(void)
997+
{
998+
return lora_config.AppSKey;
999+
}
1000+
1001+
void lora_config_appskey_set(uint8_t appskey[16])
1002+
{
1003+
memcpy1(lora_config.AppSKey, appskey, sizeof(lora_config.AppSKey));
1004+
}
1005+
9641006
uint8_t *lora_config_appkey_get(void)
9651007
{
9661008
return lora_config.AppKey;

0 commit comments

Comments
 (0)
Please sign in to comment.