Curt Black / ublox-at-cellular-interface

Dependents:  

Fork of ublox-at-cellular-interface by u-blox

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UbloxATCellularInterface.h Source File

UbloxATCellularInterface.h

00001 /* Copyright (c) 2017 ARM Limited
00002  *
00003  * Licensed under the Apache License, Version 2.0 (the "License");
00004  * you may not use this file except in compliance with the License.
00005  * You may obtain a copy of the License at
00006  *
00007  *     http://www.apache.org/licenses/LICENSE-2.0
00008  *
00009  * Unless required by applicable law or agreed to in writing, software
00010  * distributed under the License is distributed on an "AS IS" BASIS,
00011  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012  * See the License for the specific language governing permissions and
00013  * limitations under the License.
00014  */
00015 
00016 #ifndef _UBLOX_AT_CELLULAR_INTERFACE_
00017 #define _UBLOX_AT_CELLULAR_INTERFACE_
00018 
00019 #include "UbloxCellularBase.h"
00020 #include "CellularBase.h"
00021 #include "NetworkStack.h"
00022 
00023 #define USE_HEX_MODE_USORx   // Workaround for SARA_R4-1266 errata - use hex mode for socket reads
00024 
00025 /** UbloxATCellularInterface class.
00026  *
00027  *  This uses the cellular-tuned IP stack that
00028  *  is on-board the cellular modem instead of the
00029  *  LWIP stack on the mbed MCU.
00030  *
00031  *  There are three advantages to using this mechanism:
00032  *
00033  *  1.  Since the modem interface remains in AT mode
00034  *      throughout, it is possible to continue using
00035  *      any AT commands (e.g. send SMS, use the module's
00036  *      file system, etc.) while the connection is up.
00037  *
00038  *  2.  The UbloxATCellularInterfaceExt class can
00039  *      be used to perform very simple HTTP and FTP
00040  *      operations using the modem's on-board clients.
00041  *
00042  *  3.  LWIP is not required (and hence RAM is saved).
00043  *
00044  *  The disadvantage is that some additional parsing
00045  *  (at the AT interface) has to go on in order to exchange
00046  *  IP packets, so this is less efficient under heavy loads.
00047  *  Also TCP Server and getting/setting of socket options is
00048  *  currently not supported.
00049  */
00050 
00051 // Forward declaration
00052 class NetworkStack;
00053 
00054 /*
00055  * NOTE: order is important in the inheritance below!  PAL takes this class
00056  * and casts it to CellularInterface and so CellularInterface has to be first
00057  * in the last for that to work.
00058  */
00059 
00060 /** UbloxATCellularInterface class.
00061  *
00062  *  This class implements the network stack interface into the cellular
00063  *  modems on the C030 and C027 boards for 2G/3G/4G modules using
00064  *  the IP stack running on the cellular module.
00065  */
00066 class UbloxATCellularInterface : public CellularBase, public NetworkStack, virtual public UbloxCellularBase  {
00067 
00068 public:
00069     /** Constructor.
00070      *
00071      * @param tx       the UART TX data pin to which the modem is attached.
00072      * @param rx       the UART RX data pin to which the modem is attached.
00073      * @param baud     the UART baud rate.
00074      * @param debug_on true to switch AT interface debug on, otherwise false.
00075      */
00076      UbloxATCellularInterface(PinName tx = MDMTXD,
00077                               PinName rx = MDMRXD,
00078                               int baud = MBED_CONF_UBLOX_CELL_BAUD_RATE,
00079                               bool debug_on = false);
00080 
00081      /* Destructor.
00082       */
00083      virtual ~UbloxATCellularInterface();
00084 
00085     /** The amount of extra space needed in terms of AT interface
00086      * characters to get a chunk of user data (i.e. one UDP packet
00087      * or a portion of a TCP packet) across the AT interface.
00088      */
00089     #define AT_PACKET_OVERHEAD 77
00090 
00091     /** The profile to use (on board the modem).
00092      */
00093     #define PROFILE "0"
00094 
00095     /** Translates a host name to an IP address with specific IP version.
00096      *
00097      *  The host name may be either a domain name or an IP address. If the
00098      *  host name is an IP address, no network transactions will be performed.
00099      *
00100      *  If no stack-specific DNS resolution is provided, the host name
00101      *  will be resolved using a UDP socket on the stack.
00102      *
00103      *  @param host     Host name to resolve.
00104      *  @param address  Destination for the host SocketAddress.
00105      *  @param version  IP version of address to resolve, NSAPI_UNSPEC indicates
00106      *                  version is chosen by the stack (defaults to NSAPI_UNSPEC).
00107      *  @return         0 on success, negative error code on failure.
00108      */
00109     virtual nsapi_error_t gethostbyname(const char *host,
00110                                         SocketAddress *address,
00111                                         nsapi_version_t version = NSAPI_UNSPEC);
00112 
00113     /** Set the authentication scheme.
00114      *
00115      *  @param auth      The authentication scheme, chose from
00116      *                   NSAPI_SECURITY_NONE, NSAPI_SECURITY_PAP,
00117      *                   NSAPI_SECURITY_CHAP or NSAPI_SECURITY_UNKNOWN;
00118      *                   use NSAPI_SECURITY_UNKNOWN to try all of none,
00119      *                   PAP and CHAP.
00120      */
00121     virtual void set_authentication(nsapi_security_t auth);
00122 
00123     /** Set the cellular network credentials.
00124      *
00125      *  Please check documentation of connect() for default behaviour of APN settings.
00126      *
00127      *  @param apn      Access point name.
00128      *  @param uname    Optionally, user name.
00129      *  @param pwd      Optionally, password.
00130      */
00131     virtual void set_credentials(const char *apn, const char *uname = 0,
00132                                  const char *pwd = 0);
00133 
00134     /** Set the PIN code for the SIM card.
00135      *
00136      *  @param sim_pin      PIN for the SIM card.
00137      */
00138     virtual void set_sim_pin(const char *sim_pin);
00139 
00140     /** Connect to the cellular network and start the interface.
00141      *
00142      *  Attempts to connect to a cellular network.  Note: if init() has
00143      *  not been called beforehand, connect() will call it first.
00144      *
00145      *  @param sim_pin     PIN for the SIM card.
00146      *  @param apn         Optionally, access point name.
00147      *  @param uname       Optionally, user name.
00148      *  @param pwd         Optionally, password.
00149      *  @return            NSAPI_ERROR_OK on success, or negative error code on failure.
00150      */
00151     virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0,
00152                                   const char *uname = 0, const char *pwd = 0);
00153 
00154     /** Attempt to connect to the cellular network.
00155      *
00156      *  Brings up the network interface. Connects to the cellular radio
00157      *  network and then brings up IP stack on the cellular modem to be used
00158      *  indirectly via AT commands, rather than LWIP.  Note: if init() has
00159      *  not been called beforehand, connect() will call it first.
00160      *  NOTE: even a failed attempt to connect will cause the modem to remain
00161      *  powered up.  To power it down, call deinit().
00162      *
00163      *  For APN setup, default behaviour is to use 'internet' as APN string
00164      *  and assuming no authentication is required, i.e., user name and password
00165      *  are not set. Optionally, a database lookup can be requested by turning
00166      *  on the APN database lookup feature. The APN database is by no means
00167      *  exhaustive (feel free to submit a pull request with additional values).
00168      *  It contains a short list of some public APNs with publicly available
00169      *  user names and passwords (if required) in some particular countries only.
00170      *  Lookup is done using IMSI (International mobile subscriber identifier).
00171      *
00172      *  The preferred method is to setup APN using 'set_credentials()' API.
00173      *
00174      *  If you find that the AT interface returns "CONNECT" but shortly afterwards
00175      *  drops the connection then 99% of the time this will be because the APN
00176      *  is incorrect.
00177      *
00178      *  @return            0 on success, negative error code on failure.
00179      */
00180     virtual nsapi_error_t connect();
00181 
00182     /** Attempt to disconnect from the network.
00183      *
00184      *  Brings down the network interface.
00185      *  Does not bring down the Radio network.
00186      *
00187      *  @return            0 on success, negative error code on failure.
00188      */
00189     virtual nsapi_error_t disconnect();
00190 
00191     /** Adds or removes a SIM facility lock.
00192      *
00193      * Can be used to enable or disable SIM PIN check at device startup.
00194      *
00195      * @param set          Can be set to true if the SIM PIN check is supposed
00196      *                     to be enabled and vice versa.
00197      * @param immediate    If true, change the SIM PIN now, else set a flag
00198      *                     and make the change only when connect() is called.
00199      *                     If this is true and init() has not been called previously,
00200      *                     it will be called first.
00201      * @param sim_pin      The current SIM PIN, must be a const.  If this is not
00202      *                     provided, the SIM PIN must have previously been set by a
00203      *                     call to set_sim_pin().
00204      * @return             0 on success, negative error code on failure.
00205      */
00206     nsapi_error_t set_sim_pin_check(bool set, bool immediate = false,
00207                                     const char *sim_pin = NULL);
00208 
00209     /** Change the PIN for the SIM card.
00210      *
00211      * Provide the new PIN for your SIM card with this API.  It is ONLY possible to
00212      * change the SIM PIN when SIM PIN checking is ENABLED.
00213      *
00214      * @param new_pin    New PIN to be used in string format, must be a const.
00215      * @param immediate  If true, change the SIM PIN now, else set a flag
00216      *                   and make the change only when connect() is called.
00217      *                   If this is true and init() has not been called previously,
00218      *                   it will be called first.
00219      * @param old_pin    Old PIN, must be a const.  If this is not provided, the SIM PIN
00220      *                   must have previously been set by a call to set_sim_pin().
00221      * @return           0 on success, negative error code on failure.
00222      */
00223     nsapi_error_t set_new_sim_pin(const char *new_pin, bool immediate = false,
00224                                   const char *old_pin = NULL);
00225 
00226     /** Check if the connection is currently established or not.
00227      *
00228      * @return          True if connected to a data network, otherwise false.
00229      */
00230     virtual bool is_connected();
00231 
00232     /** Get the local IP address
00233      *
00234      *  @return         Null-terminated representation of the local IP address
00235      *                  or null if no IP address has been received.
00236      */
00237     virtual const char *get_ip_address();
00238 
00239     /** Get the local network mask.
00240      *
00241      *  @return         Null-terminated representation of the local network mask
00242      *                  or null if no network mask has been received.
00243      */
00244     virtual const char *get_netmask();
00245 
00246     /** Get the local gateways.
00247      *
00248      *  @return         Null-terminated representation of the local gateway
00249      *                  or null if no network mask has been received.
00250      */
00251     virtual const char *get_gateway();
00252 
00253     /** Call back in case connection is lost.
00254      *
00255      * @param cb     The function to call.
00256      */
00257     void connection_status_cb(Callback<void(nsapi_error_t)> cb);
00258 
00259 protected:
00260 
00261     /** Socket "unused" value.
00262      */
00263     #define SOCKET_UNUSED -1
00264 
00265     /** Socket timeout value in milliseconds.
00266      * Note: the sockets layer above will retry the
00267      * call to the functions here when they return NSAPI_ERROR_WOULD_BLOCK
00268      * and the user has set a larger timeout or full blocking.
00269      */
00270     #define SOCKET_TIMEOUT 1000
00271 
00272     /** The maximum number of bytes in a packet that can be written
00273      * to the AT interface in one go.
00274      */
00275 #ifdef USE_HEX_MODE_USORx
00276     #define MAX_WRITE_SIZE 512
00277 #else
00278     #define MAX_WRITE_SIZE 1024
00279 #endif
00280 
00281 
00282     /** The maximum number of bytes in a packet that can be read from
00283      * from the AT interface in one go.
00284      */
00285 #ifdef USE_HEX_MODE_USORx
00286     #define MAX_READ_SIZE 512
00287 #else
00288     #define MAX_READ_SIZE 1024
00289 #endif
00290 
00291     /** Management structure for sockets.
00292      */
00293     typedef struct {
00294         int modem_handle;  //!< The modem's handle for the socket.
00295         volatile nsapi_size_t pending; //!< The number of received bytes pending.
00296         void (*callback)(void *); //!< A callback for events.
00297         void *data; //!< A data pointer that must be passed to the callback.
00298     } SockCtrl;
00299 
00300     /** Sockets storage.
00301      */
00302     SockCtrl _sockets[7];
00303 
00304     /** Storage for a single IP address.
00305      */
00306     char *_ip;
00307 
00308     /** The APN to use.
00309      */
00310     const char *_apn;
00311 
00312     /** The user name to use.
00313      */
00314     const char *_uname;
00315 
00316     /** The password to use.
00317      */
00318     const char *_pwd;
00319 
00320     /** The type of authentication to use.
00321      */
00322     nsapi_security_t _auth;
00323 
00324     /** Get the next set of credentials from the database.
00325      */
00326     virtual void get_next_credentials(const char ** config);
00327 
00328     /** Activate one of the on-board modem's connection profiles.
00329      *
00330      * @param apn      The APN to use.
00331      * @param username The user name to use.
00332      * @param password The password to use.
00333      * @param auth     The authentication method to use
00334      *                 (NSAPI_SECURITY_NONE, NSAPI_SECURITY_PAP,
00335      *                 NSAPI_SECURITY_CHAP or NSAPI_SECURITY_UNKNOWN).
00336      * @return         True if successful, otherwise false.
00337      */
00338     virtual bool activate_profile(const char* apn, const char* username,
00339                                   const char* password, nsapi_security_t auth);
00340 
00341     /** Activate a profile using the existing external connection.
00342      *
00343      * @return true if successful, otherwise false.
00344      */
00345     virtual bool activate_profile_reuse_external(void);
00346 
00347     /** Activate a profile based on connection ID.
00348      *
00349      * @param cid       The connection ID.
00350      * @param apn       The APN to use.
00351      * @param username  The user name to use.
00352      * @param password  The password to use.
00353      * @param auth      The authentication method to use.
00354      * @return          True if successful, otherwise false.
00355      */
00356     virtual bool activate_profile_by_cid(int cid, const char* apn, const char* username,
00357                                          const char* password, nsapi_security_t auth);
00358 
00359     /** Connect the on board IP stack of the modem.
00360      *
00361      * @return         True if successful, otherwise false.
00362      */
00363     virtual bool connect_modem_stack();
00364 
00365     /** Disconnect the on board IP stack of the modem.
00366      *
00367      * @return         True if successful, otherwise false.
00368      */
00369     virtual bool disconnect_modem_stack();
00370 
00371     /** Provide access to the NetworkStack object
00372      *
00373      *  @return        The underlying NetworkStack object.
00374      */
00375     virtual NetworkStack *get_stack();
00376 
00377 protected:
00378 
00379     /** Open a socket.
00380      *
00381      *  Creates a network socket and stores it in the specified handle.
00382      *  The handle must be passed to following calls on the socket.
00383      *
00384      *  @param handle   Destination for the handle to a newly created socket.
00385      *  @param proto    Protocol of socket to open, NSAPI_TCP or NSAPI_UDP.
00386      *  @return         0 on success, negative error code on failure.
00387      */
00388     virtual nsapi_error_t socket_open(nsapi_socket_t *handle,
00389                                       nsapi_protocol_t proto);
00390 
00391     /** Close a socket.
00392      *
00393      *  Closes any open connection and deallocates any memory associated
00394      *  with the socket.
00395      *
00396      *  @param handle   Socket handle.
00397      *  @return         0 on success, negative error code on failure.
00398      */
00399     virtual nsapi_error_t socket_close(nsapi_socket_t handle);
00400 
00401     /** Bind a specific port to a socket.
00402      *
00403      *  Binding a socket specifies port on which to receive
00404      *  data. The IP address is ignored.  Note that binding
00405      *  a socket involves closing it and reopening and so the
00406      *  bind operation should be carried out before any others.
00407      *
00408      *  @param handle   Socket handle.
00409      *  @param address  Local address to bind (of which only the port is used).
00410      *  @return         0 on success, negative error code on failure.
00411      */
00412     virtual nsapi_error_t socket_bind(nsapi_socket_t handle,
00413                                       const SocketAddress &address);
00414 
00415     /** Connects TCP socket to a remote host.
00416      *
00417      *  Initiates a connection to a remote server specified by the
00418      *  indicated address.
00419      *
00420      *  @param handle   Socket handle.
00421      *  @param address  The SocketAddress of the remote host.
00422      *  @return         0 on success, negative error code on failure.
00423      */
00424     virtual nsapi_error_t socket_connect(nsapi_socket_t handle,
00425                                          const SocketAddress &address);
00426 
00427     /** Send data over a TCP socket.
00428      *
00429      *  The socket must be connected to a remote host. Returns the number of
00430      *  bytes sent from the buffer.  This class sets no upper buffer limit on
00431      *  buffer size and the maximum packet size is not connected with the
00432      *  platform.buffered-serial-txbuf-size/platform.buffered-serial-rxbuf-size
00433      *  definitions.
00434      *
00435      *  @param handle   Socket handle.
00436      *  @param data     Buffer of data to send to the host.
00437      *  @param size     Size of the buffer in bytes.
00438      *  @return         Number of sent bytes on success, negative error
00439      *                  code on failure.
00440      */
00441     virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle,
00442                                               const void *data, nsapi_size_t size);
00443 
00444     /** Send a packet over a UDP socket.
00445      *
00446      *  Sends data to the specified address. Returns the number of bytes
00447      *  sent from the buffer.
00448      *
00449      *  PACKET SIZES: the maximum packet size that can be sent in a single
00450      *  UDP packet is limited by the configuration value
00451      *  platform.buffered-serial-txbuf-size (defaults to 256).
00452      *  The maximum UDP packet size is:
00453      *
00454      *  platform.buffered-serial-txbuf-size - AT_PACKET_OVERHEAD
00455      *
00456      *  ...with a limit of 1024 bytes (at the AT interface). So, to allow sending
00457      *  of a 1024 byte UDP packet, edit your mbed_app.json to add a target override
00458      *  setting platform.buffered-serial-txbuf-size to 1101.  However, for
00459      *  UDP packets, 508 bytes is considered a more realistic size, taking into
00460      *  account fragmentation sizes over the public internet, which leads to a
00461      *  platform.buffered-serial-txbuf-size/platform.buffered-serial-rxbuf-size
00462      *  setting of 585.
00463      *
00464      *  If size is larger than this limit, the data will be split across separate
00465      *  UDP packets.
00466      *
00467      *  @param handle   Socket handle.
00468      *  @param address  The SocketAddress of the remote host.
00469      *  @param data     Buffer of data to send to the host.
00470      *  @param size     Size of the buffer in bytes.
00471      *  @return         Number of sent bytes on success, negative error
00472      *                  code on failure.
00473      */
00474     virtual nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle,
00475                                                 const SocketAddress &address,
00476                                                 const void *data,
00477                                                 nsapi_size_t size);
00478 
00479     /** Receive data over a TCP socket.
00480      *
00481      *  The socket must be connected to a remote host. Returns the number of
00482      *  bytes received into the buffer.  This class sets no upper limit on the
00483      *  buffer size and the maximum packet size is not connected with the
00484      *  platform.buffered-serial-txbuf-size/platform.buffered-serial-rxbuf-size
00485      *  definitions.
00486      *
00487      *  @param handle   Socket handle.
00488      *  @param data     Destination buffer for data received from the host.
00489      *  @param size     Size of the buffer in bytes.
00490      *  @return         Number of received bytes on success, negative error
00491      *                  code on failure.
00492      */
00493     virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle,
00494                                               void *data, nsapi_size_t size);
00495 
00496     /** Receive a packet over a UDP socket.
00497      *
00498      *  Receives data and stores the source address in address if address
00499      *  is not NULL. Returns the number of bytes received into the buffer.
00500      *
00501      *  PACKET SIZES: the maximum packet size that can be retrieved in a
00502      *  single call to this method is limited by the configuration value
00503      *  platform.buffered-serial-rxbuf-size (default 256).  The maximum
00504      *  UDP packet size is:
00505      *
00506      *  platform.buffered-serial-rxbuf-size - AT_PACKET_OVERHEAD
00507      *
00508      *  ...with a limit of 1024 (at the AT interface). So to allow reception of a
00509      *  1024 byte UDP packet in a single call, edit your mbed_app.json to add a
00510      *  target override setting platform.buffered-serial-rxbuf-size to 1101.
00511      *
00512      *  If the received packet is larger than this limit, any remainder will
00513      *  be returned in subsequent calls to this method.  Once a single UDP
00514      *  packet has been received, this method will return.
00515      *
00516      *  @param handle   Socket handle.
00517      *  @param address  Destination for the source address or NULL.
00518      *  @param data     Destination buffer for data received from the host.
00519      *  @param size     Size of the buffer in bytes.
00520      *  @return         Number of received bytes on success, negative error
00521      *                  code on failure.
00522      */
00523     virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle,
00524                                                   SocketAddress *address,
00525                                                   void *data, nsapi_size_t size);
00526 
00527     /** Register a callback on state change of the socket.
00528      *
00529      *  The specified callback will be called on state changes such as when
00530      *  the socket can recv/send/accept successfully and on when an error
00531      *  occurs. The callback may also be called spuriously without reason.
00532      *
00533      *  The callback may be called in an interrupt context and should not
00534      *  perform expensive operations such as recv/send calls.
00535      *
00536      *  @param handle   Socket handle.
00537      *  @param callback Function to call on state change.
00538      *  @param data     Argument to pass to callback.
00539      */
00540     virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *),
00541                                void *data);
00542 
00543     /** Listen for connections on a TCP socket.
00544      *
00545      *  Marks the socket as a passive socket that can be used to accept
00546      *  incoming connections.
00547      *
00548      *  @param handle   Socket handle.
00549      *  @param backlog  Number of pending connections that can be queued
00550      *                  simultaneously, defaults to 1.
00551      *  @return         0 on success, negative error code on failure.
00552      */
00553     virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
00554 
00555     /** Accepts a connection on a TCP socket.
00556      *
00557      *  The server socket must be bound and set to listen for connections.
00558      *  On a new connection, creates a network socket and stores it in the
00559      *  specified handle. The handle must be passed to following calls on
00560      *  the socket.
00561      *
00562      *  A stack may have a finite number of sockets, in this case
00563      *  NSAPI_ERROR_NO_SOCKET is returned if no socket is available.
00564      *
00565      *  This call is non-blocking. If accept would block,
00566      *  NSAPI_ERROR_WOULD_BLOCK is returned immediately.
00567      *
00568      *  @param server   Socket handle to server to accept from.
00569      *  @param handle   Destination for a handle to the newly created socket.
00570      *  @param address  Destination for the remote address or NULL.
00571      *  @return         0 on success, negative error code on failure.
00572      */
00573     virtual nsapi_error_t socket_accept(nsapi_socket_t server,
00574                                         nsapi_socket_t *handle,
00575                                         SocketAddress *address = 0);
00576 
00577     /**  Set stack-specific socket options.
00578      *
00579      *  The setsockopt allow an application to pass stack-specific hints
00580      *  to the underlying stack. For unsupported options,
00581      *  NSAPI_ERROR_UNSUPPORTED is returned and the socket is unmodified.
00582      *
00583      *  @param handle   Socket handle.
00584      *  @param level    Stack-specific protocol level.
00585      *  @param optname  Stack-specific option identifier.
00586      *  @param optval   Option value.
00587      *  @param optlen   Length of the option value.
00588      *  @return         0 on success, negative error code on failure.
00589      */
00590     virtual nsapi_error_t setsockopt(nsapi_socket_t handle, int level,
00591                                      int optname, const void *optval,
00592                                      unsigned optlen);
00593 
00594     /**  Get stack-specific socket options.
00595      *
00596      *  The getstackopt allow an application to retrieve stack-specific hints
00597      *  from the underlying stack. For unsupported options,
00598      *  NSAPI_ERROR_UNSUPPORTED is returned and optval is unmodified.
00599      *
00600      *  @param handle   Socket handle.
00601      *  @param level    Stack-specific protocol level.
00602      *  @param optname  Stack-specific option identifier.
00603      *  @param optval   Destination for option value.
00604      *  @param optlen   Length of the option value.
00605      *  @return         0 on success, negative error code on failure.
00606      */
00607     virtual nsapi_error_t getsockopt(nsapi_socket_t handle, int level,
00608                                      int optname, void *optval,
00609                                      unsigned *optlen);
00610 
00611 private:
00612 
00613     // u_ added to namespace us somewhat as this darned macro
00614     // is defined by everyone and their dog
00615     #define u_stringify(a) str(a)
00616     #define str(a) #a
00617 
00618     bool _sim_pin_check_change_pending;
00619     bool _sim_pin_check_change_pending_enabled_value;
00620     bool _sim_pin_change_pending;
00621     const char *_sim_pin_change_pending_new_pin_value;
00622     Thread event_thread;
00623     volatile bool _run_event_thread;
00624     void handle_event();
00625     SockCtrl * find_socket(int modem_handle = SOCKET_UNUSED);
00626     void clear_socket(SockCtrl * socket);
00627     bool check_socket(SockCtrl * socket);
00628     int nsapi_security_to_modem_security(nsapi_security_t nsapi_security);
00629     Callback<void(nsapi_error_t)> _connection_status_cb;
00630     void UUSORD_URC();
00631     void UUSORF_URC();
00632     void UUSOCL_URC();
00633     void UUPSDD_URC();
00634 };
00635 
00636 #endif // _UBLOX_AT_CELLULAR_INTERFACE_
00637