Connection Manager library for u-blox cellular modules. It manages the modem for keeping data connection always active.

Dependents:   C027_demo_ConnMan

Revision:
1:29ad1d1ac1f9
Parent:
0:86284a262735
--- a/CNManager.h	Tue Jan 12 09:08:15 2016 +0000
+++ b/CNManager.h	Thu Jan 21 14:00:25 2016 +0000
@@ -7,30 +7,40 @@
 #define TIMEOUT_POLLING_NETWORK_STATUS          (5 * 1000)  //!< timeout for polling the network status
 #define MAX_ERROR_RETRIES                       5           //!< number of error before reset
 #define SIM_WAIT_MAX_CYCLE                      15          //!< wait cycle for sim init
+#define MEX_RESP_ERROR                          5
 
-//! Data events
-typedef enum{
-    DATA_DISCONNECTED = 0,  //!< Data channel is down
-    DATA_CONNECTED = 1,     //!< Data channel is up
-} DataStatus;
+//! Manager events
+typedef enum {    
+    MNG_EV_IDLE,               //!< idle
+    MNG_EV_DATA_UP,            //!< data connection is active
+    MNG_EV_DATA_DOWN,            //!< data connection is active
+} MngEvents;
+
 
 /** Function handler for data status updates
-  /param ev new data status 
+  /param ev new data status
+  /param param void pointer
 */
-typedef void (*evDataHandler) (DataStatus ev);
+typedef void (*evMngHandler) (MngEvents ev, void* param);
 
 /** Init Function
-  This function has to be called prior to CNMLoop
-   \param handler        Handler for data status changes
+  This function has to be called before CNMLoop
    \param powerOn        module power status at boot: enabled on, disabled off
    \param dataEnabled    data connection status at boot: enabled on, disabled off
    \param roomingEnabled unsolicited messages status: enabled on, disabled off
    \return true if successful false otherwise
  */
-bool cnInit(evDataHandler handler = NULL, bool powerOn = true, bool dataEnabled = true, bool roomingEnabled = true);
+bool cnInit(bool powerOn = true, bool dataEnabled = true, bool roomingEnabled = true);
+
+/**Handler registration
+   
+    \param handler   Handler for data status changes
+    \param param     void paramter to be passed to the handler
+*/
+void cnRegHandler(evMngHandler handler, void* param=NULL);
 
 /** Set the debug level.
-  This function has to be called prior to CNMLoop
+  This function has to be called before CNMLoop
    \param level -1 = OFF, 0 = ERROR, 1 = INFO(default), 2 = TRACE, 3 = ATCMD,TEST
    \return true if successful, false not possible
  */
@@ -60,7 +70,7 @@
 void cnSetDataEnabled(bool enabled);
 
 /** Set parameters for the GPRS service.
-This function has to be called prior to CNMLoop.
+This function has to be called before CNMLoop.
 If Apn parameters are not set, the internal APN info database will be used.
  \param apn the of the network provider e.g. "internet" or "apn.provider.com"
  \param username is the user name text string for the authentication phase
@@ -81,12 +91,21 @@
 void cnSetRoamingOn(bool enabled);
 
 /** Get data connection status.
- * \return dataStatus
+ * \return yes if connection is up, false otherways
  */
-DataStatus cnGetDataConnStatus();
+bool cnIsDataUp();
 
+/** Get the MDM library's pointer.
+ * \return the MDM pointer
+ */
+MDMSerial* cnGetMDM();
 
-/** Get the modem library's pointer.
- * \return the MDMParser pointer
+/** Get a copy of NetStatus.
+ * \param net pointer where NetStatus will be copied into
  */
-CNLib* cnGetMDM();
\ No newline at end of file
+void getNetStatus(MDMParser::NetStatus* net);
+
+/** Get a copy of DevStatus.
+ * \param dev pointer where DevStatus will be copied into
+ */
+void getDevStatus(MDMParser::DevStatus* dev);
\ No newline at end of file