Support for LISA-N101

Fork of C027_Support by u-blox

This is a variant of the C027 driver code for the C027N version, i.e. the one with the Neul/Huawei/u-blox Cellular Internet of Things module on board. The AT command interface for this module is entirely different to the AT interface for the other u-blox modules, hence this fork of the driver. Work is underway to rearchitect the original C027 driver so that a merge can be done.

Revision:
118:f3fd6c30dc19
Parent:
117:74e4e0109a9e
Child:
122:c6b2fa1928f2
--- a/MDM.h	Thu Jan 22 08:02:55 2015 +0000
+++ b/MDM.h	Tue Mar 10 16:25:18 2015 +0000
@@ -32,7 +32,7 @@
     // ----------------------------------------------------------------
     //! MT Device Types 
     typedef enum { DEV_UNKNOWN, DEV_SARA_G350, DEV_LISA_U200, DEV_LISA_C200, 
-                   DEV_SARA_U260, DEV_SARA_U270, DEV_LEON_G200 } Dev; 
+                   DEV_SARA_U260, DEV_SARA_U270, DEV_LEON_G200, DEV_LISA_N101 } Dev; 
     //! SIM Status
     typedef enum { SIM_UNKNOWN, SIM_MISSING, SIM_PIN, SIM_READY } Sim;
     //! SIM Status
@@ -292,6 +292,42 @@
     bool ussdCommand(const char* cmd, char* buf);
     
     // ----------------------------------------------------------------
+    // DATAGRAMS (via C027N Neul module)
+    // ----------------------------------------------------------------
+
+    /** Send a datagram
+        \param size  the size of buf
+        \param buf  the hex-coded ASCII string to be sent (unterminated)
+        \return true if successful, false otherwise
+        Example: to send 0xAA11BB, use size = 6, buf = [AA11BB]
+        Note: sending a datagram involves a few AT exchanges with the
+        modem.  If a datagram happens to be received while this is going
+        on it will be ignored.  If this is a problem, use
+        datagramSendReceive() instead.
+    */
+    bool datagramSend(int size, const char* buf);
+
+    /** Receive a datagram.
+        \param size  when called, the size of buf and, on exit
+               the number of characters stored in buf.
+        \param buf  the bytes received
+        \param timeoutMs optional time to wait in milliseconds
+        \return true if something was received, false otherwise
+    */
+    bool datagramRecv(int* size, char* buf, int timeoutMs = 10000);
+
+     /** Get the RSSI of the Neul modem
+        \param rssi  a number in the range 0 to 255
+        \return true if successful, false otherwise
+     */
+    bool getRssi(int *rssi);
+
+    /** Reboot a Neul module
+       \return true if successful, false otherwise
+    */
+    bool neulReboot(void);
+
+    // ----------------------------------------------------------------
     // FILE 
     // ----------------------------------------------------------------
     
@@ -511,15 +547,20 @@
     // parsing callbacks for different AT commands and their parameter arguments
     static int _cbString(int type, const char* buf, int len, char* str);
     static int _cbInt(int type, const char* buf, int len, int* val);
+    static int _cbGmiString(int type, const char* buf, int len, char* str);
+    static int _cbGmmString(int type, const char* buf, int len, char* str);
+    static int _cbGmrString(int type, const char* buf, int len, char* str);
     // device
     static int _cbATI(int type, const char* buf, int len, Dev* dev);
     static int _cbCPIN(int type, const char* buf, int len, Sim* sim);
     static int _cbCCID(int type, const char* buf, int len, char* ccid);
     // network 
     static int _cbCSQ(int type, const char* buf, int len, NetStatus* status);
+    static int _cbCSQN(int type, const char* buf, int len, int* rssi);
     static int _cbCOPS(int type, const char* buf, int len, NetStatus* status);
     static int _cbCNUM(int type, const char* buf, int len, char* num);
     static int _cbUACTIND(int type, const char* buf, int len, int* i);
+    static int _cbRAS(int type, const char* buf, int len, bool* connected);
     static int _cbUDOPN(int type, const char* buf, int len, char* mccmnc);
     // sockets
     static int _cbCMIP(int type, const char* buf, int len, IP* ip);
@@ -531,11 +572,18 @@
     typedef struct { char* buf; IP ip; int port; } USORFparam;
     static int _cbUSORF(int type, const char* buf, int len, USORFparam* param);
     typedef struct { char* buf; char* num; } CMGRparam;
-    static int _cbCUSD(int type, const char* buf, int len, char* buf);
+    static int _cbCUSD(int type, const char* buf, int len, char* resp);
     // sms
     typedef struct { int* ix; int num; } CMGLparam;
     static int _cbCMGL(int type, const char* buf, int len, CMGLparam* param);
     static int _cbCMGR(int type, const char* buf, int len, CMGRparam* param);
+    // Neul
+    static int _cbMGS (int type, const char* buf, int len, bool* ok);
+    static int _cbSMI (int type, const char* buf, int len, bool* sent);
+    typedef struct { char* buf; int maxlen; int outlen; } MGRparam;
+    bool doMGR (int* size, char* buf, MGRparam* param);
+    static int _cbMGR (int type, const char* buf, int len, MGRparam* param);
+    static int _cbRB (int type, const char* buf, int len, bool* ok);
     // file
     typedef struct { const char* filename; char* buf; int sz; int len; } URDFILEparam;
     static int _cbUDELFILE(int type, const char* buf, int len, void*);
@@ -550,8 +598,12 @@
     // LISA-U and SARA-G have 7 sockets
     SockCtrl _sockets[12];
     int _findSocket(int handle = SOCKET_ERROR/* = CREATE*/);
+    // Utility to convert a hex string into bytes
+    static void hexStringToBytes (const char *inBuf, int lenInBuf, char * outBuf, int* lenOutBuf);
     static MDMParser* inst;
     bool _init;
+    bool _ubloxat;
+    int _outstandingNMI;
 #ifdef TARGET_UBLOX_C027
     bool _onboard;
 #endif
@@ -659,4 +711,4 @@
     // the mutex resource
     Mutex _mtx;
 };
-#endif
\ No newline at end of file
+#endif