Skip to content

Commit 9a9a209

Browse files
author
Teppo Järvelin
committed
Cellular: added radio access technology as configurable in cellular mbed_lib.json.
1 parent aae6bb1 commit 9a9a209

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

features/cellular/framework/device/CellularStateMachine.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,25 @@ bool CellularStateMachine::device_ready()
378378
if (_cellularDevice.init_module() != NSAPI_ERROR_OK) {
379379
return false;
380380
}
381+
382+
if (!_network) {
383+
_network = _cellularDevice.open_network();
384+
}
385+
386+
#ifdef MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY
387+
MBED_ASSERT(MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY >= CellularNetwork::RAT_GSM &&
388+
MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY < CellularNetwork::RAT_UNKNOWN);
389+
nsapi_error_t err = _network->set_access_technology((CellularNetwork::RadioAccessTechnology)MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY);
390+
if (err != NSAPI_ERROR_OK && err != NSAPI_ERROR_UNSUPPORTED) {
391+
tr_warning("Failed to set access technology to %d", MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY);
392+
return false;
393+
}
394+
#endif // MBED_CONF_CELLULAR_DEBUG_AT
395+
381396
if (_event_status_cb) {
382397
_event_status_cb((nsapi_event_t)CellularDeviceReady, (intptr_t)&_cb_data);
383398
}
399+
384400
_power->remove_device_ready_urc_cb(mbed::callback(this, &CellularStateMachine::ready_urc_cb));
385401
_cellularDevice.close_power();
386402
_power = NULL;
@@ -410,9 +426,6 @@ void CellularStateMachine::state_sim_pin()
410426
_cellularDevice.set_timeout(TIMEOUT_SIM_PIN);
411427
tr_info("Setup SIM (timeout %d s)", TIMEOUT_SIM_PIN / 1000);
412428
if (open_sim()) {
413-
if (!_network) {
414-
_network = _cellularDevice.open_network();
415-
}
416429

417430
bool success = false;
418431
for (int type = 0; type < CellularNetwork::C_MAX; type++) {

features/cellular/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"debug-at": {
1313
"help": "Enable AT debug prints",
1414
"value": false
15+
},
16+
"radio-access-technology": {
17+
"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",
18+
"value": null
1519
}
1620
}
1721
}

0 commit comments

Comments
 (0)