From 5f1ea7d57b39cae97e5b3998fd0f0235e7e0fd8f Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Thu, 30 Jan 2020 16:22:18 +0100 Subject: [PATCH] Cellular : add modem version in mbed trace --- .../framework/AT/AT_CellularContext.cpp | 2 ++ .../framework/device/CellularStateMachine.cpp | 26 +++++++++++++++++-- .../BG96/QUECTEL_BG96_CellularInformation.cpp | 5 ++++ .../BG96/QUECTEL_BG96_CellularInformation.h | 1 + 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/features/cellular/framework/AT/AT_CellularContext.cpp b/features/cellular/framework/AT/AT_CellularContext.cpp index 575094de16..aa10425436 100644 --- a/features/cellular/framework/AT/AT_CellularContext.cpp +++ b/features/cellular/framework/AT/AT_CellularContext.cpp @@ -376,11 +376,13 @@ bool AT_CellularContext::get_context() apn_len = _at.read_string(apn, sizeof(apn)); if (apn_len >= 0) { if (_apn && (strcmp(apn, _apn) != 0)) { + tr_debug("CID %d APN \"%s\"", cid, apn); continue; } // APN matched -> Check PDP type pdp_type_t pdp_type = string_to_pdp_type(pdp_type_from_context); + tr_debug("CID %d APN \"%s\" pdp_type %u", cid, apn, pdp_type); // Accept exact matching PDP context type or dual PDP context for modems that support both IPv4 and IPv6 stacks if (get_device()->get_property(pdp_type_t_to_cellular_property(pdp_type)) || diff --git a/features/cellular/framework/device/CellularStateMachine.cpp b/features/cellular/framework/device/CellularStateMachine.cpp index dded03921b..408b45d19c 100644 --- a/features/cellular/framework/device/CellularStateMachine.cpp +++ b/features/cellular/framework/device/CellularStateMachine.cpp @@ -18,6 +18,7 @@ #include "CellularStateMachine.h" #include "CellularDevice.h" #include "CellularLog.h" +#include "CellularInformation.h" #ifndef MBED_TRACE_MAX_LEVEL #define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO @@ -243,8 +244,8 @@ bool CellularStateMachine::get_network_registration(CellularNetwork::Registratio break; } - if (is_roaming) { - tr_info("Roaming network."); + if (is_registered || is_roaming) { + tr_info("Roaming %u Registered %u", is_roaming, is_registered); } return true; @@ -360,6 +361,26 @@ void CellularStateMachine::state_device_ready() if (_cb_data.error == NSAPI_ERROR_OK) { _cb_data.error = _cellularDevice.init(); if (_cb_data.error == NSAPI_ERROR_OK) { + +#if MBED_CONF_MBED_TRACE_ENABLE + CellularInformation *info = _cellularDevice.open_information(); + + char *buf = new (std::nothrow) char[2048]; // size from 3GPP TS 27.007 + if (buf) { + if (info->get_manufacturer(buf, 2048) == NSAPI_ERROR_OK) { + tr_info("Modem manufacturer: %s", buf); + } + if (info->get_model(buf, 2048) == NSAPI_ERROR_OK) { + tr_info("Modem model: %s", buf); + } + if (info->get_revision(buf, 2048) == NSAPI_ERROR_OK) { + tr_info("Modem revision: %s", buf); + } + delete[] buf; + } + _cellularDevice.close_information(); +#endif // MBED_CONF_MBED_TRACE_ENABLE + if (device_ready()) { _status = 0; enter_to_state(STATE_SIM_PIN); @@ -373,6 +394,7 @@ void CellularStateMachine::state_device_ready() } } } + if (_cb_data.error != NSAPI_ERROR_OK) { if (_retry_count == 0) { _cellularDevice.set_ready_cb(callback(this, &CellularStateMachine::device_ready_cb)); diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.cpp b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.cpp index 4a72d51499..38d101229b 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.cpp +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.cpp @@ -32,4 +32,9 @@ nsapi_error_t QUECTEL_BG96_CellularInformation::get_iccid(char *buf, size_t buf_ return _at.at_cmd_str("+QCCID", "", buf, buf_size); } +nsapi_error_t QUECTEL_BG96_CellularInformation::get_revision(char *buf, size_t buf_size) +{ + return get_info("AT+QGMR", buf, buf_size); +} + } /* namespace mbed */ diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.h b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.h index 3c0c7f20fc..4e445a703e 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.h +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularInformation.h @@ -28,6 +28,7 @@ public: public: // AT_CellularInformation virtual nsapi_error_t get_iccid(char *buf, size_t buf_size); + virtual nsapi_error_t get_revision(char *buf, size_t buf_size); }; } /* namespace mbed */