ublox-cellular-base_PSM

Committer:
fahim alavi
Date:
Tue Jan 09 12:34:53 2018 +0500
Revision:
12:aa3cbc3f88c5
Parent:
11:57f64bc518c0
Child:
14:e420232ee4e7
Code convention applied

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobMeades 0:5cffef3371f6 1 /* Copyright (c) 2017 ARM Limited
RobMeades 0:5cffef3371f6 2 *
RobMeades 0:5cffef3371f6 3 * Licensed under the Apache License, Version 2.0 (the "License");
RobMeades 0:5cffef3371f6 4 * you may not use this file except in compliance with the License.
RobMeades 0:5cffef3371f6 5 * You may obtain a copy of the License at
RobMeades 0:5cffef3371f6 6 *
RobMeades 0:5cffef3371f6 7 * http://www.apache.org/licenses/LICENSE-2.0
RobMeades 0:5cffef3371f6 8 *
RobMeades 0:5cffef3371f6 9 * Unless required by applicable law or agreed to in writing, software
RobMeades 0:5cffef3371f6 10 * distributed under the License is distributed on an "AS IS" BASIS,
RobMeades 0:5cffef3371f6 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
RobMeades 0:5cffef3371f6 12 * See the License for the specific language governing permissions and
RobMeades 0:5cffef3371f6 13 * limitations under the License.
RobMeades 0:5cffef3371f6 14 */
RobMeades 0:5cffef3371f6 15
rob.meades@u-blox.com 1:5aaecf2572dc 16 #ifndef _UBLOX_CELLULAR_BASE_
rob.meades@u-blox.com 1:5aaecf2572dc 17 #define _UBLOX_CELLULAR_BASE_
RobMeades 0:5cffef3371f6 18
RobMeades 0:5cffef3371f6 19 #include "mbed.h"
RobMeades 0:5cffef3371f6 20 #include "ATCmdParser.h"
RobMeades 0:5cffef3371f6 21 #include "FileHandle.h"
RobMeades 0:5cffef3371f6 22
RobMeades 0:5cffef3371f6 23 /**********************************************************************
RobMeades 0:5cffef3371f6 24 * CLASSES
RobMeades 0:5cffef3371f6 25 **********************************************************************/
RobMeades 0:5cffef3371f6 26
RobMeades 0:5cffef3371f6 27 /** UbloxCellularBase class.
RobMeades 0:5cffef3371f6 28 *
RobMeades 0:5cffef3371f6 29 * This class provides all the base support for generic u-blox modems
RobMeades 0:5cffef3371f6 30 * on C030 and C027 boards: module identification, power-up, network
RobMeades 0:5cffef3371f6 31 * registration, etc.
RobMeades 0:5cffef3371f6 32 */
RobMeades 0:5cffef3371f6 33 class UbloxCellularBase {
RobMeades 0:5cffef3371f6 34
RobMeades 0:5cffef3371f6 35 public:
RobMeades 0:5cffef3371f6 36 /** Circuit Switched network registration status (CREG Usage).
RobMeades 0:5cffef3371f6 37 * UBX-13001820 - AT Commands Example Application Note (Section 7.10.3).
RobMeades 0:5cffef3371f6 38 */
RobMeades 0:5cffef3371f6 39 typedef enum {
RobMeades 0:5cffef3371f6 40 CSD_NOT_REGISTERED_NOT_SEARCHING = 0,
RobMeades 0:5cffef3371f6 41 CSD_REGISTERED = 1,
RobMeades 0:5cffef3371f6 42 CSD_NOT_REGISTERED_SEARCHING = 2,
RobMeades 0:5cffef3371f6 43 CSD_REGISTRATION_DENIED = 3,
RobMeades 0:5cffef3371f6 44 CSD_UNKNOWN_COVERAGE = 4,
RobMeades 0:5cffef3371f6 45 CSD_REGISTERED_ROAMING = 5,
RobMeades 0:5cffef3371f6 46 CSD_SMS_ONLY = 6,
RobMeades 0:5cffef3371f6 47 CSD_SMS_ONLY_ROAMING = 7,
RobMeades 0:5cffef3371f6 48 CSD_CSFB_NOT_PREFERRED = 9
RobMeades 0:5cffef3371f6 49 } NetworkRegistrationStatusCsd;
RobMeades 0:5cffef3371f6 50
RobMeades 0:5cffef3371f6 51 /** Packet Switched network registration status (CGREG Usage).
RobMeades 0:5cffef3371f6 52 * UBX-13001820 - AT Commands Example Application Note (Section 18.27.3).
RobMeades 0:5cffef3371f6 53 */
RobMeades 0:5cffef3371f6 54 typedef enum {
RobMeades 0:5cffef3371f6 55 PSD_NOT_REGISTERED_NOT_SEARCHING = 0,
RobMeades 0:5cffef3371f6 56 PSD_REGISTERED = 1,
RobMeades 0:5cffef3371f6 57 PSD_NOT_REGISTERED_SEARCHING = 2,
RobMeades 0:5cffef3371f6 58 PSD_REGISTRATION_DENIED = 3,
RobMeades 0:5cffef3371f6 59 PSD_UNKNOWN_COVERAGE = 4,
RobMeades 0:5cffef3371f6 60 PSD_REGISTERED_ROAMING = 5,
RobMeades 0:5cffef3371f6 61 PSD_EMERGENCY_SERVICES_ONLY = 8
RobMeades 0:5cffef3371f6 62 } NetworkRegistrationStatusPsd;
RobMeades 0:5cffef3371f6 63
RobMeades 0:5cffef3371f6 64 /** EPS network registration status (CEREG Usage).
RobMeades 0:5cffef3371f6 65 * UBX-13001820 - AT Commands Example Application Note (Section 18.36.3).
RobMeades 0:5cffef3371f6 66 */
RobMeades 0:5cffef3371f6 67 typedef enum {
RobMeades 0:5cffef3371f6 68 EPS_NOT_REGISTERED_NOT_SEARCHING = 0,
RobMeades 0:5cffef3371f6 69 EPS_REGISTERED = 1,
RobMeades 0:5cffef3371f6 70 EPS_NOT_REGISTERED_SEARCHING = 2,
RobMeades 0:5cffef3371f6 71 EPS_REGISTRATION_DENIED = 3,
RobMeades 0:5cffef3371f6 72 EPS_UNKNOWN_COVERAGE = 4,
RobMeades 0:5cffef3371f6 73 EPS_REGISTERED_ROAMING = 5,
RobMeades 0:5cffef3371f6 74 EPS_EMERGENCY_SERVICES_ONLY = 8
RobMeades 0:5cffef3371f6 75 } NetworkRegistrationStatusEps;
RobMeades 0:5cffef3371f6 76
RobMeades 0:5cffef3371f6 77 /** Initialise the modem, ready for use.
RobMeades 0:5cffef3371f6 78 *
RobMeades 0:5cffef3371f6 79 * @param pin PIN for the SIM card.
RobMeades 0:5cffef3371f6 80 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 81 */
RobMeades 0:5cffef3371f6 82 bool init(const char *pin = 0);
RobMeades 0:5cffef3371f6 83
RobMeades 0:5cffef3371f6 84 /** Perform registration with the network.
RobMeades 0:5cffef3371f6 85 *
RobMeades 0:5cffef3371f6 86 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 87 */
RobMeades 0:5cffef3371f6 88 bool nwk_registration();
RobMeades 0:5cffef3371f6 89
RobMeades 0:5cffef3371f6 90 /** True if the modem is registered for circuit
RobMeades 0:5cffef3371f6 91 * switched data, otherwise false.
RobMeades 0:5cffef3371f6 92 */
RobMeades 0:5cffef3371f6 93 bool is_registered_csd();
RobMeades 0:5cffef3371f6 94
RobMeades 0:5cffef3371f6 95 /** True if the modem is registered for packet
RobMeades 0:5cffef3371f6 96 * switched data, otherwise false.
RobMeades 0:5cffef3371f6 97 */
RobMeades 0:5cffef3371f6 98 bool is_registered_psd();
RobMeades 0:5cffef3371f6 99
RobMeades 0:5cffef3371f6 100 /** True if the modem is registered for enhanced
RobMeades 0:5cffef3371f6 101 * packet switched data (i.e. LTE and beyond),
RobMeades 0:5cffef3371f6 102 * otherwise false.
RobMeades 0:5cffef3371f6 103 */
RobMeades 0:5cffef3371f6 104 bool is_registered_eps();
RobMeades 0:5cffef3371f6 105
RobMeades 0:5cffef3371f6 106 /** Perform deregistration from the network.
RobMeades 0:5cffef3371f6 107 *
RobMeades 0:5cffef3371f6 108 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 109 */
RobMeades 0:5cffef3371f6 110 bool nwk_deregistration();
RobMeades 0:5cffef3371f6 111
RobMeades 0:5cffef3371f6 112 /** Put the modem into its lowest power state.
RobMeades 0:5cffef3371f6 113 */
RobMeades 0:5cffef3371f6 114 void deinit();
RobMeades 0:5cffef3371f6 115
RobMeades 0:5cffef3371f6 116 /** Set the PIN code for the SIM card.
RobMeades 0:5cffef3371f6 117 *
RobMeades 0:5cffef3371f6 118 * @param pin PIN for the SIM card.
RobMeades 0:5cffef3371f6 119 */
RobMeades 0:5cffef3371f6 120 void set_pin(const char *pin);
RobMeades 0:5cffef3371f6 121
RobMeades 0:5cffef3371f6 122 /** Enable or disable SIM pin checking.
RobMeades 0:5cffef3371f6 123 *
RobMeades 0:5cffef3371f6 124 * @param enableNotDisable true if SIM PIN checking is to be enabled,
RobMeades 0:5cffef3371f6 125 * otherwise false.
RobMeades 0:5cffef3371f6 126 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 127 */
RobMeades 0:5cffef3371f6 128 bool sim_pin_check_enable(bool enableNotDisable);
RobMeades 0:5cffef3371f6 129
RobMeades 0:5cffef3371f6 130 /** Change the SIM pin.
RobMeades 0:5cffef3371f6 131 *
RobMeades 0:5cffef3371f6 132 * @param new_pin the new PIN to use.
RobMeades 0:5cffef3371f6 133 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 134 */
RobMeades 0:5cffef3371f6 135 bool change_sim_pin(const char *new_pin);
RobMeades 0:5cffef3371f6 136
fahim alavi 11:57f64bc518c0 137 /** Get the IMEI.
fahim alavi 11:57f64bc518c0 138 *
fahim alavi 11:57f64bc518c0 139 * @return true if successful, otherwise false.
fahim alavi 11:57f64bc518c0 140 */
fahim alavi 12:aa3cbc3f88c5 141 bool get_imei(char *imei_to_send, int size);
fahim alavi 11:57f64bc518c0 142
RobMeades 0:5cffef3371f6 143 protected:
RobMeades 0:5cffef3371f6 144
RobMeades 0:5cffef3371f6 145 #define OUTPUT_ENTER_KEY "\r"
RobMeades 0:5cffef3371f6 146
RobMeades 0:5cffef3371f6 147 #if MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_BUFFER_SIZE
RobMeades 0:5cffef3371f6 148 #define AT_PARSER_BUFFER_SIZE MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_BUFFER_SIZE
RobMeades 0:5cffef3371f6 149 #else
RobMeades 0:5cffef3371f6 150 #define AT_PARSER_BUFFER_SIZE 256
RobMeades 0:5cffef3371f6 151 #endif
RobMeades 0:5cffef3371f6 152
RobMeades 0:5cffef3371f6 153 #if MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_TIMEOUT
RobMeades 0:5cffef3371f6 154 #define AT_PARSER_TIMEOUT MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_TIMEOUT
RobMeades 0:5cffef3371f6 155 #else
RobMeades 0:5cffef3371f6 156 #define AT_PARSER_TIMEOUT 8*1000 // Milliseconds
RobMeades 0:5cffef3371f6 157 #endif
RobMeades 0:5cffef3371f6 158
RobMeades 0:5cffef3371f6 159 /** A string that would not normally be sent by the modem on the AT interface.
RobMeades 0:5cffef3371f6 160 */
RobMeades 0:5cffef3371f6 161 #define UNNATURAL_STRING "\x01"
RobMeades 0:5cffef3371f6 162
RobMeades 0:5cffef3371f6 163 /** Supported u-blox modem variants.
RobMeades 0:5cffef3371f6 164 */
RobMeades 0:5cffef3371f6 165 typedef enum {
RobMeades 0:5cffef3371f6 166 DEV_TYPE_NONE = 0,
RobMeades 0:5cffef3371f6 167 DEV_SARA_G35,
RobMeades 0:5cffef3371f6 168 DEV_LISA_U2,
RobMeades 0:5cffef3371f6 169 DEV_LISA_U2_03S,
RobMeades 0:5cffef3371f6 170 DEV_SARA_U2,
fahim alavi 11:57f64bc518c0 171 DEV_SARA_R4,
RobMeades 0:5cffef3371f6 172 DEV_LEON_G2,
RobMeades 0:5cffef3371f6 173 DEV_TOBY_L2,
RobMeades 0:5cffef3371f6 174 DEV_MPCI_L2
RobMeades 0:5cffef3371f6 175 } DeviceType;
RobMeades 0:5cffef3371f6 176
RobMeades 0:5cffef3371f6 177 /** Network registration status.
RobMeades 0:5cffef3371f6 178 * UBX-13001820 - AT Commands Example Application Note (Section 4.1.4.5).
RobMeades 0:5cffef3371f6 179 */
RobMeades 0:5cffef3371f6 180 typedef enum {
RobMeades 0:5cffef3371f6 181 GSM = 0,
RobMeades 0:5cffef3371f6 182 COMPACT_GSM = 1,
RobMeades 0:5cffef3371f6 183 UTRAN = 2,
RobMeades 0:5cffef3371f6 184 EDGE = 3,
RobMeades 0:5cffef3371f6 185 HSDPA = 4,
RobMeades 0:5cffef3371f6 186 HSUPA = 5,
RobMeades 0:5cffef3371f6 187 HSDPA_HSUPA = 6,
fahimalavi 10:c4281fa79b8f 188 LTE = 7,
fahim alavi 12:aa3cbc3f88c5 189 EC_GSM_IoT = 8,
fahim alavi 12:aa3cbc3f88c5 190 E_UTRAN_NB_S1 = 9
RobMeades 0:5cffef3371f6 191 } RadioAccessNetworkType;
RobMeades 0:5cffef3371f6 192
RobMeades 0:5cffef3371f6 193 /** Info about the modem.
RobMeades 0:5cffef3371f6 194 */
RobMeades 0:5cffef3371f6 195 typedef struct {
RobMeades 0:5cffef3371f6 196 DeviceType dev;
RobMeades 0:5cffef3371f6 197 char iccid[20 + 1]; //!< Integrated Circuit Card ID.
RobMeades 0:5cffef3371f6 198 char imsi[15 + 1]; //!< International Mobile Station Identity.
RobMeades 0:5cffef3371f6 199 char imei[15 + 1]; //!< International Mobile Equipment Identity.
RobMeades 0:5cffef3371f6 200 char meid[18 + 1]; //!< Mobile Equipment IDentifier.
RobMeades 0:5cffef3371f6 201 volatile RadioAccessNetworkType rat; //!< Type of network (e.g. 2G, 3G, LTE).
RobMeades 0:5cffef3371f6 202 volatile NetworkRegistrationStatusCsd reg_status_csd; //!< Circuit switched attach status.
RobMeades 0:5cffef3371f6 203 volatile NetworkRegistrationStatusPsd reg_status_psd; //!< Packet switched attach status.
RobMeades 0:5cffef3371f6 204 volatile NetworkRegistrationStatusEps reg_status_eps; //!< Evolved Packet Switched (e.g. LTE) attach status.
RobMeades 0:5cffef3371f6 205 } DeviceInfo;
RobMeades 0:5cffef3371f6 206
RobMeades 0:5cffef3371f6 207 /* IMPORTANT: the variables below are available to
RobMeades 0:5cffef3371f6 208 * classes that inherit this in order to keep things
RobMeades 0:5cffef3371f6 209 * simple. However, ONLY this class should free
RobMeades 0:5cffef3371f6 210 * any of the pointers, or there will be havoc.
RobMeades 0:5cffef3371f6 211 */
RobMeades 0:5cffef3371f6 212
RobMeades 0:5cffef3371f6 213 /** Point to the instance of the AT parser in use.
RobMeades 0:5cffef3371f6 214 */
RobMeades 0:5cffef3371f6 215 ATCmdParser *_at;
RobMeades 0:5cffef3371f6 216
RobMeades 0:5cffef3371f6 217 /** The current AT parser timeout value.
RobMeades 0:5cffef3371f6 218 */
RobMeades 0:5cffef3371f6 219 int _at_timeout;
RobMeades 0:5cffef3371f6 220
RobMeades 0:5cffef3371f6 221 /** File handle used by the AT parser.
RobMeades 0:5cffef3371f6 222 */
RobMeades 0:5cffef3371f6 223 FileHandle *_fh;
RobMeades 0:5cffef3371f6 224
RobMeades 0:5cffef3371f6 225 /** The mutex resource.
RobMeades 0:5cffef3371f6 226 */
RobMeades 0:5cffef3371f6 227 Mutex _mtx;
RobMeades 0:5cffef3371f6 228
RobMeades 0:5cffef3371f6 229 /** General info about the modem as a device.
RobMeades 0:5cffef3371f6 230 */
RobMeades 0:5cffef3371f6 231 DeviceInfo _dev_info;
RobMeades 0:5cffef3371f6 232
RobMeades 0:5cffef3371f6 233 /** The SIM PIN to use.
RobMeades 0:5cffef3371f6 234 */
RobMeades 0:5cffef3371f6 235 const char *_pin;
RobMeades 0:5cffef3371f6 236
RobMeades 0:5cffef3371f6 237 /** Set to true to spit out debug traces.
RobMeades 0:5cffef3371f6 238 */
RobMeades 0:5cffef3371f6 239 bool _debug_trace_on;
rob.meades@u-blox.com 4:2e640a101db1 240
rob.meades@u-blox.com 4:2e640a101db1 241 /** The baud rate to the modem.
rob.meades@u-blox.com 4:2e640a101db1 242 */
rob.meades@u-blox.com 4:2e640a101db1 243 int _baud;
RobMeades 0:5cffef3371f6 244
RobMeades 0:5cffef3371f6 245 /** True if the modem is ready register to the network,
RobMeades 0:5cffef3371f6 246 * otherwise false.
RobMeades 0:5cffef3371f6 247 */
RobMeades 0:5cffef3371f6 248 bool _modem_initialised;
RobMeades 0:5cffef3371f6 249
RobMeades 0:5cffef3371f6 250 /** True it the SIM requires a PIN, otherwise false.
RobMeades 0:5cffef3371f6 251 */
RobMeades 0:5cffef3371f6 252 bool _sim_pin_check_enabled;
RobMeades 0:5cffef3371f6 253
RobMeades 0:5cffef3371f6 254 /** Sets the modem up for powering on
RobMeades 0:5cffef3371f6 255 *
RobMeades 0:5cffef3371f6 256 * modem_init() is equivalent to plugging in the device, e.g., attaching power and serial port.
RobMeades 0:5cffef3371f6 257 * Uses onboard_modem_api.h where the implementation of onboard_modem_api is provided by the target.
RobMeades 0:5cffef3371f6 258 */
RobMeades 0:5cffef3371f6 259 virtual void modem_init();
RobMeades 0:5cffef3371f6 260
RobMeades 0:5cffef3371f6 261 /** Sets the modem in unplugged state
RobMeades 0:5cffef3371f6 262 *
RobMeades 0:5cffef3371f6 263 * modem_deinit() will be equivalent to pulling the plug off of the device, i.e., detaching power
RobMeades 0:5cffef3371f6 264 * and serial port. This puts the modem in lowest power state.
RobMeades 0:5cffef3371f6 265 * Uses onboard_modem_api.h where the implementation of onboard_modem_api is provided by the target.
RobMeades 0:5cffef3371f6 266 */
RobMeades 0:5cffef3371f6 267 virtual void modem_deinit();
RobMeades 0:5cffef3371f6 268
RobMeades 0:5cffef3371f6 269 /** Powers up the modem
RobMeades 0:5cffef3371f6 270 *
RobMeades 0:5cffef3371f6 271 * modem_power_up() is equivalent to pressing the soft power button.
RobMeades 0:5cffef3371f6 272 * The driver may repeat this if the modem is not responsive to AT commands.
RobMeades 0:5cffef3371f6 273 * Uses onboard_modem_api.h where the implementation of onboard_modem_api is provided by the target.
RobMeades 0:5cffef3371f6 274 */
RobMeades 0:5cffef3371f6 275 virtual void modem_power_up();
RobMeades 0:5cffef3371f6 276
RobMeades 0:5cffef3371f6 277 /** Powers down the modem
RobMeades 0:5cffef3371f6 278 *
RobMeades 0:5cffef3371f6 279 * modem_power_down() is equivalent to turning off the modem by button press.
RobMeades 0:5cffef3371f6 280 * Uses onboard_modem_api.h where the implementation of onboard_modem_api is provided by the target.
RobMeades 0:5cffef3371f6 281 */
RobMeades 0:5cffef3371f6 282 virtual void modem_power_down();
RobMeades 0:5cffef3371f6 283
RobMeades 0:5cffef3371f6 284 /* Note: constructor and destructor protected so that this
RobMeades 0:5cffef3371f6 285 * class can only ever be inherited, never used directly.
RobMeades 0:5cffef3371f6 286 */
RobMeades 0:5cffef3371f6 287 UbloxCellularBase();
RobMeades 0:5cffef3371f6 288 ~UbloxCellularBase();
RobMeades 0:5cffef3371f6 289
RobMeades 0:5cffef3371f6 290 /** Initialise this class.
RobMeades 0:5cffef3371f6 291 *
RobMeades 0:5cffef3371f6 292 * @param tx the UART TX data pin to which the modem is attached.
RobMeades 0:5cffef3371f6 293 * @param rx the UART RX data pin to which the modem is attached.
RobMeades 0:5cffef3371f6 294 * @param baud the UART baud rate.
RobMeades 0:5cffef3371f6 295 * @param debug_on true to switch AT interface debug on, otherwise false.
RobMeades 0:5cffef3371f6 296 *
RobMeades 0:5cffef3371f6 297 * Note: it would be more natural to do this in the constructor
RobMeades 0:5cffef3371f6 298 * however, to avoid the diamond of death, this class is only
RobMeades 0:5cffef3371f6 299 * every inherited virtually. Classes that are inherited virtually
RobMeades 0:5cffef3371f6 300 * do not get passed parameters in their constructor and hence
RobMeades 0:5cffef3371f6 301 * classInit() must be called separately by the first one to wake
RobMeades 0:5cffef3371f6 302 * the beast.
RobMeades 0:5cffef3371f6 303 */
RobMeades 0:5cffef3371f6 304 void baseClassInit(PinName tx = MDMTXD,
RobMeades 0:5cffef3371f6 305 PinName rx = MDMRXD,
RobMeades 0:5cffef3371f6 306 int baud = MBED_CONF_UBLOX_CELL_BAUD_RATE,
RobMeades 0:5cffef3371f6 307 bool debug_on = false);
RobMeades 0:5cffef3371f6 308
RobMeades 0:5cffef3371f6 309 /** Set the AT parser timeout.
RobMeades 0:5cffef3371f6 310 */
RobMeades 0:5cffef3371f6 311 void at_set_timeout(int timeout);
RobMeades 0:5cffef3371f6 312
RobMeades 0:5cffef3371f6 313 /** Read up to size characters from buf
RobMeades 0:5cffef3371f6 314 * or until the character "end" is reached, overwriting
RobMeades 0:5cffef3371f6 315 * the newline with 0 and ensuring a terminator
RobMeades 0:5cffef3371f6 316 * in all cases.
RobMeades 0:5cffef3371f6 317 *
RobMeades 0:5cffef3371f6 318 * @param buf the buffer to write to.
RobMeades 0:5cffef3371f6 319 * @param size the size of the buffer.
RobMeades 0:5cffef3371f6 320 * @param end the character to stop at.
RobMeades 0:5cffef3371f6 321 * @return the number of characters read,
RobMeades 0:5cffef3371f6 322 * not including the terminator.
RobMeades 0:5cffef3371f6 323 */
RobMeades 0:5cffef3371f6 324 int read_at_to_char(char * buf, int size, char end);
RobMeades 0:5cffef3371f6 325
RobMeades 0:5cffef3371f6 326 /** Powers up the modem.
RobMeades 0:5cffef3371f6 327 *
RobMeades 0:5cffef3371f6 328 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 329 */
RobMeades 0:5cffef3371f6 330 bool power_up();
RobMeades 0:5cffef3371f6 331
RobMeades 0:5cffef3371f6 332 /** Power down the modem.
RobMeades 0:5cffef3371f6 333 */
RobMeades 0:5cffef3371f6 334 void power_down();
RobMeades 0:5cffef3371f6 335
RobMeades 0:5cffef3371f6 336 /** Lock a mutex when accessing the modem.
RobMeades 0:5cffef3371f6 337 */
RobMeades 0:5cffef3371f6 338 void lock(void) { _mtx.lock(); }
RobMeades 0:5cffef3371f6 339
RobMeades 0:5cffef3371f6 340 /** Helper to make sure that lock unlock pair is always balanced
RobMeades 0:5cffef3371f6 341 */
RobMeades 0:5cffef3371f6 342 #define LOCK() { lock()
RobMeades 0:5cffef3371f6 343
RobMeades 0:5cffef3371f6 344 /** Unlock the modem when done accessing it.
RobMeades 0:5cffef3371f6 345 */
RobMeades 0:5cffef3371f6 346 void unlock(void) { _mtx.unlock(); }
RobMeades 0:5cffef3371f6 347
RobMeades 0:5cffef3371f6 348 /** Helper to make sure that lock unlock pair is always balanced
RobMeades 0:5cffef3371f6 349 */
RobMeades 0:5cffef3371f6 350 #define UNLOCK() } unlock()
RobMeades 0:5cffef3371f6 351
RobMeades 0:5cffef3371f6 352 /** Set the device identity in _dev_info
RobMeades 0:5cffef3371f6 353 * based on the ATI string returned by
RobMeades 0:5cffef3371f6 354 * the module.
RobMeades 0:5cffef3371f6 355 *
RobMeades 0:5cffef3371f6 356 * @return true if dev is a known value,
RobMeades 0:5cffef3371f6 357 * otherwise false.
RobMeades 0:5cffef3371f6 358 */
RobMeades 0:5cffef3371f6 359 bool set_device_identity(DeviceType *dev);
RobMeades 0:5cffef3371f6 360
RobMeades 0:5cffef3371f6 361 /** Perform any modem initialisation that is
RobMeades 0:5cffef3371f6 362 * specialised by device type.
RobMeades 0:5cffef3371f6 363 *
RobMeades 0:5cffef3371f6 364 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 365 */
RobMeades 0:5cffef3371f6 366 bool device_init(DeviceType dev);
RobMeades 0:5cffef3371f6 367
RobMeades 0:5cffef3371f6 368 /** Set up the SIM.
RobMeades 0:5cffef3371f6 369 *
RobMeades 0:5cffef3371f6 370 * @return true if successful, otherwiss false.
RobMeades 0:5cffef3371f6 371 */
RobMeades 0:5cffef3371f6 372 bool initialise_sim_card();
RobMeades 0:5cffef3371f6 373
RobMeades 0:5cffef3371f6 374 private:
RobMeades 0:5cffef3371f6 375
RobMeades 0:5cffef3371f6 376 void set_nwk_reg_status_csd(int status);
RobMeades 0:5cffef3371f6 377 void set_nwk_reg_status_psd(int status);
RobMeades 0:5cffef3371f6 378 void set_nwk_reg_status_eps(int status);
RobMeades 0:5cffef3371f6 379 void set_rat(int AcTStatus);
RobMeades 0:5cffef3371f6 380 bool get_iccid();
RobMeades 0:5cffef3371f6 381 bool get_imsi();
RobMeades 0:5cffef3371f6 382 bool get_imei();
RobMeades 0:5cffef3371f6 383 bool get_meid();
RobMeades 0:5cffef3371f6 384 bool set_sms();
RobMeades 0:5cffef3371f6 385 void parser_abort_cb();
RobMeades 0:5cffef3371f6 386 void CMX_ERROR_URC();
RobMeades 0:5cffef3371f6 387 void CREG_URC();
RobMeades 0:5cffef3371f6 388 void CGREG_URC();
RobMeades 0:5cffef3371f6 389 void CEREG_URC();
RobMeades 0:5cffef3371f6 390 void UMWI_URC();
RobMeades 0:5cffef3371f6 391 };
RobMeades 0:5cffef3371f6 392
rob.meades@u-blox.com 1:5aaecf2572dc 393 #endif // _UBLOX_CELLULAR_BASE_
RobMeades 0:5cffef3371f6 394