Skip to content

Commit 0dbf34b

Browse files
authored
Merge pull request ARMmbed#12123 from kivaisan/refactor_variable_visibilities
Cellular: Refactor cellular variable visibilities
2 parents 7090448 + f7cc3db commit 0dbf34b

12 files changed

+58
-71
lines changed

UNITTESTS/stubs/CellularDevice_stub.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0),
4242
_sms_ref_count(0),
4343
#endif //MBED_CONF_CELLULAR_USE_SMS
4444
_info_ref_count(0), _fh(fh), _queue(10 * EVENTS_EVENT_SIZE), _state_machine(0),
45-
_nw(0), _status_cb(0), _property_array(0)
45+
_nw(0), _status_cb(0)
4646
{
4747
}
4848

features/cellular/framework/API/CellularContext.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class CellularContext : public CellularInterface {
161161
*/
162162
static CellularContext *get_default_instance();
163163

164-
165164
/** Instantiates a default Non-IP cellular interface
166165
*
167166
* This function creates a new Non-IP PDP context.

features/cellular/framework/API/CellularDevice.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,7 @@ class CellularDevice {
485485

486486
private: //Common functions
487487
nsapi_error_t start_state_machine(CellularStateMachine::CellularState target_state);
488-
489488
nsapi_error_t create_state_machine();
490-
491489
void stm_callback(nsapi_event_t ev, intptr_t ptr);
492490

493491
protected: //Member variables
@@ -499,15 +497,13 @@ class CellularDevice {
499497
FileHandle *_fh;
500498
events::EventQueue _queue;
501499
CellularStateMachine *_state_machine;
500+
Callback<void(nsapi_event_t, intptr_t)> _status_cb;
502501

503502
private: //Member variables
504503
CellularNetwork *_nw;
505504
char _sim_pin[MAX_PIN_SIZE + 1];
506505
char _plmn[MAX_PLMN_SIZE + 1];
507506
PlatformMutex _mutex;
508-
Callback<void(nsapi_event_t, intptr_t)> _status_cb;
509-
510-
const intptr_t *_property_array;
511507
};
512508

513509
/**

features/cellular/framework/API/CellularSMS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class CellularSMS {
5656
* virtual Destructor
5757
*/
5858
virtual ~CellularSMS() {};
59-
public:
6059

60+
public:
6161
/* Enumeration for possible SMS modes, PDU and Text */
6262
enum CellularSMSMmode {
6363
CellularSMSMmodePDU = 0,

features/cellular/framework/AT/AT_CellularContext.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class AT_CellularContext : public CellularContext {
7373
AT_CellularDevice *get_device() const;
7474

7575
ATHandler &get_at_handler();
76+
7677
protected:
7778
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr);
7879

@@ -107,6 +108,7 @@ class AT_CellularContext : public CellularContext {
107108
virtual bool get_context();
108109
AT_CellularDevice::CellularProperty pdp_type_t_to_cellular_property(pdp_type_t pdp_type);
109110
bool set_new_context(int cid);
111+
110112
private:
111113
#if NSAPI_PPP_AVAILABLE
112114
nsapi_error_t open_data_channel();
@@ -124,6 +126,7 @@ class AT_CellularContext : public CellularContext {
124126
virtual void do_connect_with_retry();
125127
void do_disconnect();
126128
void set_cid(int cid);
129+
127130
private:
128131
ContextOperation _current_op;
129132
FileHandle *_fh;
@@ -135,8 +138,6 @@ class AT_CellularContext : public CellularContext {
135138
// flag indicating if CP was requested to be setup
136139
bool _cp_req;
137140
bool _is_connected;
138-
139-
protected:
140141
ATHandler &_at;
141142
};
142143

features/cellular/framework/AT/AT_CellularDevice.h

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,30 @@ class AT_CellularDevice : public CellularDevice {
124124
*/
125125
virtual nsapi_error_t release_at_handler(ATHandler *at_handler);
126126

127+
virtual CellularContext *get_context_list() const;
128+
129+
virtual nsapi_error_t set_baud_rate(int baud_rate);
130+
131+
#if MBED_CONF_CELLULAR_USE_SMS
132+
virtual CellularSMS *open_sms(FileHandle *fh = NULL);
133+
134+
virtual void close_sms();
135+
#endif
136+
137+
/** Get value for the given key.
138+
*
139+
* @param key key for value to be fetched
140+
* @return property value for the given key. Value type is defined in enum CellularProperty
141+
*/
142+
intptr_t get_property(CellularProperty key);
143+
144+
/** Cellular module need to define an array of cellular properties which defines module supported property values.
145+
*
146+
* @param property_array array of module properties
147+
*/
148+
void set_cellular_properties(const intptr_t *property_array);
149+
150+
protected:
127151
/** Creates new instance of AT_CellularContext or if overridden, modem specific implementation.
128152
*
129153
* @param at ATHandler reference for communication with the modem.
@@ -149,50 +173,15 @@ class AT_CellularDevice : public CellularDevice {
149173
*/
150174
virtual AT_CellularInformation *open_information_impl(ATHandler &at);
151175

152-
virtual CellularContext *get_context_list() const;
153-
154-
virtual nsapi_error_t set_baud_rate(int baud_rate);
155-
156176
#if MBED_CONF_CELLULAR_USE_SMS
157-
virtual CellularSMS *open_sms(FileHandle *fh = NULL);
158-
159-
virtual void close_sms();
160-
161177
/** Create new instance of AT_CellularSMS or if overridden, modem specific implementation.
162178
*
163179
* @param at ATHandler reference for communication with the modem.
164180
* @return new instance of class AT_CellularSMS
165181
*/
166182
virtual AT_CellularSMS *open_sms_impl(ATHandler &at);
167-
168-
AT_CellularSMS *_sms;
169-
170183
#endif // MBED_CONF_CELLULAR_USE_SMS
171184

172-
public:
173-
/** Get value for the given key.
174-
*
175-
* @param key key for value to be fetched
176-
* @return property value for the given key. Value type is defined in enum CellularProperty
177-
*/
178-
intptr_t get_property(CellularProperty key);
179-
180-
/** Cellular module need to define an array of cellular properties which defines module supported property values.
181-
*
182-
* @param property_array array of module properties
183-
*/
184-
void set_cellular_properties(const intptr_t *property_array);
185-
186-
public: //Member variables
187-
AT_CellularNetwork *_network;
188-
189-
AT_CellularInformation *_information;
190-
AT_CellularContext *_context_list;
191-
int _default_timeout;
192-
bool _modem_debug_on;
193-
ATHandler *_at;
194-
195-
protected:
196185
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx = NULL);
197186
void send_disconnect_to_context(int cid);
198187
// Sets commonly used URCs
@@ -208,7 +197,20 @@ class AT_CellularDevice : public CellularDevice {
208197
void urc_nw_deact();
209198
void urc_pdn_deact();
210199

200+
protected:
201+
ATHandler *_at;
202+
211203
private:
204+
#if MBED_CONF_CELLULAR_USE_SMS
205+
AT_CellularSMS *_sms;
206+
#endif // MBED_CONF_CELLULAR_USE_SMS
207+
208+
AT_CellularNetwork *_network;
209+
AT_CellularInformation *_information;
210+
AT_CellularContext *_context_list;
211+
212+
int _default_timeout;
213+
bool _modem_debug_on;
212214
const intptr_t *_property_array;
213215
};
214216

features/cellular/framework/AT/AT_CellularInformation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class AT_CellularInformation : public CellularInformation {
4949
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);
5050

5151
ATHandler &get_at_handler();
52+
5253
protected:
5354
/** Request information text from cellular device
5455
*
@@ -61,7 +62,6 @@ class AT_CellularInformation : public CellularInformation {
6162

6263
protected:
6364
ATHandler &_at;
64-
6565
AT_CellularDevice &_device;
6666
};
6767

features/cellular/framework/AT/AT_CellularNetwork.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ namespace mbed {
3636
* Class for attaching to a network and getting information from it.
3737
*/
3838
class AT_CellularNetwork : public CellularNetwork {
39-
4039
public:
4140

4241
AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
@@ -101,7 +100,6 @@ class AT_CellularNetwork : public CellularNetwork {
101100
ATHandler &get_at_handler();
102101

103102
protected:
104-
105103
/** Sets access technology to be scanned. Modem specific implementation.
106104
*
107105
* @param op_rat Access technology
@@ -140,7 +138,6 @@ class AT_CellularNetwork : public CellularNetwork {
140138
void call_network_cb(nsapi_connection_status_t status);
141139

142140
protected:
143-
144141
Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
145142
Callback<void(CIoT_Supported_Opt)> _ciotopt_network_support_cb;
146143
RadioAccessTechnology _op_act;
@@ -150,9 +147,7 @@ class AT_CellularNetwork : public CellularNetwork {
150147
registration_params_t _reg_params;
151148
mbed::Callback<void()> _urc_funcs[C_MAX];
152149

153-
protected:
154150
ATHandler &_at;
155-
156151
AT_CellularDevice &_device;
157152
};
158153

features/cellular/framework/AT/AT_CellularSMS.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class AT_CellularSMS: public CellularSMS {
6666
ATHandler &get_at_handler();
6767

6868
private:
69-
7069
struct sms_info_t {
7170
char date[SMS_MAX_TIME_STAMP_SIZE];
7271
uint16_t msg_index[50]; // can hold up to 50 concatenated msg parts, indexes are in correct order. So max sms size is 50*140 = 7kb
@@ -78,14 +77,6 @@ class AT_CellularSMS: public CellularSMS {
7877
sms_info_t() : msg_size(0), parts(1), parts_added(1), msg_ref_number(0), next_info(0) {};
7978
};
8079

81-
// application callback function for received sms
82-
Callback<void()> _cb;
83-
CellularSMSMmode _mode;
84-
bool _use_8bit_encoding;
85-
uint32_t _sim_wait_time;
86-
uint16_t _sms_message_ref_number;
87-
sms_info_t *_sms_info;
88-
8980
// SMS urc's
9081
void cmt_urc();
9182
void cmti_urc();
@@ -171,8 +162,15 @@ class AT_CellularSMS: public CellularSMS {
171162
int msg_len);
172163

173164
private:
174-
ATHandler &_at;
165+
// application callback function for received sms
166+
Callback<void()> _cb;
167+
CellularSMSMmode _mode;
168+
bool _use_8bit_encoding;
169+
uint32_t _sim_wait_time;
170+
uint16_t _sms_message_ref_number;
171+
sms_info_t *_sms_info;
175172

173+
ATHandler &_at;
176174
AT_CellularDevice &_device;
177175
};
178176

features/cellular/framework/AT/AT_CellularStack.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class AT_CellularStack : public NetworkStack {
9999
virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data);
100100

101101
protected:
102-
103102
class CellularSocket {
104103
public:
105104
CellularSocket() :
@@ -188,6 +187,7 @@ class AT_CellularStack : public NetworkStack {
188187
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
189188
void *buffer, nsapi_size_t size) = 0;
190189

190+
protected:
191191
/**
192192
* Find the socket handle based on the index of the socket construct
193193
* in the socket container. Please note that this index may or may not be
@@ -211,6 +211,10 @@ class AT_CellularStack : public NetworkStack {
211211
*/
212212
bool is_addr_stack_compatible(const SocketAddress &addr);
213213

214+
private:
215+
int get_socket_index_by_port(uint16_t port);
216+
217+
protected:
214218
// socket container
215219
CellularSocket **_socket;
216220

@@ -229,16 +233,10 @@ class AT_CellularStack : public NetworkStack {
229233
// IP version of send to address
230234
nsapi_version_t _ip_ver_sendto;
231235

232-
private:
233-
234-
int get_socket_index_by_port(uint16_t port);
235-
236-
protected:
237236
// mutex for write/read to a _socket array, needed when multiple threads may use sockets simultaneously
238237
PlatformMutex _socket_mutex;
239238

240239
ATHandler &_at;
241-
242240
AT_CellularDevice &_device;
243241
};
244242

features/cellular/framework/AT/AT_ControlPlane_netif.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ class AT_ControlPlane_netif: public ControlPlane_netif {
99
virtual ~AT_ControlPlane_netif();
1010

1111
protected:
12-
1312
// ControlPlane_netif
1413

1514
/* Sends data using +CSODCP specified in
1615
* 3GPP 27007 10.1.43: Sending of originating data via the control plane
1716
*/
1817
virtual nsapi_size_or_error_t send(const void *cpdata, nsapi_size_t cpdata_length);
1918

20-
2119
/* Receives data using +CRTDCP specified in
2220
* 3GPP 27007 10.1.44: Reporting of terminating data via the control plane
2321
*/

features/cellular/framework/device/CellularDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0),
3838
_sms_ref_count(0),
3939
#endif //MBED_CONF_CELLULAR_USE_SMS
4040
_info_ref_count(0), _fh(fh), _queue(10 * EVENTS_EVENT_SIZE), _state_machine(0),
41-
_nw(0), _status_cb(0), _property_array(0)
41+
_status_cb(0), _nw(0)
4242
{
4343
MBED_ASSERT(fh);
4444
set_sim_pin(NULL);

0 commit comments

Comments
 (0)