ublox-cellular-base_PSM

Committer:
fahimalavi
Date:
Tue Jan 02 05:45:24 2018 +0000
Revision:
10:c4281fa79b8f
Parent:
4:2e640a101db1
Child:
11:57f64bc518c0
Changes required for R410M in cellular base

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
RobMeades 0:5cffef3371f6 137 protected:
RobMeades 0:5cffef3371f6 138
RobMeades 0:5cffef3371f6 139 #define OUTPUT_ENTER_KEY "\r"
RobMeades 0:5cffef3371f6 140
RobMeades 0:5cffef3371f6 141 #if MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_BUFFER_SIZE
RobMeades 0:5cffef3371f6 142 #define AT_PARSER_BUFFER_SIZE MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_BUFFER_SIZE
RobMeades 0:5cffef3371f6 143 #else
RobMeades 0:5cffef3371f6 144 #define AT_PARSER_BUFFER_SIZE 256
RobMeades 0:5cffef3371f6 145 #endif
RobMeades 0:5cffef3371f6 146
RobMeades 0:5cffef3371f6 147 #if MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_TIMEOUT
RobMeades 0:5cffef3371f6 148 #define AT_PARSER_TIMEOUT MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_TIMEOUT
RobMeades 0:5cffef3371f6 149 #else
RobMeades 0:5cffef3371f6 150 #define AT_PARSER_TIMEOUT 8*1000 // Milliseconds
RobMeades 0:5cffef3371f6 151 #endif
RobMeades 0:5cffef3371f6 152
RobMeades 0:5cffef3371f6 153 /** A string that would not normally be sent by the modem on the AT interface.
RobMeades 0:5cffef3371f6 154 */
RobMeades 0:5cffef3371f6 155 #define UNNATURAL_STRING "\x01"
RobMeades 0:5cffef3371f6 156
RobMeades 0:5cffef3371f6 157 /** Supported u-blox modem variants.
RobMeades 0:5cffef3371f6 158 */
RobMeades 0:5cffef3371f6 159 typedef enum {
RobMeades 0:5cffef3371f6 160 DEV_TYPE_NONE = 0,
RobMeades 0:5cffef3371f6 161 DEV_SARA_G35,
RobMeades 0:5cffef3371f6 162 DEV_LISA_U2,
RobMeades 0:5cffef3371f6 163 DEV_LISA_U2_03S,
RobMeades 0:5cffef3371f6 164 DEV_SARA_U2,
RobMeades 0:5cffef3371f6 165 DEV_LEON_G2,
RobMeades 0:5cffef3371f6 166 DEV_TOBY_L2,
RobMeades 0:5cffef3371f6 167 DEV_MPCI_L2
RobMeades 0:5cffef3371f6 168 } DeviceType;
RobMeades 0:5cffef3371f6 169
RobMeades 0:5cffef3371f6 170 /** Network registration status.
RobMeades 0:5cffef3371f6 171 * UBX-13001820 - AT Commands Example Application Note (Section 4.1.4.5).
RobMeades 0:5cffef3371f6 172 */
RobMeades 0:5cffef3371f6 173 typedef enum {
RobMeades 0:5cffef3371f6 174 GSM = 0,
RobMeades 0:5cffef3371f6 175 COMPACT_GSM = 1,
RobMeades 0:5cffef3371f6 176 UTRAN = 2,
RobMeades 0:5cffef3371f6 177 EDGE = 3,
RobMeades 0:5cffef3371f6 178 HSDPA = 4,
RobMeades 0:5cffef3371f6 179 HSUPA = 5,
RobMeades 0:5cffef3371f6 180 HSDPA_HSUPA = 6,
fahimalavi 10:c4281fa79b8f 181 LTE = 7,
fahimalavi 10:c4281fa79b8f 182 EC_GSM_IoT =8,
fahimalavi 10:c4281fa79b8f 183 E_UTRAN_NB_S1=9
RobMeades 0:5cffef3371f6 184 } RadioAccessNetworkType;
RobMeades 0:5cffef3371f6 185
RobMeades 0:5cffef3371f6 186 /** Info about the modem.
RobMeades 0:5cffef3371f6 187 */
RobMeades 0:5cffef3371f6 188 typedef struct {
RobMeades 0:5cffef3371f6 189 DeviceType dev;
RobMeades 0:5cffef3371f6 190 char iccid[20 + 1]; //!< Integrated Circuit Card ID.
RobMeades 0:5cffef3371f6 191 char imsi[15 + 1]; //!< International Mobile Station Identity.
RobMeades 0:5cffef3371f6 192 char imei[15 + 1]; //!< International Mobile Equipment Identity.
RobMeades 0:5cffef3371f6 193 char meid[18 + 1]; //!< Mobile Equipment IDentifier.
RobMeades 0:5cffef3371f6 194 volatile RadioAccessNetworkType rat; //!< Type of network (e.g. 2G, 3G, LTE).
RobMeades 0:5cffef3371f6 195 volatile NetworkRegistrationStatusCsd reg_status_csd; //!< Circuit switched attach status.
RobMeades 0:5cffef3371f6 196 volatile NetworkRegistrationStatusPsd reg_status_psd; //!< Packet switched attach status.
RobMeades 0:5cffef3371f6 197 volatile NetworkRegistrationStatusEps reg_status_eps; //!< Evolved Packet Switched (e.g. LTE) attach status.
RobMeades 0:5cffef3371f6 198 } DeviceInfo;
RobMeades 0:5cffef3371f6 199
RobMeades 0:5cffef3371f6 200 /* IMPORTANT: the variables below are available to
RobMeades 0:5cffef3371f6 201 * classes that inherit this in order to keep things
RobMeades 0:5cffef3371f6 202 * simple. However, ONLY this class should free
RobMeades 0:5cffef3371f6 203 * any of the pointers, or there will be havoc.
RobMeades 0:5cffef3371f6 204 */
RobMeades 0:5cffef3371f6 205
RobMeades 0:5cffef3371f6 206 /** Point to the instance of the AT parser in use.
RobMeades 0:5cffef3371f6 207 */
RobMeades 0:5cffef3371f6 208 ATCmdParser *_at;
RobMeades 0:5cffef3371f6 209
RobMeades 0:5cffef3371f6 210 /** The current AT parser timeout value.
RobMeades 0:5cffef3371f6 211 */
RobMeades 0:5cffef3371f6 212 int _at_timeout;
RobMeades 0:5cffef3371f6 213
RobMeades 0:5cffef3371f6 214 /** File handle used by the AT parser.
RobMeades 0:5cffef3371f6 215 */
RobMeades 0:5cffef3371f6 216 FileHandle *_fh;
RobMeades 0:5cffef3371f6 217
RobMeades 0:5cffef3371f6 218 /** The mutex resource.
RobMeades 0:5cffef3371f6 219 */
RobMeades 0:5cffef3371f6 220 Mutex _mtx;
RobMeades 0:5cffef3371f6 221
RobMeades 0:5cffef3371f6 222 /** General info about the modem as a device.
RobMeades 0:5cffef3371f6 223 */
RobMeades 0:5cffef3371f6 224 DeviceInfo _dev_info;
RobMeades 0:5cffef3371f6 225
RobMeades 0:5cffef3371f6 226 /** The SIM PIN to use.
RobMeades 0:5cffef3371f6 227 */
RobMeades 0:5cffef3371f6 228 const char *_pin;
RobMeades 0:5cffef3371f6 229
RobMeades 0:5cffef3371f6 230 /** Set to true to spit out debug traces.
RobMeades 0:5cffef3371f6 231 */
RobMeades 0:5cffef3371f6 232 bool _debug_trace_on;
rob.meades@u-blox.com 4:2e640a101db1 233
rob.meades@u-blox.com 4:2e640a101db1 234 /** The baud rate to the modem.
rob.meades@u-blox.com 4:2e640a101db1 235 */
rob.meades@u-blox.com 4:2e640a101db1 236 int _baud;
RobMeades 0:5cffef3371f6 237
RobMeades 0:5cffef3371f6 238 /** True if the modem is ready register to the network,
RobMeades 0:5cffef3371f6 239 * otherwise false.
RobMeades 0:5cffef3371f6 240 */
RobMeades 0:5cffef3371f6 241 bool _modem_initialised;
RobMeades 0:5cffef3371f6 242
RobMeades 0:5cffef3371f6 243 /** True it the SIM requires a PIN, otherwise false.
RobMeades 0:5cffef3371f6 244 */
RobMeades 0:5cffef3371f6 245 bool _sim_pin_check_enabled;
RobMeades 0:5cffef3371f6 246
RobMeades 0:5cffef3371f6 247 /** Sets the modem up for powering on
RobMeades 0:5cffef3371f6 248 *
RobMeades 0:5cffef3371f6 249 * modem_init() is equivalent to plugging in the device, e.g., attaching power and serial port.
RobMeades 0:5cffef3371f6 250 * Uses onboard_modem_api.h where the implementation of onboard_modem_api is provided by the target.
RobMeades 0:5cffef3371f6 251 */
RobMeades 0:5cffef3371f6 252 virtual void modem_init();
RobMeades 0:5cffef3371f6 253
RobMeades 0:5cffef3371f6 254 /** Sets the modem in unplugged state
RobMeades 0:5cffef3371f6 255 *
RobMeades 0:5cffef3371f6 256 * modem_deinit() will be equivalent to pulling the plug off of the device, i.e., detaching power
RobMeades 0:5cffef3371f6 257 * and serial port. This puts the modem in lowest power state.
RobMeades 0:5cffef3371f6 258 * Uses onboard_modem_api.h where the implementation of onboard_modem_api is provided by the target.
RobMeades 0:5cffef3371f6 259 */
RobMeades 0:5cffef3371f6 260 virtual void modem_deinit();
RobMeades 0:5cffef3371f6 261
RobMeades 0:5cffef3371f6 262 /** Powers up the modem
RobMeades 0:5cffef3371f6 263 *
RobMeades 0:5cffef3371f6 264 * modem_power_up() is equivalent to pressing the soft power button.
RobMeades 0:5cffef3371f6 265 * The driver may repeat this if the modem is not responsive to AT commands.
RobMeades 0:5cffef3371f6 266 * Uses onboard_modem_api.h where the implementation of onboard_modem_api is provided by the target.
RobMeades 0:5cffef3371f6 267 */
RobMeades 0:5cffef3371f6 268 virtual void modem_power_up();
RobMeades 0:5cffef3371f6 269
RobMeades 0:5cffef3371f6 270 /** Powers down the modem
RobMeades 0:5cffef3371f6 271 *
RobMeades 0:5cffef3371f6 272 * modem_power_down() is equivalent to turning off the modem by button press.
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_down();
RobMeades 0:5cffef3371f6 276
RobMeades 0:5cffef3371f6 277 /* Note: constructor and destructor protected so that this
RobMeades 0:5cffef3371f6 278 * class can only ever be inherited, never used directly.
RobMeades 0:5cffef3371f6 279 */
RobMeades 0:5cffef3371f6 280 UbloxCellularBase();
RobMeades 0:5cffef3371f6 281 ~UbloxCellularBase();
RobMeades 0:5cffef3371f6 282
RobMeades 0:5cffef3371f6 283 /** Initialise this class.
RobMeades 0:5cffef3371f6 284 *
RobMeades 0:5cffef3371f6 285 * @param tx the UART TX data pin to which the modem is attached.
RobMeades 0:5cffef3371f6 286 * @param rx the UART RX data pin to which the modem is attached.
RobMeades 0:5cffef3371f6 287 * @param baud the UART baud rate.
RobMeades 0:5cffef3371f6 288 * @param debug_on true to switch AT interface debug on, otherwise false.
RobMeades 0:5cffef3371f6 289 *
RobMeades 0:5cffef3371f6 290 * Note: it would be more natural to do this in the constructor
RobMeades 0:5cffef3371f6 291 * however, to avoid the diamond of death, this class is only
RobMeades 0:5cffef3371f6 292 * every inherited virtually. Classes that are inherited virtually
RobMeades 0:5cffef3371f6 293 * do not get passed parameters in their constructor and hence
RobMeades 0:5cffef3371f6 294 * classInit() must be called separately by the first one to wake
RobMeades 0:5cffef3371f6 295 * the beast.
RobMeades 0:5cffef3371f6 296 */
RobMeades 0:5cffef3371f6 297 void baseClassInit(PinName tx = MDMTXD,
RobMeades 0:5cffef3371f6 298 PinName rx = MDMRXD,
RobMeades 0:5cffef3371f6 299 int baud = MBED_CONF_UBLOX_CELL_BAUD_RATE,
RobMeades 0:5cffef3371f6 300 bool debug_on = false);
RobMeades 0:5cffef3371f6 301
RobMeades 0:5cffef3371f6 302 /** Set the AT parser timeout.
RobMeades 0:5cffef3371f6 303 */
RobMeades 0:5cffef3371f6 304 void at_set_timeout(int timeout);
RobMeades 0:5cffef3371f6 305
RobMeades 0:5cffef3371f6 306 /** Read up to size characters from buf
RobMeades 0:5cffef3371f6 307 * or until the character "end" is reached, overwriting
RobMeades 0:5cffef3371f6 308 * the newline with 0 and ensuring a terminator
RobMeades 0:5cffef3371f6 309 * in all cases.
RobMeades 0:5cffef3371f6 310 *
RobMeades 0:5cffef3371f6 311 * @param buf the buffer to write to.
RobMeades 0:5cffef3371f6 312 * @param size the size of the buffer.
RobMeades 0:5cffef3371f6 313 * @param end the character to stop at.
RobMeades 0:5cffef3371f6 314 * @return the number of characters read,
RobMeades 0:5cffef3371f6 315 * not including the terminator.
RobMeades 0:5cffef3371f6 316 */
RobMeades 0:5cffef3371f6 317 int read_at_to_char(char * buf, int size, char end);
RobMeades 0:5cffef3371f6 318
RobMeades 0:5cffef3371f6 319 /** Powers up the modem.
RobMeades 0:5cffef3371f6 320 *
RobMeades 0:5cffef3371f6 321 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 322 */
RobMeades 0:5cffef3371f6 323 bool power_up();
RobMeades 0:5cffef3371f6 324
RobMeades 0:5cffef3371f6 325 /** Power down the modem.
RobMeades 0:5cffef3371f6 326 */
RobMeades 0:5cffef3371f6 327 void power_down();
RobMeades 0:5cffef3371f6 328
RobMeades 0:5cffef3371f6 329 /** Lock a mutex when accessing the modem.
RobMeades 0:5cffef3371f6 330 */
RobMeades 0:5cffef3371f6 331 void lock(void) { _mtx.lock(); }
RobMeades 0:5cffef3371f6 332
RobMeades 0:5cffef3371f6 333 /** Helper to make sure that lock unlock pair is always balanced
RobMeades 0:5cffef3371f6 334 */
RobMeades 0:5cffef3371f6 335 #define LOCK() { lock()
RobMeades 0:5cffef3371f6 336
RobMeades 0:5cffef3371f6 337 /** Unlock the modem when done accessing it.
RobMeades 0:5cffef3371f6 338 */
RobMeades 0:5cffef3371f6 339 void unlock(void) { _mtx.unlock(); }
RobMeades 0:5cffef3371f6 340
RobMeades 0:5cffef3371f6 341 /** Helper to make sure that lock unlock pair is always balanced
RobMeades 0:5cffef3371f6 342 */
RobMeades 0:5cffef3371f6 343 #define UNLOCK() } unlock()
RobMeades 0:5cffef3371f6 344
RobMeades 0:5cffef3371f6 345 /** Set the device identity in _dev_info
RobMeades 0:5cffef3371f6 346 * based on the ATI string returned by
RobMeades 0:5cffef3371f6 347 * the module.
RobMeades 0:5cffef3371f6 348 *
RobMeades 0:5cffef3371f6 349 * @return true if dev is a known value,
RobMeades 0:5cffef3371f6 350 * otherwise false.
RobMeades 0:5cffef3371f6 351 */
RobMeades 0:5cffef3371f6 352 bool set_device_identity(DeviceType *dev);
RobMeades 0:5cffef3371f6 353
RobMeades 0:5cffef3371f6 354 /** Perform any modem initialisation that is
RobMeades 0:5cffef3371f6 355 * specialised by device type.
RobMeades 0:5cffef3371f6 356 *
RobMeades 0:5cffef3371f6 357 * @return true if successful, otherwise false.
RobMeades 0:5cffef3371f6 358 */
RobMeades 0:5cffef3371f6 359 bool device_init(DeviceType dev);
RobMeades 0:5cffef3371f6 360
RobMeades 0:5cffef3371f6 361 /** Set up the SIM.
RobMeades 0:5cffef3371f6 362 *
RobMeades 0:5cffef3371f6 363 * @return true if successful, otherwiss false.
RobMeades 0:5cffef3371f6 364 */
RobMeades 0:5cffef3371f6 365 bool initialise_sim_card();
RobMeades 0:5cffef3371f6 366
RobMeades 0:5cffef3371f6 367 private:
RobMeades 0:5cffef3371f6 368
RobMeades 0:5cffef3371f6 369 void set_nwk_reg_status_csd(int status);
RobMeades 0:5cffef3371f6 370 void set_nwk_reg_status_psd(int status);
RobMeades 0:5cffef3371f6 371 void set_nwk_reg_status_eps(int status);
RobMeades 0:5cffef3371f6 372 void set_rat(int AcTStatus);
RobMeades 0:5cffef3371f6 373 bool get_iccid();
RobMeades 0:5cffef3371f6 374 bool get_imsi();
RobMeades 0:5cffef3371f6 375 bool get_imei();
RobMeades 0:5cffef3371f6 376 bool get_meid();
RobMeades 0:5cffef3371f6 377 bool set_sms();
RobMeades 0:5cffef3371f6 378 void parser_abort_cb();
RobMeades 0:5cffef3371f6 379 void CMX_ERROR_URC();
RobMeades 0:5cffef3371f6 380 void CREG_URC();
RobMeades 0:5cffef3371f6 381 void CGREG_URC();
RobMeades 0:5cffef3371f6 382 void CEREG_URC();
RobMeades 0:5cffef3371f6 383 void UMWI_URC();
RobMeades 0:5cffef3371f6 384 };
RobMeades 0:5cffef3371f6 385
rob.meades@u-blox.com 1:5aaecf2572dc 386 #endif // _UBLOX_CELLULAR_BASE_
RobMeades 0:5cffef3371f6 387