@@ -87,20 +87,18 @@ static Mcps_t interpret_mcps_confirm_type(const lora_mac_mcps_t& local);
87
87
static Mib_t interpret_mib_req_confirm_type (const lora_mac_mib_t & mib_local);
88
88
static lora_mac_event_info_status_t interpret_event_info_type (const LoRaMacEventInfoStatus_t& remote);
89
89
90
- #if MBED_CONF_LORA_PHY == 0
91
- #include " lorawan/lorastack/mac/LoRaMacTest.h"
92
- #endif
93
-
94
- /* *
95
- *
96
- * User application data buffer size if compliance test is used
97
- */
98
- #if (MBED_CONF_LORA_PHY == 0 || MBED_CONF_LORA_PHY == 4 || MBED_CONF_LORA_PHY == 6 || MBED_CONF_LORA_PHY == 7)
99
- #define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 16
100
- #elif (MBED_CONF_LORA_PHY == 1 || MBED_CONF_LORA_PHY == 2 || MBED_CONF_LORA_PHY == 8 || MBED_CONF_LORA_PHY == 9)
101
- #define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 11
102
- #else
103
- #error "Must set LoRa PHY layer parameters."
90
+ #if defined(LORAWAN_COMPLIANCE_TEST)
91
+ /* *
92
+ *
93
+ * User application data buffer size if compliance test is used
94
+ */
95
+ #if (MBED_CONF_LORA_PHY == 0 || MBED_CONF_LORA_PHY == 4 || MBED_CONF_LORA_PHY == 6 || MBED_CONF_LORA_PHY == 7)
96
+ #define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 16
97
+ #elif (MBED_CONF_LORA_PHY == 1 || MBED_CONF_LORA_PHY == 2 || MBED_CONF_LORA_PHY == 8 || MBED_CONF_LORA_PHY == 9)
98
+ #define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 11
99
+ #else
100
+ #error "Must set LoRa PHY layer parameters."
101
+ #endif
104
102
#endif
105
103
106
104
/* ****************************************************************************
@@ -186,15 +184,20 @@ lora_mac_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
186
184
static LoRaMacPrimitives_t LoRaMacPrimitives;
187
185
static LoRaMacCallback_t LoRaMacCallbacks;
188
186
static lora_mac_mib_request_confirm_t mib_req;
187
+
188
+ #if defined(LORAWAN_COMPLIANCE_TEST)
189
189
static uint8_t compliance_test_buffer[LORAWAN_TX_MAX_SIZE];
190
+ #endif
190
191
191
192
tr_debug (" Initializing MAC layer" );
192
193
193
194
// store a pointer to Event Queue
194
195
_queue = queue;
195
196
197
+ #if defined(LORAWAN_COMPLIANCE_TEST)
196
198
// Allocate memory for compliance test
197
199
_compliance_test.app_data_buffer = compliance_test_buffer;
200
+ #endif
198
201
199
202
TimerTimeCounterInit ( );
200
203
LoRaMacPrimitives.MacMcpsConfirm = callback (this , &LoRaWANStack::mcps_confirm);
@@ -219,6 +222,7 @@ lora_mac_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
219
222
return lora_state_machine ();
220
223
}
221
224
225
+ #if defined(LORAWAN_COMPLIANCE_TEST)
222
226
/* *
223
227
*
224
228
* Prepares the upload message to reserved ports
@@ -305,6 +309,7 @@ lora_mac_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
305
309
306
310
return mcps_request_handler (&mcps_req);
307
311
}
312
+ #endif
308
313
309
314
uint16_t LoRaWANStack::check_possible_tx_size (uint16_t size)
310
315
{
@@ -803,9 +808,11 @@ int16_t LoRaWANStack::handle_tx(uint8_t port, const uint8_t* data,
803
808
return LORA_MAC_STATUS_WOULD_BLOCK;
804
809
}
805
810
811
+ #if defined(LORAWAN_COMPLIANCE_TEST)
806
812
if (_compliance_test.running ) {
807
813
return LORA_MAC_STATUS_COMPLIANCE_TEST_ON;
808
814
}
815
+ #endif
809
816
810
817
lora_mac_mib_request_confirm_t mib_req;
811
818
lora_mac_status_t status;
@@ -900,9 +907,11 @@ int16_t LoRaWANStack::handle_rx(const uint8_t port, uint8_t* data,
900
907
return LORA_MAC_STATUS_WOULD_BLOCK;
901
908
}
902
909
910
+ #if defined(LORAWAN_COMPLIANCE_TEST)
903
911
if (_compliance_test.running ) {
904
912
return LORA_MAC_STATUS_COMPLIANCE_TEST_ON;
905
913
}
914
+ #endif
906
915
907
916
if (data == NULL ) {
908
917
return LORA_MAC_STATUS_PARAMETER_INVALID;
@@ -1035,11 +1044,13 @@ void LoRaWANStack::mlme_confirm_handler(lora_mac_mlme_confirm_t *mlme_confirm)
1035
1044
if (mlme_confirm->status == LORA_EVENT_INFO_STATUS_OK) {
1036
1045
// Check DemodMargin
1037
1046
// Check NbGateways
1047
+ #if defined(LORAWAN_COMPLIANCE_TEST)
1038
1048
if (_compliance_test.running == true ) {
1039
1049
_compliance_test.link_check = true ;
1040
1050
_compliance_test.demod_margin = mlme_confirm->demod_margin ;
1041
1051
_compliance_test.nb_gateways = mlme_confirm->nb_gateways ;
1042
1052
}
1053
+ #endif
1043
1054
}
1044
1055
break ;
1045
1056
default :
@@ -1189,15 +1200,21 @@ void LoRaWANStack::mcps_indication_handler(lora_mac_mcps_indication_t *mcps_indi
1189
1200
1190
1201
_lw_session.downlink_counter ++;
1191
1202
1203
+ #if defined(LORAWAN_COMPLIANCE_TEST)
1192
1204
if (_compliance_test.running == true ) {
1193
1205
_compliance_test.downlink_counter ++;
1194
1206
}
1207
+ #endif
1195
1208
1196
1209
if (mcps_indication->rx_data == true ) {
1197
1210
switch (mcps_indication->port ) {
1198
1211
case 224 :
1212
+ #if defined(LORAWAN_COMPLIANCE_TEST)
1199
1213
tr_debug (" Compliance test command received." );
1200
1214
compliance_test_handler (mcps_indication);
1215
+ #else
1216
+ tr_debug (" Compliance test disabled." );
1217
+ #endif
1201
1218
break ;
1202
1219
default :
1203
1220
if (is_port_valid (mcps_indication->port ) == true ||
@@ -1236,6 +1253,7 @@ void LoRaWANStack::mcps_indication_handler(lora_mac_mcps_indication_t *mcps_indi
1236
1253
}
1237
1254
}
1238
1255
1256
+ #if defined(LORAWAN_COMPLIANCE_TEST)
1239
1257
/* * Compliance testing function
1240
1258
*
1241
1259
* \param mcps_indication Pointer to the indication structure,
@@ -1369,6 +1387,7 @@ void LoRaWANStack::compliance_test_handler(lora_mac_mcps_indication_t *mcps_indi
1369
1387
}
1370
1388
}
1371
1389
}
1390
+ #endif
1372
1391
1373
1392
lora_mac_status_t LoRaWANStack::mib_set_request (lora_mac_mib_request_confirm_t *mib_set_params)
1374
1393
{
@@ -1775,7 +1794,9 @@ lora_mac_status_t LoRaWANStack::lora_state_machine()
1775
1794
drop_channel_list ();
1776
1795
1777
1796
// Stop sending messages and set joined status to false.
1778
- LoRaMacStopTxTimer ();
1797
+ #if defined(LORAWAN_COMPLIANCE_TEST)
1798
+ _loramac.LoRaMacStopTxTimer ();
1799
+ #endif
1779
1800
mib_req.type = LORA_MIB_NETWORK_JOINED;
1780
1801
mib_req.param .is_network_joined = false ;
1781
1802
mib_set_request (&mib_req);
@@ -1909,6 +1930,7 @@ lora_mac_status_t LoRaWANStack::lora_state_machine()
1909
1930
// Do nothing
1910
1931
status = LORA_MAC_STATUS_IDLE;
1911
1932
break ;
1933
+ #if defined(LORAWAN_COMPLIANCE_TEST)
1912
1934
case DEVICE_STATE_COMPLIANCE_TEST:
1913
1935
// Device is in compliance test mode
1914
1936
tr_debug (" Device is in compliance test mode." );
@@ -1920,6 +1942,7 @@ lora_mac_status_t LoRaWANStack::lora_state_machine()
1920
1942
}
1921
1943
status = LORA_MAC_STATUS_COMPLIANCE_TEST_ON;
1922
1944
break ;
1945
+ #endif
1923
1946
default :
1924
1947
status = LORA_MAC_STATUS_SERVICE_UNKNOWN;
1925
1948
break ;
0 commit comments