Skip to content

Commit e4ee870

Browse files
author
Teppo Järvelin
committed
Cellular: Initialize CellularContext member variables in correct class
CellularContext member variables were initialized in inheriting class. Now in base class where they should be initialized so that every inheriting class don't have to init them.
1 parent 2f1338b commit e4ee870

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

UNITTESTS/stubs/CellularContext_stub.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

2020
namespace mbed {
2121

22+
CellularContext::CellularContext() : _next(0), _stack(0), _pdp_type(DEFAULT_PDP_TYPE),
23+
_authentication_type(CellularContext::CHAP), _connect_status(NSAPI_STATUS_DISCONNECTED), _status_cb(0),
24+
_cid(-1), _new_context_set(false), _is_context_active(false), _is_context_activated(false),
25+
_apn(0), _uname(0), _pwd(0), _dcd_pin(NC), _active_high(false), _cp_netif(0), _retry_array_length(0),
26+
_retry_count(0), _device(0), _nw(0), _is_blocking(true)
27+
{
28+
memset(_retry_timeout_array, 0, CELLULAR_RETRY_ARRAY_SIZE);
29+
}
30+
2231
void CellularContext::cp_data_received()
2332
{
2433
_cp_netif->data_received();

features/cellular/framework/API/CellularContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class CellularContext : public CellularInterface {
122122
protected:
123123
// friend of CellularDevice, so it's the only way to close or delete this class.
124124
friend class CellularDevice;
125+
CellularContext();
125126
virtual ~CellularContext() {}
126127
public: // from NetworkInterface
127128
virtual nsapi_error_t set_blocking(bool blocking) = 0;

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,8 @@ AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, co
5151
_nonip_req(nonip_req), _cp_in_use(false)
5252
{
5353
tr_info("New CellularContext %s (%p)", apn ? apn : "", this);
54-
_stack = NULL;
55-
_pdp_type = DEFAULT_PDP_TYPE;
56-
_authentication_type = CellularContext::CHAP;
57-
_connect_status = NSAPI_STATUS_DISCONNECTED;
58-
_is_context_active = false;
59-
_is_context_activated = false;
6054
_apn = apn;
61-
_uname = NULL;
62-
_pwd = NULL;
63-
_status_cb = NULL;
64-
_cid = -1;
65-
_new_context_set = false;
66-
_next = NULL;
67-
_dcd_pin = NC;
68-
_active_high = false;
69-
_cp_netif = NULL;
70-
memset(_retry_timeout_array, 0, CELLULAR_RETRY_ARRAY_SIZE);
71-
_retry_array_length = 0;
72-
_retry_count = 0;
73-
_is_blocking = true;
7455
_device = device;
75-
_nw = NULL;
7656
}
7757

7858
AT_CellularContext::~AT_CellularContext()

features/cellular/framework/device/CellularContext.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ MBED_WEAK CellularContext *CellularContext::get_default_nonip_instance()
5858
return context;
5959
}
6060

61+
CellularContext::CellularContext() : _next(0), _stack(0), _pdp_type(DEFAULT_PDP_TYPE),
62+
_authentication_type(CellularContext::CHAP), _connect_status(NSAPI_STATUS_DISCONNECTED), _status_cb(0),
63+
_cid(-1), _new_context_set(false), _is_context_active(false), _is_context_activated(false),
64+
_apn(0), _uname(0), _pwd(0), _dcd_pin(NC), _active_high(false), _cp_netif(0), _retry_array_length(0),
65+
_retry_count(0), _device(0), _nw(0), _is_blocking(true)
66+
{
67+
memset(_retry_timeout_array, 0, CELLULAR_RETRY_ARRAY_SIZE);
68+
}
69+
6170
void CellularContext::cp_data_received()
6271
{
6372
_cp_netif->data_received();

0 commit comments

Comments
 (0)