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.
Diff: MDM.h
- Revision:
- 74:208e3e32d263
- Parent:
- 73:2b32e0a21df2
- Child:
- 75:ce6e12067d0c
--- a/MDM.h Thu May 15 08:25:45 2014 +0000 +++ b/MDM.h Thu May 15 22:20:42 2014 +0000 @@ -7,14 +7,16 @@ #include "SerialPipe.h" #ifdef TARGET_UBLOX_C027 - // if we detect the C027 platform we will assign the - // default pinname and baudrate in the constructor - // this helper macro will be used. - #define _C027DEFAULT(name) = name + #define _IF(onboard,shield) onboard #else - #define _C027DEFAULT(name) + #define _IF(onboard,shield) shield #endif +//! include debug capabilty on more powerful targets with a dedicated debug port +#if defined(TARGET_LPC1768) || defined(TARGET_LPC4088) || defined(TARGET_K64F) + #define MDM_DEBUG +#endif + /** basic modem parser class */ class MDMParser @@ -22,6 +24,8 @@ public: //! Constructor MDMParser(); + //! Destructor + ~MDMParser(); //! get static instance static MDMParser* getInstance() { return inst; }; @@ -94,14 +98,15 @@ */ bool connect(const char* simpin, const char* apn, const char* username, const char* password, - bool dump); + PinName pn _IF( = MDMPWRON, = D4)); /** register (Attach) the MT to the GPRS service. \param simpin a optional pin of the SIM card \param status an optional struture to with device information \return true if successful, false otherwise */ - bool init(const char* simpin = NULL, DevStatus* status = NULL); + bool init(const char* simpin = NULL, DevStatus* status = NULL, + PinName pn _IF( = MDMPWRON, = D4)); /** check if the network is available \param status an optional structure to with network information @@ -279,9 +284,15 @@ bool ussdCommand(const char* cmd, char* buf); // ---------------------------------------------------------------- - // DUMP status to standard out (printf) + // DEBUG/DUMP status to standard out (printf) // ---------------------------------------------------------------- + /*! Set the debug level + \param level 0 = OFF, 1 = INFO(default), 2 = TRACE, 3 = ATCMD + \return true if successful, false not possible + */ + bool setDebug(int level); + //! helper type for DPRINT typedef int (*_DPRINT)(void* param, char const * format, ...); @@ -294,7 +305,7 @@ static void func(type arg, \ _DPRINT dprint = (_DPRINT)fprintf, \ void* param = (void*)stdout); - + /** dump the device status to stdout using printf \param status the status to convert to textual form, unavailable fields are ommited (not printed) @@ -487,6 +498,13 @@ // LISA-U and SARA-G have 7 sockets starting at index 1 SockCtrl _sockets[32]; static MDMParser* inst; +#ifdef TARGET_UBLOX_C027 + bool _onboard; +#endif +#ifdef MDM_DEBUG + int _debugLevel; + Timer _debugTime; +#endif }; // ----------------------------------------------------------------------- @@ -509,12 +527,12 @@ \param rxSize the size of the serial rx buffer \param txSize the size of the serial tx buffer */ - MDMSerial(PinName tx _C027DEFAULT(MDMTXD), - PinName rx _C027DEFAULT(MDMRXD), - int baudrate _C027DEFAULT(MDMBAUD), + MDMSerial(PinName tx _IF( = MDMTXD, = D1 ), + PinName rx _IF( = MDMRXD, = D2 ), + int baudrate _IF( = MDMBAUD, = 115200 ), #if DEVICE_SERIAL_FC - PinName rts _C027DEFAULT(MDMRTS), - PinName cts _C027DEFAULT(MDMCTS), + PinName rts _IF( = MDMRTS, = NC ), + PinName cts _IF( = MDMCTS, = NC ), #endif int rxSize = 256 , int txSize = 128 );