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 hard_power_on();
43 
44  virtual nsapi_error_t hard_power_off();
45 
46  virtual nsapi_error_t soft_power_on();
47 
48  virtual nsapi_error_t soft_power_off();
49 
50  virtual nsapi_error_t set_pin(const char *sim_pin);
51 
52  virtual nsapi_error_t get_sim_state(SimState &state);
53 
54  virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false);
55 
56 #if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
57  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);
58 #endif // #if DEVICE_SERIAL
59 
60  virtual void delete_context(CellularContext *context);
61 
62  virtual CellularNetwork *open_network(FileHandle *fh = NULL);
63 
64  virtual CellularSMS *open_sms(FileHandle *fh = NULL);
65 
66  virtual CellularInformation *open_information(FileHandle *fh = NULL);
67 
68  virtual void close_network();
69 
70  virtual void close_sms();
71 
72  virtual void close_information();
73 
74  virtual void set_timeout(int timeout);
75 
76  virtual uint16_t get_send_delay() const;
77 
78  virtual void modem_debug_on(bool on);
79 
80  virtual nsapi_error_t init();
81 
82  virtual nsapi_error_t shutdown();
83 
84  virtual nsapi_error_t is_ready();
85 
86  virtual void set_ready_cb(Callback<void()> callback);
87 
88  virtual nsapi_error_t set_power_save_mode(int periodic_time, int active_time = 0);
89 
90 
91  virtual ATHandler *get_at_handler(FileHandle *fh);
92 
93  virtual ATHandler *get_at_handler();
94 
95  /** Releases the given at_handler. If last reference to at_hander then it's deleted.
96  *
97  * @param at_handler
98  * @return NSAPI_ERROR_OK on success, NSAPI_ERROR_PARAMETER on failure
99  */
100  virtual nsapi_error_t release_at_handler(ATHandler *at_handler);
101 
102  /** Creates new instance of AT_CellularContext or if overridden, modem specific implementation.
103  *
104  * @param at ATHandler reference for communication with the modem.
105  * @param apn access point to use with context
106  * @param cp_req flag indicating if control plane EPS optimization needs to be setup
107  * @param nonip_req flag indicating if PDP context needs to be Non-IP
108  * @return new instance of class AT_CellularContext
109  *
110  */
111  virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
112 
113  /** Create new instance of AT_CellularNetwork or if overridden, modem specific implementation.
114  *
115  * @param at ATHandler reference for communication with the modem.
116  * @return new instance of class AT_CellularNetwork
117  */
119 
120  /** Create new instance of AT_CellularSMS or if overridden, modem specific implementation.
121  *
122  * @param at ATHandler reference for communication with the modem.
123  * @return new instance of class AT_CellularSMS
124  */
125  virtual AT_CellularSMS *open_sms_impl(ATHandler &at);
126 
127  /** Create new instance of AT_CellularInformation or if overridden, modem specific implementation.
128  *
129  * @param at ATHandler reference for communication with the modem.
130  * @return new instance of class AT_CellularInformation
131  */
133 
134  virtual CellularContext *get_context_list() const;
135 
136  AT_CellularNetwork *_network;
137  AT_CellularSMS *_sms;
138  AT_CellularInformation *_information;
139  AT_CellularContext *_context_list;
140  int _default_timeout;
141  bool _modem_debug_on;
142  ATHandler *_at;
143 
144 protected:
145  virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx = NULL);
146  void send_disconnect_to_context(int cid);
147 
148 private:
149  void urc_nw_deact();
150  void urc_pdn_deact();
151 };
152 
153 } // namespace mbed
154 #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:50
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.
Callback< R()> callback(R(*func)()=0)
Create a callback class with type inferred from the arguments.
Definition: Callback.h:3848
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.
virtual nsapi_error_t release_at_handler(ATHandler *at_handler)
Releases the given at_handler.
Class CellularSMS.
Definition: CellularSMS.h:48
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:63
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.