diff --git a/features/cellular/easy_cellular/EasyCellularConnection.cpp b/features/cellular/easy_cellular/EasyCellularConnection.cpp index 074a3b7b88..ec08c995c8 100644 --- a/features/cellular/easy_cellular/EasyCellularConnection.cpp +++ b/features/cellular/easy_cellular/EasyCellularConnection.cpp @@ -32,7 +32,8 @@ #include "APN_db.h" #endif //MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP -namespace mbed { +namespace mbed +{ bool EasyCellularConnection::cellular_status(int state, int next_state) { @@ -45,17 +46,16 @@ bool EasyCellularConnection::cellular_status(int state, int next_state) } MBED_ASSERT(_cellularSemaphore.release() == osOK); return false; - } - else { + } else { _is_connected = false; } return true; } EasyCellularConnection::EasyCellularConnection() : _is_connected(false), _is_initialized(false), - _target_state(CellularConnectionUtil::STATE_POWER_ON), - _cellularSerial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE), - _cellularSemaphore(0), _cellularConnectionUtil(), _credentials_err(NSAPI_ERROR_OK) + _target_state(CellularConnectionUtil::STATE_POWER_ON), + _cellularSerial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE), + _cellularSemaphore(0), _cellularConnectionUtil(), _credentials_err(NSAPI_ERROR_OK) { #if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP _credentials_set = false; @@ -78,7 +78,7 @@ nsapi_error_t EasyCellularConnection::init() _cellularConnectionUtil.set_serial(&_cellularSerial); _cellularConnectionUtil.set_callback(callback(this, &EasyCellularConnection::cellular_status)); - err = _cellularConnectionUtil.init(); + err = _cellularConnectionUtil.init(); if (err == NSAPI_ERROR_OK) { err = _cellularConnectionUtil.start_dispatch(); @@ -259,6 +259,14 @@ void EasyCellularConnection::attach(mbed::Callbackmodem_debug_on(on); + } +} + NetworkStack *EasyCellularConnection::get_stack() { return _cellularConnectionUtil.get_stack(); diff --git a/features/cellular/easy_cellular/EasyCellularConnection.h b/features/cellular/easy_cellular/EasyCellularConnection.h index a4c3bc62b2..02de2c7320 100644 --- a/features/cellular/easy_cellular/EasyCellularConnection.h +++ b/features/cellular/easy_cellular/EasyCellularConnection.h @@ -23,13 +23,15 @@ #include "netsocket/CellularBase.h" -namespace mbed { +namespace mbed +{ /** EasyCellularConnection class * * Simplified adapter for cellular connection */ -class EasyCellularConnection: public CellularBase { +class EasyCellularConnection: public CellularBase +{ public: EasyCellularConnection(); @@ -117,6 +119,12 @@ public: */ virtual void attach(mbed::Callback status_cb); + /** Turn modem debug traces on + * + * @param on set true to enable debug traces + */ + void modem_debug_on(bool on); + protected: /** Provide access to the NetworkStack object diff --git a/features/cellular/framework/API/CellularDevice.h b/features/cellular/framework/API/CellularDevice.h index b919fb5bd4..5ef45eb4b4 100644 --- a/features/cellular/framework/API/CellularDevice.h +++ b/features/cellular/framework/API/CellularDevice.h @@ -28,7 +28,8 @@ #include "CellularInformation.h" #include "NetworkStack.h" -namespace mbed { +namespace mbed +{ /** * Class CellularDevice @@ -115,7 +116,13 @@ public: * @param timeout milliseconds to wait response from modem */ virtual void set_timeout(int timeout) = 0; - + + /** Turn modem debug traces on + * + * @param on set true to enable debug traces + */ + virtual void modem_debug_on(bool on) = 0; + /** Get network stack. * * @return network stack diff --git a/features/cellular/framework/AT/AT_CellularDevice.cpp b/features/cellular/framework/AT/AT_CellularDevice.cpp index dff3d072f1..c85e7f6835 100644 --- a/features/cellular/framework/AT/AT_CellularDevice.cpp +++ b/features/cellular/framework/AT/AT_CellularDevice.cpp @@ -23,7 +23,8 @@ using namespace mbed; #define DEFAULT_AT_TIMEOUT 1000 // at default timeout in milliseconds AT_CellularDevice::AT_CellularDevice(EventQueue &queue) : - _atHandlers(0), _network(0), _sms(0), _sim(0), _power(0), _multiplexer(0), _information(0), _queue(queue), _default_timeout(DEFAULT_AT_TIMEOUT) + _atHandlers(0), _network(0), _sms(0), _sim(0), _power(0), _multiplexer(0), _information(0), _queue(queue), + _default_timeout(DEFAULT_AT_TIMEOUT), _modem_debug_on(false) { } @@ -62,6 +63,9 @@ ATHandler* AT_CellularDevice::get_at_handler(FileHandle *fileHandle) atHandler = new ATHandler(fileHandle, _queue, _default_timeout, "\r"); if (atHandler) { + if (_modem_debug_on) { + atHandler->enable_debug(_modem_debug_on); + } atHandler->_nextATHandler = _atHandlers; _atHandlers = atHandler; } @@ -83,8 +87,7 @@ void AT_CellularDevice::release_at_handler(ATHandler* at_handler) if (atHandler == at_handler) { if (prev == NULL) { _atHandlers = _atHandlers->_nextATHandler; - } - else { + } else { prev->_nextATHandler = atHandler->_nextATHandler; } delete atHandler; @@ -247,6 +250,17 @@ void AT_CellularDevice::set_timeout(int timeout) } } +void AT_CellularDevice::modem_debug_on(bool on) +{ + _modem_debug_on = on; + + ATHandler *atHandler = _atHandlers; + while (atHandler) { + atHandler->enable_debug(_modem_debug_on); + atHandler = atHandler->_nextATHandler; + } +} + NetworkStack *AT_CellularDevice::get_stack() { if (!_network) { diff --git a/features/cellular/framework/AT/AT_CellularDevice.h b/features/cellular/framework/AT/AT_CellularDevice.h index a231ca773b..578c0b2393 100644 --- a/features/cellular/framework/AT/AT_CellularDevice.h +++ b/features/cellular/framework/AT/AT_CellularDevice.h @@ -29,7 +29,8 @@ #include "ATHandler.h" -namespace mbed { +namespace mbed +{ /** * Class AT_CellularDevice @@ -81,6 +82,8 @@ public: // CellularDevice virtual void set_timeout(int timeout); + virtual void modem_debug_on(bool on); + virtual NetworkStack *get_stack(); protected: @@ -94,6 +97,7 @@ protected: protected: events::EventQueue &_queue; int _default_timeout; + bool _modem_debug_on; }; } // namespace mbed