Mistake on this page?
Report an issue in GitHub or email us
AT_CellularDevice.h
1 /*
2  * Copyright (c) 2017, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef AT_CELLULAR_DEVICE_H_
19 #define AT_CELLULAR_DEVICE_H_
20 
21 #include "CellularDevice.h"
22 
23 namespace mbed {
24 
25 class ATHandler;
26 class AT_CellularInformation;
27 class AT_CellularNetwork;
28 class AT_CellularSMS;
29 class AT_CellularContext;
30 
31 /**
32  * Class AT_CellularDevice
33  *
34  * A class defines opening and closing of cellular interfaces.
35  * Deleting/Closing of opened interfaces can be done only through this class.
36  */
38 public:
40  virtual ~AT_CellularDevice();
41 
42  virtual nsapi_error_t clear();
43 
44  virtual nsapi_error_t hard_power_on();
45 
46  virtual nsapi_error_t hard_power_off();
47 
48  virtual nsapi_error_t soft_power_on();
49 
50  virtual nsapi_error_t soft_power_off();
51 
52  virtual nsapi_error_t set_pin(const char *sim_pin);
53 
54  virtual nsapi_error_t get_sim_state(SimState &state);
55 
56  virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false);
57 
58 #if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
59  virtual CellularContext *create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin = NC, bool active_high = false, bool cp_req = false, bool nonip_req = false);
60 #endif // #if DEVICE_SERIAL
61 
62  virtual void delete_context(CellularContext *context);
63 
64  virtual CellularNetwork *open_network(FileHandle *fh = NULL);
65 
66  virtual CellularSMS *open_sms(FileHandle *fh = NULL);
67 
68  virtual CellularInformation *open_information(FileHandle *fh = NULL);
69 
70  virtual void close_network();
71 
72  virtual void close_sms();
73 
74  virtual void close_information();
75 
76  virtual void set_timeout(int timeout);
77 
78  virtual uint16_t get_send_delay() const;
79 
80  virtual void modem_debug_on(bool on);
81 
82  virtual nsapi_error_t init();
83 
84  virtual nsapi_error_t shutdown();
85 
86  virtual nsapi_error_t is_ready();
87 
88  virtual void set_ready_cb(Callback<void()> callback);
89 
90  virtual nsapi_error_t set_power_save_mode(int periodic_time, int active_time = 0);
91 
92 
93  virtual ATHandler *get_at_handler(FileHandle *fh);
94 
95  virtual ATHandler *get_at_handler();
96 
97  /** Releases the given at_handler. If last reference to at_hander then it's deleted.
98  *
99  * @param at_handler
100  * @return NSAPI_ERROR_OK on success, NSAPI_ERROR_PARAMETER on failure
101  */
102  virtual nsapi_error_t release_at_handler(ATHandler *at_handler);
103 
104  /** Creates new instance of AT_CellularContext or if overridden, modem specific implementation.
105  *
106  * @param at ATHandler reference for communication with the modem.
107  * @param apn access point to use with context
108  * @param cp_req flag indicating if control plane EPS optimization needs to be setup
109  * @param nonip_req flag indicating if PDP context needs to be Non-IP
110  * @return new instance of class AT_CellularContext
111  *
112  */
113  virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
114 
115  /** Create new instance of AT_CellularNetwork or if overridden, modem specific implementation.
116  *
117  * @param at ATHandler reference for communication with the modem.
118  * @return new instance of class AT_CellularNetwork
119  */
121 
122  /** Create new instance of AT_CellularSMS or if overridden, modem specific implementation.
123  *
124  * @param at ATHandler reference for communication with the modem.
125  * @return new instance of class AT_CellularSMS
126  */
127  virtual AT_CellularSMS *open_sms_impl(ATHandler &at);
128 
129  /** Create new instance of AT_CellularInformation or if overridden, modem specific implementation.
130  *
131  * @param at ATHandler reference for communication with the modem.
132  * @return new instance of class AT_CellularInformation
133  */
135 
136  virtual CellularContext *get_context_list() const;
137 
138  AT_CellularNetwork *_network;
139  AT_CellularSMS *_sms;
140  AT_CellularInformation *_information;
141  AT_CellularContext *_context_list;
142  int _default_timeout;
143  bool _modem_debug_on;
144  ATHandler *_at;
145 
146 protected:
147  virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx = NULL);
148  void send_disconnect_to_context(int cid);
149  // Sets commonly used URCs
150  void set_at_urcs();
151  // To be used for setting target specific URCs
152  virtual void set_at_urcs_impl();
153  // Sets up parameters for AT handler, for now only the send delay and URCs.
154  // This kind of routine is needed for initialisation routines that are virtual and therefore cannot be called from constructor.
155  void setup_at_handler();
156 
157 private:
158  void urc_nw_deact();
159  void urc_pdn_deact();
160 };
161 
162 } // namespace mbed
163 #endif // AT_CELLULAR_DEVICE_H_
virtual nsapi_error_t get_sim_state(SimState &state)
Get SIM card&#39;s state.
virtual AT_CellularContext * create_context_impl(ATHandler &at, const char *apn, bool cp_req=false, bool nonip_req=false)
Creates new instance of AT_CellularContext or if overridden, modem specific implementation.
virtual void close_information()
Closes the opened CellularInformation by deleting the CellularInformation instance.
virtual void set_ready_cb(Callback< void()> callback)
Set callback function to listen when device is ready.
virtual void close_sms()
Closes the opened CellularSMS by deleting the CellularSMS instance.
CellularContext is CellularInterface/NetworkInterface with extensions for cellular connectivity...
Class CellularDevice.
virtual nsapi_error_t is_ready()
Check whether the device is ready to accept commands.
Class AT_CellularSMS.
virtual nsapi_error_t set_pin(const char *sim_pin)
Open the SIM card by setting the pin code for SIM.
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:95
Class FileHandle.
Definition: FileHandle.h:46
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx=NULL)
Cellular callback to be attached to Network and CellularStateMachine classes.
virtual AT_CellularSMS * open_sms_impl(ATHandler &at)
Create new instance of AT_CellularSMS or if overridden, modem specific implementation.
Class providing buffered UART communication functionality using separate circular buffer for send and...
Definition: UARTSerial.h:51
virtual nsapi_error_t soft_power_on()
Powers up the modem.
virtual ATHandler * get_at_handler()
Get the current ATHandler instance in use for debug purposes etc.
virtual nsapi_error_t soft_power_off()
Powers down the modem.
virtual CellularContext * get_context_list() const
Get the linked list of CellularContext instances.
Class CellularDevice.
virtual nsapi_error_t shutdown()
Shutdown cellular device to minimum functionality.
virtual void close_network()
Closes the opened CellularNetwork by deleting the CellularNetwork instance.
virtual CellularNetwork * open_network(FileHandle *fh=NULL)
Create new CellularNetwork interface.
virtual AT_CellularNetwork * open_network_impl(ATHandler &at)
Create new instance of AT_CellularNetwork or if overridden, modem specific implementation.
virtual AT_CellularInformation * open_information_impl(ATHandler &at)
Create new instance of AT_CellularInformation or if overridden, modem specific implementation.
An abstract interface for connecting to a network and getting information from it.
Class CellularInformation.
virtual CellularInformation * open_information(FileHandle *fh=NULL)
Create new CellularInformation interface.
virtual nsapi_error_t init()
Initialize cellular device must be called right after the module is ready.
Class AT_CellularInformation.
virtual nsapi_error_t hard_power_on()
Sets the modem up for powering on This is equivalent to plugging in the device, i.e., attaching power and serial port.
virtual nsapi_error_t hard_power_off()
Sets the modem in unplugged state.
Callback< R(ArgTs...)> callback(R(*func)(ArgTs...)=0)
Create a callback class with type inferred from the arguments.
Definition: Callback.h:709
virtual nsapi_error_t release_at_handler(ATHandler *at_handler)
Releases the given at_handler.
Class CellularSMS.
Definition: CellularSMS.h:48
virtual nsapi_error_t clear()
Clear modem to a default initial state.
virtual CellularContext * create_context(FileHandle *fh=NULL, const char *apn=NULL, bool cp_req=false, bool nonip_req=false)
Creates a new CellularContext interface.
virtual void delete_context(CellularContext *context)
Deletes the given CellularContext instance.
virtual CellularSMS * open_sms(FileHandle *fh=NULL)
Create new CellularSMS interface.
Class AT_CellularDevice.
virtual void set_timeout(int timeout)
Set the default response timeout.
virtual void modem_debug_on(bool on)
Turn modem debug traces on.
Class AT_CellularNetwork.
virtual nsapi_error_t set_power_save_mode(int periodic_time, int active_time=0)
Set power save mode.
Callback class based on template specialization.
Definition: Callback.h:39
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:66
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.