diff --git a/UNITTESTS/stubs/CellularDevice_stub.cpp b/UNITTESTS/stubs/CellularDevice_stub.cpp index 9cc36650a6..df2e08892b 100644 --- a/UNITTESTS/stubs/CellularDevice_stub.cpp +++ b/UNITTESTS/stubs/CellularDevice_stub.cpp @@ -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) { } diff --git a/features/cellular/framework/API/CellularContext.h b/features/cellular/framework/API/CellularContext.h index 45c758aec8..170cd63f90 100644 --- a/features/cellular/framework/API/CellularContext.h +++ b/features/cellular/framework/API/CellularContext.h @@ -161,7 +161,6 @@ public: // from NetworkInterface */ static CellularContext *get_default_instance(); - /** Instantiates a default Non-IP cellular interface * * This function creates a new Non-IP PDP context. diff --git a/features/cellular/framework/API/CellularDevice.h b/features/cellular/framework/API/CellularDevice.h index 024410572e..f193fbcde6 100644 --- a/features/cellular/framework/API/CellularDevice.h +++ b/features/cellular/framework/API/CellularDevice.h @@ -485,9 +485,7 @@ protected: //Common functions 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 @@ -499,15 +497,13 @@ protected: //Member variables FileHandle *_fh; events::EventQueue _queue; CellularStateMachine *_state_machine; + Callback _status_cb; private: //Member variables CellularNetwork *_nw; char _sim_pin[MAX_PIN_SIZE + 1]; char _plmn[MAX_PLMN_SIZE + 1]; PlatformMutex _mutex; - Callback _status_cb; - - const intptr_t *_property_array; }; /** diff --git a/features/cellular/framework/API/CellularSMS.h b/features/cellular/framework/API/CellularSMS.h index 0f015232b3..7a3004af6a 100644 --- a/features/cellular/framework/API/CellularSMS.h +++ b/features/cellular/framework/API/CellularSMS.h @@ -56,8 +56,8 @@ protected: * virtual Destructor */ virtual ~CellularSMS() {}; -public: +public: /* Enumeration for possible SMS modes, PDU and Text */ enum CellularSMSMmode { CellularSMSMmodePDU = 0, diff --git a/features/cellular/framework/AT/AT_CellularContext.h b/features/cellular/framework/AT/AT_CellularContext.h index b19c5f3849..c8aecbf920 100644 --- a/features/cellular/framework/AT/AT_CellularContext.h +++ b/features/cellular/framework/AT/AT_CellularContext.h @@ -73,6 +73,7 @@ public: AT_CellularDevice *get_device() const; ATHandler &get_at_handler(); + protected: virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr); @@ -107,6 +108,7 @@ protected: 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(); @@ -124,6 +126,7 @@ private: virtual void do_connect_with_retry(); void do_disconnect(); void set_cid(int cid); + private: ContextOperation _current_op; FileHandle *_fh; @@ -135,8 +138,6 @@ protected: // flag indicating if CP was requested to be setup bool _cp_req; bool _is_connected; - -protected: ATHandler &_at; }; diff --git a/features/cellular/framework/AT/AT_CellularDevice.h b/features/cellular/framework/AT/AT_CellularDevice.h index 5c028a141b..c678c50a14 100755 --- a/features/cellular/framework/AT/AT_CellularDevice.h +++ b/features/cellular/framework/AT/AT_CellularDevice.h @@ -123,6 +123,30 @@ public: */ 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. @@ -148,50 +172,15 @@ public: */ 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 @@ -207,7 +196,20 @@ private: 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; }; diff --git a/features/cellular/framework/AT/AT_CellularInformation.h b/features/cellular/framework/AT/AT_CellularInformation.h index 36ad047e9a..ec6aeefbbf 100644 --- a/features/cellular/framework/AT/AT_CellularInformation.h +++ b/features/cellular/framework/AT/AT_CellularInformation.h @@ -49,6 +49,7 @@ public: virtual nsapi_error_t get_iccid(char *buf, size_t buf_size); ATHandler &get_at_handler(); + protected: /** Request information text from cellular device * @@ -61,7 +62,6 @@ protected: protected: ATHandler &_at; - AT_CellularDevice &_device; }; diff --git a/features/cellular/framework/AT/AT_CellularNetwork.h b/features/cellular/framework/AT/AT_CellularNetwork.h index aa2f61ca34..8537d2f5c0 100644 --- a/features/cellular/framework/AT/AT_CellularNetwork.h +++ b/features/cellular/framework/AT/AT_CellularNetwork.h @@ -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); @@ -101,7 +100,6 @@ public: ATHandler &get_at_handler(); protected: - /** Sets access technology to be scanned. Modem specific implementation. * * @param op_rat Access technology @@ -140,7 +138,6 @@ private: void call_network_cb(nsapi_connection_status_t status); protected: - Callback _connection_status_cb; Callback _ciotopt_network_support_cb; RadioAccessTechnology _op_act; @@ -150,9 +147,7 @@ protected: registration_params_t _reg_params; mbed::Callback _urc_funcs[C_MAX]; -protected: ATHandler &_at; - AT_CellularDevice &_device; }; diff --git a/features/cellular/framework/AT/AT_CellularSMS.h b/features/cellular/framework/AT/AT_CellularSMS.h index 98191bc630..d086ada7fc 100644 --- a/features/cellular/framework/AT/AT_CellularSMS.h +++ b/features/cellular/framework/AT/AT_CellularSMS.h @@ -66,7 +66,6 @@ public: 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 @@ -78,14 +77,6 @@ private: 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 _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(); @@ -171,8 +162,15 @@ private: int msg_len); private: - ATHandler &_at; + // application callback function for received sms + Callback _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; }; diff --git a/features/cellular/framework/AT/AT_CellularStack.h b/features/cellular/framework/AT/AT_CellularStack.h index db966ee272..a1d1476cdf 100644 --- a/features/cellular/framework/AT/AT_CellularStack.h +++ b/features/cellular/framework/AT/AT_CellularStack.h @@ -99,7 +99,6 @@ protected: // NetworkStack virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data); protected: - class CellularSocket { public: CellularSocket() : @@ -188,6 +187,7 @@ protected: 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 @@ -211,6 +211,10 @@ protected: */ bool is_addr_stack_compatible(const SocketAddress &addr); +private: + int get_socket_index_by_port(uint16_t port); + +protected: // socket container CellularSocket **_socket; @@ -229,16 +233,10 @@ protected: // 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; }; diff --git a/features/cellular/framework/AT/AT_ControlPlane_netif.h b/features/cellular/framework/AT/AT_ControlPlane_netif.h index a502ded282..13c3895aaf 100644 --- a/features/cellular/framework/AT/AT_ControlPlane_netif.h +++ b/features/cellular/framework/AT/AT_ControlPlane_netif.h @@ -9,7 +9,6 @@ public: virtual ~AT_ControlPlane_netif(); protected: - // ControlPlane_netif /* Sends data using +CSODCP specified in @@ -17,7 +16,6 @@ protected: */ 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 */ diff --git a/features/cellular/framework/device/CellularDevice.cpp b/features/cellular/framework/device/CellularDevice.cpp index 1bccde4d67..0537160444 100644 --- a/features/cellular/framework/device/CellularDevice.cpp +++ b/features/cellular/framework/device/CellularDevice.cpp @@ -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);