mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #3 from AnttiKauppila/fix_compliance_test
Fix compilance test compilationpull/6411/head
commit
fd9a6af93b
|
@ -189,10 +189,6 @@ lorawan_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
|
||||||
tr_debug("Initializing MAC layer");
|
tr_debug("Initializing MAC layer");
|
||||||
_queue = queue;
|
_queue = queue;
|
||||||
|
|
||||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
|
||||||
_compliance_test.app_data_buffer = compliance_test_buffer;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_loramac.initialize(&LoRaMacPrimitives, queue);
|
_loramac.initialize(&LoRaMacPrimitives, queue);
|
||||||
|
|
||||||
// Reset counters to zero. Will change in future with 1.1 support.
|
// Reset counters to zero. Will change in future with 1.1 support.
|
||||||
|
@ -876,36 +872,34 @@ lorawan_status_t LoRaWANStack::lora_state_machine(device_states_t new_state)
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
|
lorawan_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
|
||||||
{
|
{
|
||||||
loramac_mcps_req_t mcps_req;
|
loramac_compliance_test_req_t test_req;
|
||||||
|
|
||||||
// prepare_special_tx_frame(_compliance_test.app_port);
|
|
||||||
//TODO: What if the port is not 224 ???
|
//TODO: What if the port is not 224 ???
|
||||||
if (_compliance_test.app_port == 224) {
|
if (_compliance_test.app_port == 224) {
|
||||||
// Clear any normal message stuff before compliance test.
|
// Clear any normal message stuff before compliance test.
|
||||||
memset(&mcps_req, 0, sizeof(mcps_req));
|
memset(&test_req, 0, sizeof(test_req));
|
||||||
|
|
||||||
if (_compliance_test.link_check == true) {
|
if (_compliance_test.link_check == true) {
|
||||||
_compliance_test.link_check = false;
|
_compliance_test.link_check = false;
|
||||||
_compliance_test.state = 1;
|
_compliance_test.state = 1;
|
||||||
mcps_req.f_buffer_size = 3;
|
test_req.f_buffer_size = 3;
|
||||||
mcps_req.f_buffer[0] = 5;
|
test_req.f_buffer[0] = 5;
|
||||||
mcps_req.f_buffer[1] = _compliance_test.demod_margin;
|
test_req.f_buffer[1] = _compliance_test.demod_margin;
|
||||||
mcps_req.f_buffer[2] = _compliance_test.nb_gateways;
|
test_req.f_buffer[2] = _compliance_test.nb_gateways;
|
||||||
} else {
|
} else {
|
||||||
switch (_compliance_test.state) {
|
switch (_compliance_test.state) {
|
||||||
case 4:
|
case 4:
|
||||||
_compliance_test.state = 1;
|
_compliance_test.state = 1;
|
||||||
mcps_req.f_buffer_size = _compliance_test.app_data_size;
|
test_req.f_buffer_size = _compliance_test.app_data_size;
|
||||||
|
test_req.f_buffer[0] = _compliance_test.app_data_buffer[0];
|
||||||
mcps_req.f_buffer[0] = _compliance_test.app_data_buffer[0];
|
|
||||||
for(uint8_t i = 1; i < MIN(_compliance_test.app_data_size, MBED_CONF_LORA_TX_MAX_SIZE); ++i) {
|
for(uint8_t i = 1; i < MIN(_compliance_test.app_data_size, MBED_CONF_LORA_TX_MAX_SIZE); ++i) {
|
||||||
mcps_req.f_buffer[i] = _compliance_test.app_data_buffer[i];
|
test_req.f_buffer[i] = _compliance_test.app_data_buffer[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
mcps_req.f_buffer_size = 2;
|
test_req.f_buffer_size = 2;
|
||||||
mcps_req.f_buffer[0] = _compliance_test.downlink_counter >> 8;
|
test_req.f_buffer[0] = _compliance_test.downlink_counter >> 8;
|
||||||
mcps_req.f_buffer[1] = _compliance_test.downlink_counter;
|
test_req.f_buffer[1] = _compliance_test.downlink_counter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -914,45 +908,32 @@ lorawan_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
|
||||||
//TODO: If port is not 224, this might not work!
|
//TODO: If port is not 224, this might not work!
|
||||||
//Is there a test case where same _tx_msg's buffer would be used, when port is not 224???
|
//Is there a test case where same _tx_msg's buffer would be used, when port is not 224???
|
||||||
if (!_compliance_test.is_tx_confirmed) {
|
if (!_compliance_test.is_tx_confirmed) {
|
||||||
mcps_req.type = MCPS_UNCONFIRMED;
|
test_req.type = MCPS_UNCONFIRMED;
|
||||||
// mcps_req.f_buffer = _tx_msg.f_buffer;
|
test_req.fport = _compliance_test.app_port;
|
||||||
// mcps_req.f_buffer_size = _tx_msg.f_buffer_size;
|
test_req.nb_trials = 1;
|
||||||
mcps_req.fport = _compliance_test.app_port;
|
test_req.data_rate = _loramac.get_default_tx_datarate();
|
||||||
mcps_req.nb_trials = 1;
|
|
||||||
mcps_req.data_rate = _loramac.get_default_tx_datarate();
|
|
||||||
|
|
||||||
tr_info("Transmit unconfirmed compliance test frame %d bytes.", mcps_req.f_buffer_size);
|
tr_info("Transmit unconfirmed compliance test frame %d bytes.", test_req.f_buffer_size);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < mcps_req.f_buffer_size; ++i) {
|
for (uint8_t i = 0; i < test_req.f_buffer_size; ++i) {
|
||||||
tr_info("Byte %d, data is 0x%x", i+1, ((uint8_t*)mcps_req.f_buffer)[i]);
|
tr_info("Byte %d, data is 0x%x", i+1, ((uint8_t*)test_req.f_buffer)[i]);
|
||||||
}
|
}
|
||||||
} else if (_compliance_test.is_tx_confirmed) {
|
} else if (_compliance_test.is_tx_confirmed) {
|
||||||
mcps_req.type = MCPS_CONFIRMED;
|
test_req.type = MCPS_CONFIRMED;
|
||||||
// mcps_req.f_buffer = _tx_msg.f_buffer;
|
test_req.fport = _compliance_test.app_port;
|
||||||
// mcps_req.f_buffer_size = _tx_msg.f_buffer_size;
|
test_req.nb_trials = _num_retry;
|
||||||
mcps_req.fport = _compliance_test.app_port;
|
test_req.data_rate = _loramac.get_default_tx_datarate();
|
||||||
mcps_req.nb_trials = _num_retry;
|
|
||||||
mcps_req.data_rate = _loramac.get_default_tx_datarate();
|
|
||||||
|
|
||||||
tr_info("Transmit confirmed compliance test frame %d bytes.", mcps_req.f_buffer_size);
|
tr_info("Transmit confirmed compliance test frame %d bytes.", test_req.f_buffer_size);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < mcps_req.f_buffer_size; ++i) {
|
for (uint8_t i = 0; i < test_req.f_buffer_size; ++i) {
|
||||||
tr_info("Byte %d, data is 0x%x", i+1, ((uint8_t*)mcps_req.f_buffer)[i]);
|
tr_info("Byte %d, data is 0x%x", i+1, ((uint8_t*)test_req.f_buffer)[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return LORAWAN_STATUS_SERVICE_UNKNOWN;
|
return LORAWAN_STATUS_SERVICE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mcps_request_handler(&mcps_req);
|
return _loramac.test_request(&test_req);
|
||||||
}
|
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::mcps_request_handler(loramac_mcps_req_t *mcps_request)
|
|
||||||
{
|
|
||||||
if (mcps_request == NULL) {
|
|
||||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _loramac.mcps_request(mcps_request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRaWANStack::compliance_test_handler(loramac_mcps_indication_t *mcps_indication)
|
void LoRaWANStack::compliance_test_handler(loramac_mcps_indication_t *mcps_indication)
|
||||||
|
@ -1035,8 +1016,6 @@ void LoRaWANStack::compliance_test_handler(loramac_mcps_indication_t *mcps_indic
|
||||||
_loramac.setup_link_check_request();
|
_loramac.setup_link_check_request();
|
||||||
break;
|
break;
|
||||||
case 6: // (ix)
|
case 6: // (ix)
|
||||||
loramac_mlme_req_t mlme_req;
|
|
||||||
|
|
||||||
// Disable TestMode and revert back to normal operation
|
// Disable TestMode and revert back to normal operation
|
||||||
_compliance_test.is_tx_confirmed = true;
|
_compliance_test.is_tx_confirmed = true;
|
||||||
_compliance_test.app_port = MBED_CONF_LORA_APP_PORT;
|
_compliance_test.app_port = MBED_CONF_LORA_APP_PORT;
|
||||||
|
|
|
@ -471,17 +471,11 @@ private:
|
||||||
*/
|
*/
|
||||||
void compliance_test_handler(loramac_mcps_indication_t *mcps_indication);
|
void compliance_test_handler(loramac_mcps_indication_t *mcps_indication);
|
||||||
|
|
||||||
/**
|
|
||||||
* Used only for compliance testing
|
|
||||||
*/
|
|
||||||
lorawan_status_t mcps_request_handler(loramac_mcps_req_t *mcps_request);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used only for compliance testing
|
* Used only for compliance testing
|
||||||
*/
|
*/
|
||||||
lorawan_status_t send_compliance_test_frame_to_mac();
|
lorawan_status_t send_compliance_test_frame_to_mac();
|
||||||
|
|
||||||
uint8_t compliance_test_buffer[MBED_CONF_LORA_TX_MAX_SIZE];
|
|
||||||
compliance_test_t _compliance_test;
|
compliance_test_t _compliance_test;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -1995,7 +1995,7 @@ lorawan_status_t LoRaMac::mlme_request( loramac_mlme_req_t *mlmeRequest )
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
lorawan_status_t LoRaMac::mcps_request( loramac_mcps_req_t *mcpsRequest )
|
lorawan_status_t LoRaMac::test_request( loramac_compliance_test_req_t *mcpsRequest )
|
||||||
{
|
{
|
||||||
if (_params.mac_state != LORAMAC_IDLE) {
|
if (_params.mac_state != LORAMAC_IDLE) {
|
||||||
return LORAWAN_STATUS_BUSY;
|
return LORAWAN_STATUS_BUSY;
|
||||||
|
|
|
@ -621,20 +621,20 @@ public: // Test interface
|
||||||
*
|
*
|
||||||
* uint8_t buffer[] = {1, 2, 3};
|
* uint8_t buffer[] = {1, 2, 3};
|
||||||
*
|
*
|
||||||
* loramac_mcps_req_t request;
|
* loramac_compliance_test_req_t request;
|
||||||
* request.type = MCPS_UNCONFIRMED;
|
* request.type = MCPS_UNCONFIRMED;
|
||||||
* request.fport = 1;
|
* request.fport = 1;
|
||||||
* request.f_buffer = buffer;
|
* request.f_buffer = buffer;
|
||||||
* request.f_buffer_size = sizeof(buffer);
|
* request.f_buffer_size = sizeof(buffer);
|
||||||
*
|
*
|
||||||
* if (mcps_request(&request) == LORAWAN_STATUS_OK) {
|
* if (test_request(&request) == LORAWAN_STATUS_OK) {
|
||||||
* // Service started successfully. Waiting for the MCPS-Confirm event
|
* // Service started successfully. Waiting for the MCPS-Confirm event
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param [in] request The MCPS request to perform.
|
* @param [in] request The test request to perform.
|
||||||
* Refer to \ref loramac_mcps_req_t.
|
* Refer to \ref loramac_compliance_test_req_t.
|
||||||
*
|
*
|
||||||
* @return `lorawan_status_t` The status of the operation. The possible values are:
|
* @return `lorawan_status_t` The status of the operation. The possible values are:
|
||||||
* \ref LORAWAN_STATUS_OK
|
* \ref LORAWAN_STATUS_OK
|
||||||
|
@ -645,7 +645,7 @@ public: // Test interface
|
||||||
* \ref LORAWAN_STATUS_LENGTH_ERROR
|
* \ref LORAWAN_STATUS_LENGTH_ERROR
|
||||||
* \ref LORAWAN_STATUS_DEVICE_OFF
|
* \ref LORAWAN_STATUS_DEVICE_OFF
|
||||||
*/
|
*/
|
||||||
lorawan_status_t mcps_request(loramac_mcps_req_t *request);
|
lorawan_status_t test_request(loramac_compliance_test_req_t *request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief LoRaMAC set tx timer.
|
* \brief LoRaMAC set tx timer.
|
||||||
|
|
|
@ -1744,7 +1744,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/*!
|
/*!
|
||||||
* MCPS-Request type.
|
* Compiliance test request
|
||||||
*/
|
*/
|
||||||
mcps_type_t type;
|
mcps_type_t type;
|
||||||
|
|
||||||
|
@ -1786,14 +1786,15 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* A pointer to the buffer of the frame payload.
|
* A pointer to the buffer of the frame payload.
|
||||||
*/
|
*/
|
||||||
void *f_buffer;
|
uint8_t f_buffer[LORAMAC_PHY_MAXPAYLOAD];
|
||||||
/** Payload size
|
|
||||||
*
|
|
||||||
* The size of the frame payload.
|
|
||||||
*/
|
|
||||||
uint16_t f_buffer_size;
|
|
||||||
|
|
||||||
} loramac_mcps_req_t;
|
/** Payload size
|
||||||
|
*
|
||||||
|
* The size of the frame payload.
|
||||||
|
*/
|
||||||
|
uint16_t f_buffer_size;
|
||||||
|
|
||||||
|
} loramac_compliance_test_req_t;
|
||||||
|
|
||||||
/** LoRaWAN compliance tests support data
|
/** LoRaWAN compliance tests support data
|
||||||
*
|
*
|
||||||
|
@ -1822,7 +1823,7 @@ typedef struct compliance_test {
|
||||||
/** Data provided by application
|
/** Data provided by application
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint8_t *app_data_buffer;
|
uint8_t app_data_buffer[MBED_CONF_LORA_TX_MAX_SIZE];
|
||||||
/** Downlink counter
|
/** Downlink counter
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue