Skip to content

Cellular : add modem version in mbed trace #12339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions features/cellular/framework/AT/AT_CellularContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) ||
Expand Down
26 changes: 24 additions & 2 deletions features/cellular/framework/device/CellularStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class QUECTEL_BG96_CellularInformation: public AT_CellularInformation {

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 */
Expand Down