Skip to content

Cellular: Refactor cellular variable visibilities #12123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UNITTESTS/stubs/CellularDevice_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0),
_sms_ref_count(0),
#endif //MBED_CONF_CELLULAR_USE_SMS
_info_ref_count(0), _fh(fh), _queue(10 * EVENTS_EVENT_SIZE), _state_machine(0),
_nw(0), _status_cb(0), _property_array(0)
_nw(0), _status_cb(0)
{
}

Expand Down
1 change: 0 additions & 1 deletion features/cellular/framework/API/CellularContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ class CellularContext : public CellularInterface {
*/
static CellularContext *get_default_instance();


/** Instantiates a default Non-IP cellular interface
*
* This function creates a new Non-IP PDP context.
Expand Down
6 changes: 1 addition & 5 deletions features/cellular/framework/API/CellularDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,7 @@ class CellularDevice {

private: //Common functions
nsapi_error_t start_state_machine(CellularStateMachine::CellularState target_state);

nsapi_error_t create_state_machine();

void stm_callback(nsapi_event_t ev, intptr_t ptr);

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

private: //Member variables
CellularNetwork *_nw;
char _sim_pin[MAX_PIN_SIZE + 1];
char _plmn[MAX_PLMN_SIZE + 1];
PlatformMutex _mutex;
Callback<void(nsapi_event_t, intptr_t)> _status_cb;

const intptr_t *_property_array;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion features/cellular/framework/API/CellularSMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class CellularSMS {
* virtual Destructor
*/
virtual ~CellularSMS() {};
public:

public:
/* Enumeration for possible SMS modes, PDU and Text */
enum CellularSMSMmode {
CellularSMSMmodePDU = 0,
Expand Down
5 changes: 3 additions & 2 deletions features/cellular/framework/AT/AT_CellularContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class AT_CellularContext : public CellularContext {
AT_CellularDevice *get_device() const;

ATHandler &get_at_handler();

protected:
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr);

Expand Down Expand Up @@ -107,6 +108,7 @@ class AT_CellularContext : public CellularContext {
virtual bool get_context();
AT_CellularDevice::CellularProperty pdp_type_t_to_cellular_property(pdp_type_t pdp_type);
bool set_new_context(int cid);

private:
#if NSAPI_PPP_AVAILABLE
nsapi_error_t open_data_channel();
Expand All @@ -124,6 +126,7 @@ class AT_CellularContext : public CellularContext {
virtual void do_connect_with_retry();
void do_disconnect();
void set_cid(int cid);

private:
ContextOperation _current_op;
FileHandle *_fh;
Expand All @@ -135,8 +138,6 @@ class AT_CellularContext : public CellularContext {
// flag indicating if CP was requested to be setup
bool _cp_req;
bool _is_connected;

protected:
ATHandler &_at;
};

Expand Down
72 changes: 37 additions & 35 deletions features/cellular/framework/AT/AT_CellularDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ class AT_CellularDevice : public CellularDevice {
*/
virtual nsapi_error_t release_at_handler(ATHandler *at_handler);

virtual CellularContext *get_context_list() const;

virtual nsapi_error_t set_baud_rate(int baud_rate);

#if MBED_CONF_CELLULAR_USE_SMS
virtual CellularSMS *open_sms(FileHandle *fh = NULL);

virtual void close_sms();
#endif

/** Get value for the given key.
*
* @param key key for value to be fetched
* @return property value for the given key. Value type is defined in enum CellularProperty
*/
intptr_t get_property(CellularProperty key);

/** Cellular module need to define an array of cellular properties which defines module supported property values.
*
* @param property_array array of module properties
*/
void set_cellular_properties(const intptr_t *property_array);

protected:
/** Creates new instance of AT_CellularContext or if overridden, modem specific implementation.
*
* @param at ATHandler reference for communication with the modem.
Expand All @@ -148,50 +172,15 @@ class AT_CellularDevice : public CellularDevice {
*/
virtual AT_CellularInformation *open_information_impl(ATHandler &at);

virtual CellularContext *get_context_list() const;

virtual nsapi_error_t set_baud_rate(int baud_rate);

#if MBED_CONF_CELLULAR_USE_SMS
virtual CellularSMS *open_sms(FileHandle *fh = NULL);

virtual void close_sms();

/** Create new instance of AT_CellularSMS or if overridden, modem specific implementation.
*
* @param at ATHandler reference for communication with the modem.
* @return new instance of class AT_CellularSMS
*/
virtual AT_CellularSMS *open_sms_impl(ATHandler &at);

AT_CellularSMS *_sms;

#endif // MBED_CONF_CELLULAR_USE_SMS

public:
/** Get value for the given key.
*
* @param key key for value to be fetched
* @return property value for the given key. Value type is defined in enum CellularProperty
*/
intptr_t get_property(CellularProperty key);

/** Cellular module need to define an array of cellular properties which defines module supported property values.
*
* @param property_array array of module properties
*/
void set_cellular_properties(const intptr_t *property_array);

public: //Member variables
AT_CellularNetwork *_network;

AT_CellularInformation *_information;
AT_CellularContext *_context_list;
int _default_timeout;
bool _modem_debug_on;
ATHandler *_at;

protected:
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx = NULL);
void send_disconnect_to_context(int cid);
// Sets commonly used URCs
Expand All @@ -207,7 +196,20 @@ class AT_CellularDevice : public CellularDevice {
void urc_nw_deact();
void urc_pdn_deact();

protected:
ATHandler *_at;

private:
#if MBED_CONF_CELLULAR_USE_SMS
AT_CellularSMS *_sms;
#endif // MBED_CONF_CELLULAR_USE_SMS

AT_CellularNetwork *_network;
AT_CellularInformation *_information;
AT_CellularContext *_context_list;

int _default_timeout;
bool _modem_debug_on;
const intptr_t *_property_array;
};

Expand Down
2 changes: 1 addition & 1 deletion features/cellular/framework/AT/AT_CellularInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AT_CellularInformation : public CellularInformation {
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);

ATHandler &get_at_handler();

protected:
/** Request information text from cellular device
*
Expand All @@ -61,7 +62,6 @@ class AT_CellularInformation : public CellularInformation {

protected:
ATHandler &_at;

AT_CellularDevice &_device;
};

Expand Down
5 changes: 0 additions & 5 deletions features/cellular/framework/AT/AT_CellularNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace mbed {
* Class for attaching to a network and getting information from it.
*/
class AT_CellularNetwork : public CellularNetwork {

public:

AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
Expand Down Expand Up @@ -101,7 +100,6 @@ class AT_CellularNetwork : public CellularNetwork {
ATHandler &get_at_handler();

protected:

/** Sets access technology to be scanned. Modem specific implementation.
*
* @param op_rat Access technology
Expand Down Expand Up @@ -140,7 +138,6 @@ class AT_CellularNetwork : public CellularNetwork {
void call_network_cb(nsapi_connection_status_t status);

protected:

Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
Callback<void(CIoT_Supported_Opt)> _ciotopt_network_support_cb;
RadioAccessTechnology _op_act;
Expand All @@ -150,9 +147,7 @@ class AT_CellularNetwork : public CellularNetwork {
registration_params_t _reg_params;
mbed::Callback<void()> _urc_funcs[C_MAX];

protected:
ATHandler &_at;

AT_CellularDevice &_device;
};

Expand Down
18 changes: 8 additions & 10 deletions features/cellular/framework/AT/AT_CellularSMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class AT_CellularSMS: public CellularSMS {
ATHandler &get_at_handler();

private:

struct sms_info_t {
char date[SMS_MAX_TIME_STAMP_SIZE];
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
Expand All @@ -78,14 +77,6 @@ class AT_CellularSMS: public CellularSMS {
sms_info_t() : msg_size(0), parts(1), parts_added(1), msg_ref_number(0), next_info(0) {};
};

// application callback function for received sms
Callback<void()> _cb;
CellularSMSMmode _mode;
bool _use_8bit_encoding;
uint32_t _sim_wait_time;
uint16_t _sms_message_ref_number;
sms_info_t *_sms_info;

// SMS urc's
void cmt_urc();
void cmti_urc();
Expand Down Expand Up @@ -171,8 +162,15 @@ class AT_CellularSMS: public CellularSMS {
int msg_len);

private:
ATHandler &_at;
// application callback function for received sms
Callback<void()> _cb;
CellularSMSMmode _mode;
bool _use_8bit_encoding;
uint32_t _sim_wait_time;
uint16_t _sms_message_ref_number;
sms_info_t *_sms_info;

ATHandler &_at;
AT_CellularDevice &_device;
};

Expand Down
12 changes: 5 additions & 7 deletions features/cellular/framework/AT/AT_CellularStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class AT_CellularStack : public NetworkStack {
virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data);

protected:

class CellularSocket {
public:
CellularSocket() :
Expand Down Expand Up @@ -188,6 +187,7 @@ class AT_CellularStack : public NetworkStack {
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
void *buffer, nsapi_size_t size) = 0;

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

private:
int get_socket_index_by_port(uint16_t port);

protected:
// socket container
CellularSocket **_socket;

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

private:

int get_socket_index_by_port(uint16_t port);

protected:
// mutex for write/read to a _socket array, needed when multiple threads may use sockets simultaneously
PlatformMutex _socket_mutex;

ATHandler &_at;

AT_CellularDevice &_device;
};

Expand Down
2 changes: 0 additions & 2 deletions features/cellular/framework/AT/AT_ControlPlane_netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ class AT_ControlPlane_netif: public ControlPlane_netif {
virtual ~AT_ControlPlane_netif();

protected:

// ControlPlane_netif

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


/* Receives data using +CRTDCP specified in
* 3GPP 27007 10.1.44: Reporting of terminating data via the control plane
*/
Expand Down
2 changes: 1 addition & 1 deletion features/cellular/framework/device/CellularDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0),
_sms_ref_count(0),
#endif //MBED_CONF_CELLULAR_USE_SMS
_info_ref_count(0), _fh(fh), _queue(10 * EVENTS_EVENT_SIZE), _state_machine(0),
_nw(0), _status_cb(0), _property_array(0)
_status_cb(0), _nw(0)
{
MBED_ASSERT(fh);
set_sim_pin(NULL);
Expand Down