Skip to content

Commit 164e8fb

Browse files
author
Ari Parkkila
committed
Added modem_debug_on to cellular device
1 parent a95d376 commit 164e8fb

File tree

5 files changed

+56
-15
lines changed

5 files changed

+56
-15
lines changed

features/cellular/easy_cellular/EasyCellularConnection.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#include "APN_db.h"
3333
#endif //MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
3434

35-
namespace mbed {
35+
namespace mbed
36+
{
3637

3738
bool EasyCellularConnection::cellular_status(int state, int next_state)
3839
{
@@ -45,17 +46,16 @@ bool EasyCellularConnection::cellular_status(int state, int next_state)
4546
}
4647
MBED_ASSERT(_cellularSemaphore.release() == osOK);
4748
return false;
48-
}
49-
else {
49+
} else {
5050
_is_connected = false;
5151
}
5252
return true;
5353
}
5454

5555
EasyCellularConnection::EasyCellularConnection() : _is_connected(false), _is_initialized(false),
56-
_target_state(CellularConnectionUtil::STATE_POWER_ON),
57-
_cellularSerial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE),
58-
_cellularSemaphore(0), _cellularConnectionUtil(), _credentials_err(NSAPI_ERROR_OK)
56+
_target_state(CellularConnectionUtil::STATE_POWER_ON),
57+
_cellularSerial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE),
58+
_cellularSemaphore(0), _cellularConnectionUtil(), _credentials_err(NSAPI_ERROR_OK)
5959
{
6060
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
6161
_credentials_set = false;
@@ -78,7 +78,7 @@ nsapi_error_t EasyCellularConnection::init()
7878
_cellularConnectionUtil.set_serial(&_cellularSerial);
7979
_cellularConnectionUtil.set_callback(callback(this, &EasyCellularConnection::cellular_status));
8080

81-
err = _cellularConnectionUtil.init();
81+
err = _cellularConnectionUtil.init();
8282

8383
if (err == NSAPI_ERROR_OK) {
8484
err = _cellularConnectionUtil.start_dispatch();
@@ -259,6 +259,14 @@ void EasyCellularConnection::attach(mbed::Callback<void(nsapi_event_t, intptr_t)
259259
}
260260
}
261261

262+
void EasyCellularConnection::modem_debug_on(bool on)
263+
{
264+
CellularDevice *dev =_cellularConnectionUtil.get_device();
265+
if (dev) {
266+
dev->modem_debug_on(on);
267+
}
268+
}
269+
262270
NetworkStack *EasyCellularConnection::get_stack()
263271
{
264272
return _cellularConnectionUtil.get_stack();

features/cellular/easy_cellular/EasyCellularConnection.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323

2424
#include "netsocket/CellularBase.h"
2525

26-
namespace mbed {
26+
namespace mbed
27+
{
2728

2829
/** EasyCellularConnection class
2930
*
3031
* Simplified adapter for cellular connection
3132
*/
32-
class EasyCellularConnection: public CellularBase {
33+
class EasyCellularConnection: public CellularBase
34+
{
3335

3436
public:
3537
EasyCellularConnection();
@@ -117,6 +119,12 @@ class EasyCellularConnection: public CellularBase {
117119
*/
118120
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
119121

122+
/** Turn modem debug traces on
123+
*
124+
* @param on set true to enable debug traces
125+
*/
126+
void modem_debug_on(bool on);
127+
120128
protected:
121129

122130
/** Provide access to the NetworkStack object

features/cellular/framework/API/CellularDevice.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
#include "CellularInformation.h"
2929
#include "NetworkStack.h"
3030

31-
namespace mbed {
31+
namespace mbed
32+
{
3233

3334
/**
3435
* Class CellularDevice
@@ -115,7 +116,13 @@ class CellularDevice
115116
* @param timeout milliseconds to wait response from modem
116117
*/
117118
virtual void set_timeout(int timeout) = 0;
118-
119+
120+
/** Turn modem debug traces on
121+
*
122+
* @param on set true to enable debug traces
123+
*/
124+
virtual void modem_debug_on(bool on) = 0;
125+
119126
/** Get network stack.
120127
*
121128
* @return network stack

features/cellular/framework/AT/AT_CellularDevice.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ using namespace mbed;
2323
#define DEFAULT_AT_TIMEOUT 1000 // at default timeout in milliseconds
2424

2525
AT_CellularDevice::AT_CellularDevice(EventQueue &queue) :
26-
_atHandlers(0), _network(0), _sms(0), _sim(0), _power(0), _multiplexer(0), _information(0), _queue(queue), _default_timeout(DEFAULT_AT_TIMEOUT)
26+
_atHandlers(0), _network(0), _sms(0), _sim(0), _power(0), _multiplexer(0), _information(0), _queue(queue),
27+
_default_timeout(DEFAULT_AT_TIMEOUT), _modem_debug_on(false)
2728
{
2829
}
2930

@@ -62,6 +63,9 @@ ATHandler* AT_CellularDevice::get_at_handler(FileHandle *fileHandle)
6263

6364
atHandler = new ATHandler(fileHandle, _queue, _default_timeout, "\r");
6465
if (atHandler) {
66+
if (_modem_debug_on) {
67+
atHandler->enable_debug(_modem_debug_on);
68+
}
6569
atHandler->_nextATHandler = _atHandlers;
6670
_atHandlers = atHandler;
6771
}
@@ -83,8 +87,7 @@ void AT_CellularDevice::release_at_handler(ATHandler* at_handler)
8387
if (atHandler == at_handler) {
8488
if (prev == NULL) {
8589
_atHandlers = _atHandlers->_nextATHandler;
86-
}
87-
else {
90+
} else {
8891
prev->_nextATHandler = atHandler->_nextATHandler;
8992
}
9093
delete atHandler;
@@ -247,6 +250,17 @@ void AT_CellularDevice::set_timeout(int timeout)
247250
}
248251
}
249252

253+
void AT_CellularDevice::modem_debug_on(bool on)
254+
{
255+
_modem_debug_on = on;
256+
257+
ATHandler *atHandler = _atHandlers;
258+
while (atHandler) {
259+
atHandler->enable_debug(_modem_debug_on);
260+
atHandler = atHandler->_nextATHandler;
261+
}
262+
}
263+
250264
NetworkStack *AT_CellularDevice::get_stack()
251265
{
252266
if (!_network) {

features/cellular/framework/AT/AT_CellularDevice.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
#include "ATHandler.h"
3131

32-
namespace mbed {
32+
namespace mbed
33+
{
3334

3435
/**
3536
* Class AT_CellularDevice
@@ -81,6 +82,8 @@ class AT_CellularDevice : public CellularDevice
8182

8283
virtual void set_timeout(int timeout);
8384

85+
virtual void modem_debug_on(bool on);
86+
8487
virtual NetworkStack *get_stack();
8588

8689
protected:
@@ -94,6 +97,7 @@ class AT_CellularDevice : public CellularDevice
9497
protected:
9598
events::EventQueue &_queue;
9699
int _default_timeout;
100+
bool _modem_debug_on;
97101
};
98102

99103
} // namespace mbed

0 commit comments

Comments
 (0)