mirror of https://github.com/ARMmbed/mbed-os.git
Lora: All API methods should check if stack has been initialized
parent
52cb119571
commit
d3327c3f5a
|
@ -127,6 +127,10 @@ lorawan_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::set_lora_callbacks(const lorawan_app_callbacks_t *callbacks)
|
lorawan_status_t LoRaWANStack::set_lora_callbacks(const lorawan_app_callbacks_t *callbacks)
|
||||||
{
|
{
|
||||||
|
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
||||||
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
if (!callbacks || !callbacks->events) {
|
if (!callbacks || !callbacks->events) {
|
||||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +152,6 @@ lorawan_status_t LoRaWANStack::set_lora_callbacks(const lorawan_app_callbacks_t
|
||||||
lorawan_status_t LoRaWANStack::connect()
|
lorawan_status_t LoRaWANStack::connect()
|
||||||
{
|
{
|
||||||
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
||||||
tr_error("Stack not initialized!");
|
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +167,6 @@ lorawan_status_t LoRaWANStack::connect()
|
||||||
lorawan_status_t LoRaWANStack::connect(const lorawan_connect_t &connect)
|
lorawan_status_t LoRaWANStack::connect(const lorawan_connect_t &connect)
|
||||||
{
|
{
|
||||||
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
||||||
tr_error("Stack not initialized!");
|
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +188,6 @@ lorawan_status_t LoRaWANStack::connect(const lorawan_connect_t &connect)
|
||||||
lorawan_status_t LoRaWANStack::add_channels(const lorawan_channelplan_t &channel_plan)
|
lorawan_status_t LoRaWANStack::add_channels(const lorawan_channelplan_t &channel_plan)
|
||||||
{
|
{
|
||||||
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
||||||
tr_error("Stack not initialized!");
|
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +197,6 @@ lorawan_status_t LoRaWANStack::add_channels(const lorawan_channelplan_t &channel
|
||||||
lorawan_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
|
lorawan_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
|
||||||
{
|
{
|
||||||
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
||||||
tr_error("Stack not initialized!");
|
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,6 @@ lorawan_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
|
||||||
lorawan_status_t LoRaWANStack::drop_channel_list()
|
lorawan_status_t LoRaWANStack::drop_channel_list()
|
||||||
{
|
{
|
||||||
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
||||||
tr_error("Stack not initialized!");
|
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +215,6 @@ lorawan_status_t LoRaWANStack::drop_channel_list()
|
||||||
lorawan_status_t LoRaWANStack::get_enabled_channels(lorawan_channelplan_t& channel_plan)
|
lorawan_status_t LoRaWANStack::get_enabled_channels(lorawan_channelplan_t& channel_plan)
|
||||||
{
|
{
|
||||||
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
||||||
tr_error("Stack not initialized!");
|
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,6 +223,10 @@ lorawan_status_t LoRaWANStack::get_enabled_channels(lorawan_channelplan_t& chann
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::set_confirmed_msg_retry(uint8_t count)
|
lorawan_status_t LoRaWANStack::set_confirmed_msg_retry(uint8_t count)
|
||||||
{
|
{
|
||||||
|
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
||||||
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
if (count >= MAX_CONFIRMED_MSG_RETRIES) {
|
if (count >= MAX_CONFIRMED_MSG_RETRIES) {
|
||||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -236,9 +238,7 @@ lorawan_status_t LoRaWANStack::set_confirmed_msg_retry(uint8_t count)
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate)
|
lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate)
|
||||||
{
|
{
|
||||||
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state)
|
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
||||||
{
|
|
||||||
tr_error("Stack not initialized!");
|
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,11 +248,10 @@ lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate)
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::enable_adaptive_datarate(bool adr_enabled)
|
lorawan_status_t LoRaWANStack::enable_adaptive_datarate(bool adr_enabled)
|
||||||
{
|
{
|
||||||
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED)
|
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
||||||
{
|
|
||||||
tr_error("Stack not initialized!");
|
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
_loramac.enable_adaptive_datarate(adr_enabled);
|
_loramac.enable_adaptive_datarate(adr_enabled);
|
||||||
return LORAWAN_STATUS_OK;
|
return LORAWAN_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
@ -410,6 +409,10 @@ int16_t LoRaWANStack::handle_rx(uint8_t* data, uint16_t length, uint8_t& port, i
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::set_link_check_request()
|
lorawan_status_t LoRaWANStack::set_link_check_request()
|
||||||
{
|
{
|
||||||
|
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
||||||
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
_link_check_requested = true;
|
_link_check_requested = true;
|
||||||
if (!_callbacks.link_check_resp) {
|
if (!_callbacks.link_check_resp) {
|
||||||
tr_error("Must assign a callback function for link check request. ");
|
tr_error("Must assign a callback function for link check request. ");
|
||||||
|
@ -427,11 +430,19 @@ void LoRaWANStack::remove_link_check_request()
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::shutdown()
|
lorawan_status_t LoRaWANStack::shutdown()
|
||||||
{
|
{
|
||||||
|
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
||||||
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
return state_controller(DEVICE_STATE_SHUTDOWN);
|
return state_controller(DEVICE_STATE_SHUTDOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::set_device_class(const device_class_t& device_class)
|
lorawan_status_t LoRaWANStack::set_device_class(const device_class_t& device_class)
|
||||||
{
|
{
|
||||||
|
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
|
||||||
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
if (device_class == CLASS_B) {
|
if (device_class == CLASS_B) {
|
||||||
return LORAWAN_STATUS_UNSUPPORTED;
|
return LORAWAN_STATUS_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue