Skip to content

Commit 88213d3

Browse files
Teppo JärvelinTeppo Järvelin
authored andcommitted
Cellular: astyle fixes after introducing CellularContext class and major refactor.
1 parent 14f3740 commit 88213d3

File tree

6 files changed

+43
-42
lines changed

6 files changed

+43
-42
lines changed

features/cellular/framework/API/CellularContext.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class CellularContext : public CellularBase {
9696
typedef CellularList<pdpcontext_params_t> pdpContextList_t;
9797

9898
// pointer for next item when used as a linked list
99-
CellularContext* _next;
99+
CellularContext *_next;
100100
protected:
101101
// friend of CellularDevice so that it's the only way to close/delete this class.
102102
friend class CellularDevice;
@@ -217,17 +217,17 @@ class CellularContext : public CellularBase {
217217
OP_DEVICE_READY = 0,
218218
OP_SIM_READY = 1,
219219
OP_REGISTER = 2,
220-
OP_ATTACH = 3 ,
220+
OP_ATTACH = 3,
221221
OP_CONNECT = 4,
222222
OP_MAX = 5
223223
};
224224

225-
/** Status callback function will be called on status changes on the network or CellularDevice
226-
* by the CellularDevice.
227-
*
228-
* @param ev event type
229-
* @param ptr event-type dependent reason parameter
230-
*/
225+
/** Status callback function will be called on status changes on the network or CellularDevice
226+
* by the CellularDevice.
227+
*
228+
* @param ev event type
229+
* @param ptr event-type dependent reason parameter
230+
*/
231231
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr) = 0;
232232

233233
// member variables needed in target override methods

features/cellular/framework/API/CellularDevice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CellularDevice {
9999
*
100100
* @param plmn plmn used when registering to cellular network
101101
*/
102-
void set_plmn(const char* plmn);
102+
void set_plmn(const char *plmn);
103103

104104
/** Start the interface
105105
*
@@ -260,7 +260,7 @@ class CellularDevice {
260260

261261
CellularNetwork *_nw;
262262
char _sim_pin[MAX_PIN_SIZE + 1];
263-
char _plmn[MAX_PLMN_SIZE +1];
263+
char _plmn[MAX_PLMN_SIZE + 1];
264264
PlatformMutex _mutex;
265265
};
266266

features/cellular/framework/common/CellularCommon.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
#include "nsapi_types.h"
2323

2424
struct cell_callback_data_t {
25-
nsapi_error_t error; /* possible error code */
26-
int status_data; /* cellular_event_status related enum or other info in int format. Check cellular_event_status comments.*/
27-
bool final_try; /* This flag is true if state machine is used and this was the last try. State machine does goes to idle. */
25+
nsapi_error_t error; /* possible error code */
26+
int status_data; /* cellular_event_status related enum or other info in int format. Check cellular_event_status comments.*/
27+
bool final_try; /* This flag is true if state machine is used and this was the last try. State machine does goes to idle. */
2828

29-
cell_callback_data_t() {
30-
error = NSAPI_ERROR_OK;
31-
status_data = -1;
32-
final_try = false;
33-
}
34-
};
29+
cell_callback_data_t()
30+
{
31+
error = NSAPI_ERROR_OK;
32+
status_data = -1;
33+
final_try = false;
34+
}
35+
};
3536

