From 9a9a209eff3397a01eabb4595df26d30dd44183a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teppo=20J=C3=A4rvelin?= Date: Tue, 20 Nov 2018 15:15:50 +0200 Subject: [PATCH 1/2] Cellular: added radio access technology as configurable in cellular mbed_lib.json. --- .../framework/device/CellularStateMachine.cpp | 19 ++++++++++++++++--- features/cellular/mbed_lib.json | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/features/cellular/framework/device/CellularStateMachine.cpp b/features/cellular/framework/device/CellularStateMachine.cpp index 3e7dd5ef8cb..050147972fa 100644 --- a/features/cellular/framework/device/CellularStateMachine.cpp +++ b/features/cellular/framework/device/CellularStateMachine.cpp @@ -378,9 +378,25 @@ bool CellularStateMachine::device_ready() if (_cellularDevice.init_module() != NSAPI_ERROR_OK) { return false; } + + if (!_network) { + _network = _cellularDevice.open_network(); + } + +#ifdef MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY + MBED_ASSERT(MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY >= CellularNetwork::RAT_GSM && + MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY < CellularNetwork::RAT_UNKNOWN); + nsapi_error_t err = _network->set_access_technology((CellularNetwork::RadioAccessTechnology)MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY); + if (err != NSAPI_ERROR_OK && err != NSAPI_ERROR_UNSUPPORTED) { + tr_warning("Failed to set access technology to %d", MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY); + return false; + } +#endif // MBED_CONF_CELLULAR_DEBUG_AT + if (_event_status_cb) { _event_status_cb((nsapi_event_t)CellularDeviceReady, (intptr_t)&_cb_data); } + _power->remove_device_ready_urc_cb(mbed::callback(this, &CellularStateMachine::ready_urc_cb)); _cellularDevice.close_power(); _power = NULL; @@ -410,9 +426,6 @@ void CellularStateMachine::state_sim_pin() _cellularDevice.set_timeout(TIMEOUT_SIM_PIN); tr_info("Setup SIM (timeout %d s)", TIMEOUT_SIM_PIN / 1000); if (open_sim()) { - if (!_network) { - _network = _cellularDevice.open_network(); - } bool success = false; for (int type = 0; type < CellularNetwork::C_MAX; type++) { diff --git a/features/cellular/mbed_lib.json b/features/cellular/mbed_lib.json index 0a70b96b3e5..cc41f2dbe49 100644 --- a/features/cellular/mbed_lib.json +++ b/features/cellular/mbed_lib.json @@ -12,6 +12,10 @@ "debug-at": { "help": "Enable AT debug prints", "value": false + }, + "radio-access-technology": { + "help": "Radio access technology to use. Value in integer: GSM=0, GSM_COMPACT=1, UTRAN=2, EGPRS=3, HSDPA=4, HSUPA=5, HSDPA_HSUPA=6, E_UTRAN=7, CATM1=8 ,NB1=9", + "value": null } } } From f31db91cfb04209c5f2f7b85535b3f3b90b9179d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teppo=20J=C3=A4rvelin?= Date: Tue, 20 Nov 2018 15:40:26 +0200 Subject: [PATCH 2/2] Cellular: astyle fixes for CellularStateMachine.cpp. --- features/cellular/framework/device/CellularStateMachine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/cellular/framework/device/CellularStateMachine.cpp b/features/cellular/framework/device/CellularStateMachine.cpp index 050147972fa..75e9416c14f 100644 --- a/features/cellular/framework/device/CellularStateMachine.cpp +++ b/features/cellular/framework/device/CellularStateMachine.cpp @@ -385,7 +385,7 @@ bool CellularStateMachine::device_ready() #ifdef MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY MBED_ASSERT(MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY >= CellularNetwork::RAT_GSM && - MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY < CellularNetwork::RAT_UNKNOWN); + MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY < CellularNetwork::RAT_UNKNOWN); nsapi_error_t err = _network->set_access_technology((CellularNetwork::RadioAccessTechnology)MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY); if (err != NSAPI_ERROR_OK && err != NSAPI_ERROR_UNSUPPORTED) { tr_warning("Failed to set access technology to %d", MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY);