support library for C027 helper functions for Buffer Pipes, Buffered Serial Port (rtos capable) and GPS parsing. It includes modem APIs for USSD, SMS and Sockets.

Dependents:   HTTPClient_Cellular_HelloWorld Cellular_HelloMQTT MbedSmartRestMain Car_Bon_car_module ... more

This library is intended to be used with u-blox products such as the C027 or a shield with u-blox cellular and GPS modules like the cellular and positioning shield from Embedded Artist.

For 2G/GSM and 3G/UMTS you need to:

  • have a SIM card and know its PIN number
  • need to know you network operators APN setting These setting should be passed to the connect or init and join functions. You can also extend the APN database in MDMAPN.h.

For CDMA products you need to make sure that you have provisioned and activated the modem with either Sprint or Verizon.

Revision:
135:cbccf4052d45
Parent:
134:2fbd5723e063
Child:
136:8dc8f48275fc
--- a/MDM.h	Tue Jan 12 08:37:29 2016 +0000
+++ b/MDM.h	Thu Jan 21 15:59:42 2016 +0000
@@ -274,7 +274,83 @@
         \return true if successfully, false otherwise
     */    
     bool socketFree(int socket);
-        
+
+    // ----------------------------------------------------------------
+    // HTTP
+    // ----------------------------------------------------------------
+    
+    //! Type of HTTP Operational Codes (reference to HTTP control +UHTTP) 
+    typedef enum { HTTP_IP_ADDRESS, HTTP_SERVER_NAME, HTTP_USER_NAME, HTTP_PASSWORD, \
+                   HTTP_AUTH_TYPE, HTTP_PORT, HTTP_SECURE } HttpOpCode;
+    
+    //! Type of HTTP Commands (reference to HTTP command +UHTTPC)
+    typedef enum { HTTP_HEAD, HTTP_GET, HTTP_DELETE, HTTP_PUT, \
+                   HTTP_POST_FILE, HTTP_POST_DATA } HttpCmd;
+    
+    //! HTTP Profile error return codes
+    #define HTTP_PROF_ERROR -1
+    
+    /** find HTTP profile
+        \return true if successfully, false otherwise
+    */
+    int httpFindProfile();
+    
+    /** get the number of bytes pending for reading for this HTTP profile
+        \param profile the HTTP profile handle
+        \param timeout_ms -1 blocking, else non blocking timeout in ms
+        \return 0 if successful or SOCKET_ERROR on failure 
+    */
+    bool httpSetBlocking(int profile, int timeout_ms);
+    
+    /** set the HTTP profile for commands management
+        \param profile the HTTP profile handle
+        \return true if successfully, false otherwise
+    */
+    bool httpSetProfileForCmdMng(int profile);
+    
+    /** free the HTTP profile
+        \param profile the HTTP profile handle
+        \return true if successfully, false otherwise
+    */
+    bool httpFreeProfile(int profile);
+    
+    /** reset HTTP profile
+        \param httpProfile the HTTP profile to be reset
+        \return true if successfully, false otherwise
+    */
+    bool httpResetProfile(int httpProfile);
+    
+    /** set HTTP parameters
+        \param httpProfile the HTTP profile identifier
+        \param httpOpCode the HTTP operation code
+        \param httpInPar the HTTP input parameter
+        \return true if successfully, false otherwise
+    */
+    bool httpSetPar(int httpProfile, HttpOpCode httpOpCode, const char * httpInPar);
+    
+    /** HTTP commands management
+        \param httpProfile the HTTP profile identifier
+        \param httpCmdCode the HTTP command code
+        \param httpPath the path of HTTP server resource
+        \param httpOut the filename where the HTTP server response will be stored
+        \param httpIn the input data (filename or string) to be sent 
+                      to the HTTP server with the command request
+        \param httpContentType the HTTP Content-Type identifier
+        \param httpCustomPar the parameter for an user defined HTTP Content-Type
+        \param buf the buffer to read into
+        \param len the size of the buffer to read into
+        \return true if successfully, false otherwise
+    */
+    bool httpCommand(int httpProfile, HttpCmd httpCmdCode, const char* httpPath, \
+                     const char* httpOut, const char* httpIn, int httpContentType, \
+                     const char* httpCustomPar, char* buf, int len);
+    
+    /** get HTTP commands
+        \param httpCmdCode the HTTP command code (reference also the enum format)
+        \return HTTP command in string format
+    */
+    const char* getHTTPcmd(int httpCmdCode);
+    
     // ----------------------------------------------------------------
     // SMS Short Message Service
     // ----------------------------------------------------------------
@@ -340,13 +416,29 @@
     */
     int writeFile(const char* filename, const char* buf, int len);
     
-    /** REad a file from the local file system
+    /** Read a file from the local file system
         \param filename the name of the file 
         \param buf a buffer to hold the data 
         \param len the size to read
         \return the number of bytes read
     */
     int readFile(const char* filename, char* buf, int len);
+    
+    /** Read a file from the local file system
+        (the file size is greater than MAX_SIZE bytes)
+        \param filename the name of the file 
+        \param buf a buffer to hold the data 
+        \param len the size to read
+        \return the number of bytes read
+    */
+    int readFileNew(const char* filename, char* buf, int len);
+    
+    /** Retrieve information about the dimension of a file from the local FFS
+        \param filename the name of the file
+        \return the file dimension in number of bytes 
+    */
+    int infoFile(const char* filename);
+    
     // ----------------------------------------------------------------
     // Cell Locate
     // ----------------------------------------------------------------
@@ -626,6 +718,8 @@
     typedef struct { const char* filename; char* buf; int sz; int len; } URDFILEparam;
     static int _cbUDELFILE(int type, const char* buf, int len, void*);
     static int _cbURDFILE(int type, const char* buf, int len, URDFILEparam* param);
+    static int _cbURDBLOCK(int type, const char* buf, int len, char* out);
+    static int _cbULSTFILE(int type, const char* buf, int len, int* infoFile);
     // variables
     DevStatus   _dev; //!< collected device information
     NetStatus   _net; //!< collected network information 
@@ -637,6 +731,16 @@
     // LISA-U and SARA-G have 7 sockets
     SockCtrl _sockets[12];
     int _findSocket(int handle = SOCKET_ERROR/* = CREATE*/);
+    // management structure for HTTP profiles
+    // it's possible to have up to 4 different HTTP profiles (LISA-C200, LISA-U200 and SARA-G350) having:
+    // param handle the current HTTP profile is in handling state or not (default value is HTTP_ERROR)
+    // param timeout_ms the timeout for the current HTTP command
+    // param pending the status for the current HTTP command (in processing state or not)
+    // param cmd the code for the current HTTP command
+    // param result the result for the current HTTP command once processed
+    typedef struct {  int handle; int timeout_ms; bool pending; int cmd; int result; } HttpProfCtrl;
+    HttpProfCtrl _httpProfiles[4];
+    int _findProfile(int handle = HTTP_PROF_ERROR/* = CREATE*/);
     static MDMParser* inst;
     bool _init;
 #ifdef TARGET_UBLOX_C027