Skip to content

Commit d7f3341

Browse files
authored
Merge pull request #12339 from jeromecoutant/PR_MODEMVERSION
Cellular : add modem version in mbed trace
2 parents 7383860 + 5f1ea7d commit d7f3341

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,13 @@ bool AT_CellularContext::get_context()
367367
apn_len = _at.read_string(apn, sizeof(apn));
368368
if (apn_len >= 0) {
369369
if (_apn && (strcmp(apn, _apn) != 0)) {
370+
tr_debug("CID %d APN \"%s\"", cid, apn);
370371
continue;
371372
}
372373

373374
// APN matched -> Check PDP type
374375
pdp_type_t pdp_type = string_to_pdp_type(pdp_type_from_context);
376+
tr_debug("CID %d APN \"%s\" pdp_type %u", cid, apn, pdp_type);
375377

376378
// Accept exact matching PDP context type or dual PDP context for modems that support both IPv4 and IPv6 stacks
377379
if (get_device()->get_property(pdp_type_t_to_cellular_property(pdp_type)) ||

features/cellular/framework/device/CellularStateMachine.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "CellularStateMachine.h"
1919
#include "CellularDevice.h"
2020
#include "CellularLog.h"
21+
#include "CellularInformation.h"
2122

2223
#ifndef MBED_TRACE_MAX_LEVEL
2324
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO
@@ -243,8 +244,8 @@ bool CellularStateMachine::get_network_registration(CellularNetwork::Registratio
243244
break;
244245
}
245246

246-
if (is_roaming) {
247-
tr_info("Roaming network.");
247+
if (is_registered || is_roaming) {
248+
tr_info("Roaming %u Registered %u", is_roaming, is_registered);
248249
}
249250

250251
return true;
@@ -360,6 +361,26 @@ void CellularStateMachine::state_device_ready()
360361
if (_cb_data.error == NSAPI_ERROR_OK) {
361362
_cb_data.error = _cellularDevice.init();
362363
if (_cb_data.error == NSAPI_ERROR_OK) {
364+
365+
#if MBED_CONF_MBED_TRACE_ENABLE
366+
CellularInformation *info = _cellularDevice.open_information();
367+
368+
char *buf = new (std::nothrow) char[2048]; // size from 3GPP TS 27.007
369+
if (buf) {
370+
if (info->get_manufacturer(buf, 2048) == NSAPI_ERROR_OK) {
371+
tr_info("Modem manufacturer: %s", buf);
372+
}
373+
if (info->get_model(buf, 2048) == NSAPI_ERROR_OK) {
374+
tr_info("Modem model: %s", buf);
375+
}
376+
if (info->get_revision(buf, 2048) == NSAPI_ERROR_OK) {
377+
tr_info("Modem revision: %s", buf);
378+
}
379+
delete[] buf;
380+
}
381+
_cellularDevice.close_information();
382+
#endif // MBED_CONF_MBED_TRACE_ENABLE
383+
363384
if (device_ready()) {
364385
_status = 0;
365386
enter_to_state(STATE_SIM_PIN);
@@ -373,6 +394,7 @@ void CellularStateMachine::state_device_ready()
373394
}
374395
}
375396
}
397+
376398
if (_cb_data.error != NSAPI_ERROR_OK) {
377399
if (_retry_count == 0) {
378400
_cellularDevice.set_ready_cb(callback(this, &CellularStateMachine::device_ready_cb));

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ nsapi_error_t QUECTEL_BG96_CellularInformation::get_iccid(char *buf, size_t buf_
3232
return _at.at_cmd_str("+QCCID", "", buf, buf_size);
3333
}
3434

35+
nsapi_error_t QUECTEL_BG96_CellularInformation::get_revision(char *buf, size_t buf_size)
36+
{
37+
return get_info("AT+QGMR", buf, buf_size);
38+
}
39+
3540
} /* namespace mbed */

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class QUECTEL_BG96_CellularInformation: public AT_CellularInformation {
2828

2929
public: // AT_CellularInformation
3030
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);
31+
virtual nsapi_error_t get_revision(char *buf, size_t buf_size);
3132
};
3233

3334
} /* namespace mbed */

0 commit comments

Comments
 (0)