3637
/**
3738
* Cellular specific event changes.

features/cellular/framework/device/CellularDevice.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ MBED_WEAK CellularDevice *CellularDevice::get_default_instance()
3636
static UARTSerial serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
3737
#if DEVICE_SERIAL_FC
3838
if (MDMRTS != NC && MDMCTS != NC) {
39-
tr_info("_USING flow control, MDMRTS: %d MDMCTS: %d",MDMRTS, MDMCTS);
39+
tr_info("_USING flow control, MDMRTS: %d MDMCTS: %d", MDMRTS, MDMCTS);
4040
serial.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS);
4141
}
4242
#endif
@@ -50,8 +50,8 @@ MBED_WEAK CellularDevice *CellularDevice::get_default_instance()
5050
}
5151
#endif // CELLULAR_DEVICE
5252

53-
CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0), _sms_ref_count(0),_power_ref_count(0), _sim_ref_count(0),
54-
_info_ref_count(0), _fh(fh), _queue(5 * EVENTS_EVENT_SIZE), _state_machine(0), _nw(0)
53+
CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0), _sms_ref_count(0), _power_ref_count(0), _sim_ref_count(0),
54+
_info_ref_count(0), _fh(fh), _queue(5 * EVENTS_EVENT_SIZE), _state_machine(0), _nw(0)
5555
{
5656
set_sim_pin(NULL);
5757
set_plmn(NULL);
@@ -87,7 +87,7 @@ void CellularDevice::set_sim_pin(const char *sim_pin)
8787
}
8888
}
8989

90-
void CellularDevice::set_plmn(const char* plmn)
90+
void CellularDevice::set_plmn(const char *plmn)
9191
{
9292
if (plmn) {
9393
strncpy(_plmn, plmn, sizeof(_plmn));
@@ -156,7 +156,7 @@ nsapi_error_t CellularDevice::start_state_machine(CellularStateMachine::Cellular
156156
void CellularDevice::cellular_callback(nsapi_event_t ev, intptr_t ptr)
157157
{
158158
if (ev >= NSAPI_EVENT_CELLULAR_STATUS_BASE && ev <= NSAPI_EVENT_CELLULAR_STATUS_END) {
159-
cell_callback_data_t* ptr_data = (cell_callback_data_t*)ptr;
159+
cell_callback_data_t *ptr_data = (cell_callback_data_t *)ptr;
160160
tr_debug("Device: network_callback called with event: %d, err: %d, data: %d", ev, ptr_data->error, ptr_data->status_data);
161161
cellular_connection_status_t cell_ev = (cellular_connection_status_t)ev;
162162
if (cell_ev == CellularRegistrationStatusChanged && _state_machine) {
@@ -174,7 +174,7 @@ void CellularDevice::cellular_callback(nsapi_event_t ev, intptr_t ptr)
174174
_state_machine->set_plmn(_plmn);
175175
}
176176
} else if (cell_ev == CellularSIMStatusChanged && ptr_data->error == NSAPI_ERROR_OK &&
177-
ptr_data->status_data == CellularSIM::SimStatePinNeeded) {
177+
ptr_data->status_data == CellularSIM::SimStatePinNeeded) {
178178
if (strlen(_sim_pin)) {
179179
_state_machine->set_sim_pin(_sim_pin);
180180
}

features/cellular/framework/device/CellularStateMachine.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ const int STM_STOPPED = -99;
4444
namespace mbed {
4545

4646
CellularStateMachine::CellularStateMachine(CellularDevice &device, events::EventQueue &queue) :
47-
_cellularDevice(device), _state(STATE_INIT), _next_state(_state), _target_state(_state),
48-
_event_status_cb(0), _network(0), _power(0), _sim(0), _queue(queue), _queue_thread(0), _sim_pin(0),
49-
_retry_count(0), _event_timeout(-1), _event_id(-1), _plmn(0), _command_success(false),
50-
_plmn_network_found(false), _is_retry(false), _cb_data(), _current_event(NSAPI_EVENT_CONNECTION_STATUS_CHANGE),
51-
_active_context(false)
47+
_cellularDevice(device), _state(STATE_INIT), _next_state(_state), _target_state(_state),
48+
_event_status_cb(0), _network(0), _power(0), _sim(0), _queue(queue), _queue_thread(0), _sim_pin(0),
49+
_retry_count(0), _event_timeout(-1), _event_id(-1), _plmn(0), _command_success(false),
50+
_plmn_network_found(false), _is_retry(false), _cb_data(), _current_event(NSAPI_EVENT_CONNECTION_STATUS_CHANGE),
51+
_active_context(false)
5252
{
5353
#if MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY == 0
5454
_start_time = 0;
@@ -157,7 +157,7 @@ bool CellularStateMachine::open_sim()
157157
// report current state so callback can set sim pin if needed
158158
if (_event_status_cb) {
159159
_cb_data.status_data = state;
160-
_event_status_cb((nsapi_event_t)CellularSIMStatusChanged, (intptr_t )&_cb_data);
160+
_event_status_cb((nsapi_event_t)CellularSIMStatusChanged, (intptr_t)&_cb_data);
161161
}
162162

163163
if (state == CellularSIM::SimStatePinNeeded) {
@@ -197,7 +197,7 @@ bool CellularStateMachine::is_registered()
197197
}
198198

199199
bool CellularStateMachine::get_network_registration(CellularNetwork::RegistrationType type,
200-
CellularNetwork::RegistrationStatus &status, bool &is_registered)
200+
CellularNetwork::RegistrationStatus &status, bool &is_registered)
201201
{
202202
is_registered = false;
203203
bool is_roaming = false;
@@ -255,7 +255,7 @@ void CellularStateMachine::report_failure(const char *msg)
255255
_event_id = -1;
256256
if (_event_status_cb) {
257257
_cb_data.final_try = true;
258-
_event_status_cb(_current_event, (intptr_t )&_cb_data);
258+
_event_status_cb(_current_event, (intptr_t)&_cb_data);
259259
}
260260

261261
tr_error("Target state %s was not reached. Returning from state: %s", get_state_string(_target_state), get_state_string(_state));
@@ -379,7 +379,7 @@ bool CellularStateMachine::device_ready()
379379
return false;
380380
}
381381
if (_event_status_cb) {
382-
_event_status_cb((nsapi_event_t)CellularDeviceReady, (intptr_t )&_cb_data);
382+
_event_status_cb((nsapi_event_t)CellularDeviceReady, (intptr_t)&_cb_data);
383383
}
384384
_power->remove_device_ready_urc_cb(mbed::callback(this, &CellularStateMachine::ready_urc_cb));
385385
_cellularDevice.close_power();
@@ -493,7 +493,7 @@ void CellularStateMachine::state_attaching()
493493
_sim = NULL;
494494
if (_event_status_cb) {
495495
_cb_data.status_data = CellularNetwork::Attached;
496-
_event_status_cb(_current_event, (intptr_t )&_cb_data);
496+
_event_status_cb(_current_event, (intptr_t)&_cb_data);
497497
}
498498
} else {
499499
retry_state_or_fail();
@@ -527,29 +527,29 @@ nsapi_error_t CellularStateMachine::run_to_state(CellularStateMachine::CellularS
527527
_mutex.unlock();
528528
return NSAPI_ERROR_NO_MEMORY;
529529
}
530-
_mutex.unlock();
530+
_mutex.unlock();
531531
return NSAPI_ERROR_OK;
532532
}
533533

534534
void CellularStateMachine::pre_event(CellularState state)
535535
{
536536
tr_debug("CellularStateMachine::pre_event, state: %s, _target_state: %s, _event_id: %d", get_state_string(state), get_state_string(_target_state), _event_id);
537-
if (_target_state < state) {
537+
if (_target_state < state) {
538538
// new wanted state will not be achieved with current _target_state so update it
539539
_target_state = state;
540540
} else {
541541
// wanted state is already / will be achieved, return without launching new event
542542
return;
543543
}
544-
// if _event_id is -1 it means that new event is not going to be launched so we must launch new event
544+
// if _event_id is -1 it means that new event is not going to be launched so we must launch new event
545545
if (_event_id == -1) {
546546
if (!_cb_data.final_try) {
547547
// update next state so that we don't continue from previous state if state machine was paused and then started again.
548548
// but only if earlier try did not finish to failure, then we must continue from that state
549549
_state = _next_state;
550550
}
551-
enter_to_state(_next_state);
552-
_event_id = _queue.call_in(0, this, &CellularStateMachine::event);
551+
enter_to_state(_next_state);
552+
_event_id = _queue.call_in(0, this, &CellularStateMachine::event);
553553
if (!_event_id) {
554554
_event_id = -1;
555555
report_failure("Failed to call queue.");
@@ -655,7 +655,7 @@ void CellularStateMachine::set_cellular_callback(mbed::Callback<void(nsapi_event
655655

656656
void CellularStateMachine::cellular_event_changed(nsapi_event_t ev, intptr_t ptr)
657657
{
658-
cell_callback_data_t *data = (cell_callback_data_t*)ptr;
658+
cell_callback_data_t *data = (cell_callback_data_t *)ptr;
659659
if (ev >= NSAPI_EVENT_CELLULAR_STATUS_BASE && ev <= NSAPI_EVENT_CELLULAR_STATUS_END) {
660660
tr_debug("FSM: cellular_event_changed called with event: %d, err: %d, data: %d _state: %s", ev, data->error, data->status_data, get_state_string(_state));
661661
} else {

features/cellular/framework/device/CellularStateMachine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "PlatformMutex.h"
2424

2525
namespace rtos {
26-
class Thread;
26+
class Thread;
2727
}
2828

2929
namespace mbed {

0 commit comments

Comments
 (0)