Merge pull request #12339 from jeromecoutant/PR_MODEMVERSION

Cellular : add modem version in mbed trace
pull/12431/head
Martin Kojtal 2020-02-13 13:04:30 +00:00 committed by GitHub
commit d7f3341974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 2 deletions

View File

@ -367,11 +367,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)) ||

View File

@ -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));

View File

@ -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 */

View File

@ -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 */