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 CellularInformation *open_information(FileHandle *fh = NULL);
67 
68  virtual void close_network();
69 
70  virtual void close_information();
71 
72  virtual void set_timeout(int timeout);
73 
74  virtual uint16_t get_send_delay() const;
75 
76  virtual void modem_debug_on(bool on);
77 
78  virtual nsapi_error_t init();
79 
80  virtual nsapi_error_t shutdown();
81 
82  virtual nsapi_error_t is_ready();
83 
84  virtual void set_ready_cb(Callback<void()> callback);
85 
86  virtual nsapi_error_t set_power_save_mode(int periodic_time, int active_time = 0);
87 
88 
89  virtual ATHandler *get_at_handler(FileHandle *fh);
90 
91  virtual ATHandler *get_at_handler();
92 
93  /** Releases the given at_handler. If last reference to at_hander then it's deleted.
94  *
95  * @param at_handler
96  * @return NSAPI_ERROR_OK on success, NSAPI_ERROR_PARAMETER on failure
97  */
98  virtual nsapi_error_t release_at_handler(ATHandler *at_handler);
99 
100  /** Creates new instance of AT_CellularContext or if overridden, modem specific implementation.
101  *
102  * @param at ATHandler reference for communication with the modem.
103  * @param apn access point to use with context
104  * @param cp_req flag indicating if control plane EPS optimization needs to be setup
105  * @param nonip_req flag indicating if PDP context needs to be Non-IP
106  * @return new instance of class AT_CellularContext
107  *
108  */
109  virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
110 
111  /** Create new instance of AT_CellularNetwork or if overridden, modem specific implementation.
112  *
113  * @param at ATHandler reference for communication with the modem.
114  * @return new instance of class AT_CellularNetwork
115  */
117 
118  /** Create new instance of AT_CellularInformation or if overridden, modem specific implementation.
119  *
120  * @param at ATHandler reference for communication with the modem.
121  * @return new instance of class AT_CellularInformation
122  */
124 
125  virtual CellularContext *get_context_list() const;
126 
127  virtual nsapi_error_t set_baud_rate(int baud_rate);
128 
129 #if MBED_CONF_CELLULAR_USE_SMS
130  virtual CellularSMS *open_sms(FileHandle *fh = NULL);
131 
132  virtual void close_sms();
133 
134  /** Create new instance of AT_CellularSMS or if overridden, modem specific implementation.
135  *
136  * @param at ATHandler reference for communication with the modem.
137  * @return new instance of class AT_CellularSMS
138  */
139  virtual AT_CellularSMS *open_sms_impl(ATHandler &at);
140 
141  AT_CellularSMS *_sms;
142 
143 #endif // MBED_CONF_CELLULAR_USE_SMS
144 
145  AT_CellularNetwork *_network;
146 
147  AT_CellularInformation *_information;
148  AT_CellularContext *_context_list;
149  int _default_timeout;
150  bool _modem_debug_on;
151  ATHandler *_at;
152 
153 protected:
154  virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx = NULL);
155  void send_disconnect_to_context(int cid);
156  // Sets commonly used URCs
157  void set_at_urcs();
158  // To be used for setting target specific URCs
159  virtual void set_at_urcs_impl();
160  // Sets up parameters for AT handler, for now only the send delay and URCs.
161  // This kind of routine is needed for initialisation routines that are virtual and therefore cannot be called from constructor.
162  void setup_at_handler();
163  virtual nsapi_error_t set_baud_rate_impl(int baud_rate);
164 
165 private:
166  void urc_nw_deact();
167  void urc_pdn_deact();
168 };
169 
170 } // namespace mbed
171 #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 nsapi_error_t set_baud_rate(int baud_rate)
Sets cellular modem to given baud rate.
virtual void close_sms()=0
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.
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.
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.
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.
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
virtual CellularSMS * open_sms(FileHandle *fh=NULL)=0
Create new CellularSMS interface.
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:68
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.