mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: Updated coding guidelines
parent
63f62165d8
commit
f059fb36bd
|
@ -37,8 +37,7 @@
|
||||||
|
|
||||||
#define RETRY_COUNT_DEFAULT 3
|
#define RETRY_COUNT_DEFAULT 3
|
||||||
|
|
||||||
namespace mbed
|
namespace mbed {
|
||||||
{
|
|
||||||
|
|
||||||
CellularConnectionFSM::CellularConnectionFSM() :
|
CellularConnectionFSM::CellularConnectionFSM() :
|
||||||
_serial(0), _state(STATE_INIT), _next_state(_state), _status_callback(0), _event_status_cb(0), _network(0), _power(0), _sim(0),
|
_serial(0), _state(STATE_INIT), _next_state(_state), _status_callback(0), _event_status_cb(0), _network(0), _power(0), _sim(0),
|
||||||
|
@ -147,7 +146,7 @@ bool CellularConnectionFSM::power_on()
|
||||||
void CellularConnectionFSM::set_sim_pin(const char *sim_pin)
|
void CellularConnectionFSM::set_sim_pin(const char *sim_pin)
|
||||||
{
|
{
|
||||||
strncpy(_sim_pin, sim_pin, sizeof(_sim_pin));
|
strncpy(_sim_pin, sim_pin, sizeof(_sim_pin));
|
||||||
_sim_pin[sizeof(_sim_pin)-1] = '\0';
|
_sim_pin[sizeof(_sim_pin) - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellularConnectionFSM::set_plmn(const char *plmn)
|
void CellularConnectionFSM::set_plmn(const char *plmn)
|
||||||
|
@ -581,7 +580,7 @@ void CellularConnectionFSM::event()
|
||||||
if (_event_timeout == -1) {
|
if (_event_timeout == -1) {
|
||||||
_event_timeout = 0;
|
_event_timeout = 0;
|
||||||
}
|
}
|
||||||
_event_id = _queue.call_in(_event_timeout*1000, callback(this, &CellularConnectionFSM::event));
|
_event_id = _queue.call_in(_event_timeout * 1000, callback(this, &CellularConnectionFSM::event));
|
||||||
if (!_event_id) {
|
if (!_event_id) {
|
||||||
report_failure("Cellular event failure!");
|
report_failure("Cellular event failure!");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -43,8 +43,7 @@ const int MAX_RETRY_ARRAY_SIZE = 10;
|
||||||
*
|
*
|
||||||
* Finite State Machine for connecting to cellular network
|
* Finite State Machine for connecting to cellular network
|
||||||
*/
|
*/
|
||||||
class CellularConnectionFSM
|
class CellularConnectionFSM {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CellularConnectionFSM();
|
CellularConnectionFSM();
|
||||||
virtual ~CellularConnectionFSM();
|
virtual ~CellularConnectionFSM();
|
||||||
|
@ -148,7 +147,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param plmn operator in numeric format. See more from 3GPP TS 27.007 chapter 7.3.
|
* @param plmn operator in numeric format. See more from 3GPP TS 27.007 chapter 7.3.
|
||||||
*/
|
*/
|
||||||
void set_plmn(const char* plmn);
|
void set_plmn(const char *plmn);
|
||||||
|
|
||||||
/** returns readable format of the given state. Used for printing states while debugging.
|
/** returns readable format of the given state. Used for printing states while debugging.
|
||||||
*
|
*
|
||||||
|
@ -186,7 +185,7 @@ private:
|
||||||
NetworkStack *get_stack();
|
NetworkStack *get_stack();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void report_failure(const char* msg);
|
void report_failure(const char *msg);
|
||||||
void event();
|
void event();
|
||||||
void ready_urc_cb();
|
void ready_urc_cb();
|
||||||
|
|
||||||
|
@ -203,7 +202,7 @@ private:
|
||||||
events::EventQueue _queue;
|
events::EventQueue _queue;
|
||||||
rtos::Thread *_queue_thread;
|
rtos::Thread *_queue_thread;
|
||||||
CellularDevice *_cellularDevice;
|
CellularDevice *_cellularDevice;
|
||||||
char _sim_pin[PIN_SIZE+1];
|
char _sim_pin[PIN_SIZE + 1];
|
||||||
int _retry_count;
|
int _retry_count;
|
||||||
int _start_time;
|
int _start_time;
|
||||||
int _event_timeout;
|
int _event_timeout;
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
#include "CellularInformation.h"
|
#include "CellularInformation.h"
|
||||||
#include "NetworkStack.h"
|
#include "NetworkStack.h"
|
||||||
|
|
||||||
namespace mbed
|
namespace mbed {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CellularDevice
|
* Class CellularDevice
|
||||||
|
@ -36,8 +35,7 @@ namespace mbed
|
||||||
* An abstract interface that defines opening and closing of cellular interfaces.
|
* An abstract interface that defines opening and closing of cellular interfaces.
|
||||||
* Deleting/Closing of opened interfaces can be done only via this class.
|
* Deleting/Closing of opened interfaces can be done only via this class.
|
||||||
*/
|
*/
|
||||||
class CellularDevice
|
class CellularDevice {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/** virtual Destructor
|
/** virtual Destructor
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -28,8 +28,7 @@
|
||||||
|
|
||||||
#include "ATHandler.h"
|
#include "ATHandler.h"
|
||||||
|
|
||||||
namespace mbed
|
namespace mbed {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AT_CellularDevice
|
* Class AT_CellularDevice
|
||||||
|
@ -37,8 +36,7 @@ namespace mbed
|
||||||
* A class defines opening and closing of cellular interfaces.
|
* A class defines opening and closing of cellular interfaces.
|
||||||
* Deleting/Closing of opened interfaces can be done only through this class.
|
* Deleting/Closing of opened interfaces can be done only through this class.
|
||||||
*/
|
*/
|
||||||
class AT_CellularDevice : public CellularDevice
|
class AT_CellularDevice : public CellularDevice {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
AT_CellularDevice(events::EventQueue &queue);
|
AT_CellularDevice(events::EventQueue &queue);
|
||||||
virtual ~AT_CellularDevice();
|
virtual ~AT_CellularDevice();
|
||||||
|
@ -52,7 +50,7 @@ protected:
|
||||||
*
|
*
|
||||||
* @param at_handler
|
* @param at_handler
|
||||||
*/
|
*/
|
||||||
void release_at_handler(ATHandler* at_handler);
|
void release_at_handler(ATHandler *at_handler);
|
||||||
|
|
||||||
public: // CellularDevice
|
public: // CellularDevice
|
||||||
virtual CellularNetwork *open_network(FileHandle *fh);
|
virtual CellularNetwork *open_network(FileHandle *fh);
|
||||||
|
@ -87,8 +85,8 @@ protected:
|
||||||
AT_CellularNetwork *_network;
|
AT_CellularNetwork *_network;
|
||||||
AT_CellularSMS *_sms;
|
AT_CellularSMS *_sms;
|
||||||
AT_CellularSIM *_sim;
|
AT_CellularSIM *_sim;
|
||||||
AT_CellularPower* _power;
|
AT_CellularPower *_power;
|
||||||
AT_CellularInformation* _information;
|
AT_CellularInformation *_information;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
events::EventQueue &_queue;
|
events::EventQueue &_queue;
|
||||||
|
|
Loading…
Reference in New Issue