Connection Manager library for u-blox cellular modules. It manages the modem for keeping data connection always active.
Diff: CNManager.h
- Revision:
- 0:86284a262735
- Child:
- 1:29ad1d1ac1f9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CNManager.h Tue Jan 12 09:08:15 2016 +0000 @@ -0,0 +1,92 @@ +#pragma once + +#include "CNLib.h" + +#define TIMEOUT_RETRY_DATA_CONNECTION (5 * 1000) //!< timeout for bringing up data in case of faults +#define TIMEOUT_CHECK_STATUS_DATA_CONNECITION (5 * 1000) //!< timeout for checking data connection status +#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 + +//! Data events +typedef enum{ + DATA_DISCONNECTED = 0, //!< Data channel is down + DATA_CONNECTED = 1, //!< Data channel is up +} DataStatus; + +/** Function handler for data status updates + /param ev new data status +*/ +typedef void (*evDataHandler) (DataStatus ev); + +/** Init Function + This function has to be called prior to CNMLoop + \param handler Handler for data status changes + \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); + +/** Set the debug level. + This function has to be called prior to CNMLoop + \param level -1 = OFF, 0 = ERROR, 1 = INFO(default), 2 = TRACE, 3 = ATCMD,TEST + \return true if successful, false not possible + */ +bool cnSetDebug(int level); + +/** Cycle the connection manager loop. +* \return true if successful, false otherwise +*/ +int cnLoop(); + +/** force module reset. + This function can be called at any time. + Force the reset of the connection manager and of the module. + */ +void cnReset(); + +/** Set the module power. + This function can be called at any time. + \param on if true the module is switched on, if false is switched off + */ +void cnSetPower(bool on); + +/** Register (Attach) the MT to the GPRS service. + This function can be called at any time. + \param enabled if true data connection is requested, if false not. + */ +void cnSetDataEnabled(bool enabled); + +/** Set parameters for the GPRS service. +This function has to be called prior to 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 + \param password is the password text string for the authentication phase + \param auth is the authentication mode (CHAP,PAP,NONE or DETECT) + */ +void cnSetApn(const char *apn,const char* username = NULL,const char* password = NULL); + +/** Set Sim pin for unlocking the sim + This function has to be called prior to CNMLoop. + \param pin of the SIM card + */ +void cnSetSimPin(const char* pin); + +/** Set if rooming is allowed. + \param enabled if true rooming is allowed, false it is not + */ +void cnSetRoamingOn(bool enabled); + +/** Get data connection status. + * \return dataStatus + */ +DataStatus cnGetDataConnStatus(); + + +/** Get the modem library's pointer. + * \return the MDMParser pointer + */ +CNLib* cnGetMDM(); \ No newline at end of file