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.

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Fri Jun 06 07:51:23 2014 +0000
Parent:
84:a05edb010176
Child:
86:840a86109d4b
Commit message:
adding simple apn lookup table ... that can be to be extended for other networks

Changed in this revision

MDM.cpp Show annotated file Show diff for this revision Revisions of this file
MDMAPN.h Show annotated file Show diff for this revision Revisions of this file
--- a/MDM.cpp	Thu Jun 05 15:16:57 2014 +0000
+++ b/MDM.cpp	Fri Jun 06 07:51:23 2014 +0000
@@ -4,42 +4,7 @@
 #ifdef TARGET_UBLOX_C027
  #include "C027_api.h"
 #endif
-
-/* ----------------------------------------------------------------
-   APN stands for Access Point Name, a setting on your modem or phone
-   that identifies an external network your phone can access for data 
-   (e.g., 3G or 4G Internet service on your phone). 
-   
-   The APN settings can be forced when calling the join function.
-   Below is a list of known APNs that us used if no apn config 
-   is forced. This list could be extended by other settings.
-   
-   For further reading:
-   wiki apn: http://en.wikipedia.org/wiki/Access_Point_Name
-   wiki mcc/mnc: http://en.wikipedia.org/wiki/Mobile_country_code
-   google: https://www.google.de/search?q=APN+list   
----------------------------------------------------------------- */
-//! helper 
-#define _APN(a,u,p) a "\0" u "\0" p "\0"
-//! default APN settings used by many networks
-static const char* apndef =     _APN("internet",,); 
-//! this is a list of special APNs for different network operators 
-static const struct { const char* mccmnc; const char* cfg; } apnlut[] = {
-// Germany 
-    { /*T-Mobile*/ "26201",     _APN("internet.t-mobile","t-mobile","tm") },
-// Switzerland
-    { /*Swisscom*/ "22801",     _APN("gprs.swisscom.ch",,) },
-// USA
-    { /*T-Mobile*/ "310026|310260|310490",
-                                _APN("epc.tmobile.com",,) 
-                                _APN("fast.tmobile.com",,) /*LTE*/ },
-    { /*AT&T*/     "310030|310150|310170|310260|310410|310560|310680",
-                                _APN("phone",,)
-                                _APN("wap.cingular","WAP@CINGULARGPRS.COM","CINGULAR1")
-                                _APN("isp.cingular","ISP@CINGULARGPRS.COM","CINGULAR1") },
-    // ...     
-};
-// ----------------------------------------------------------------
+#include "MDMAPN.h"
                 
 #define PROFILE         "0"   //!< this is the psd profile used
 #define MAX_SIZE        128   //!< max expected messages
@@ -740,6 +705,8 @@
                 config = apndef;
                 sendFormated("AT+UDOPN=0\r\n");
                 if ((RESP_OK == waitFinalResp(_cbUDOPN, mccmnc)) && *mccmnc) {
+                    TRACE("Lookup APN Settings for network \"%s\" from operator \"%s\"\r\n", 
+                            mccmnc, _net.opr);
                     // many carriers use internet without username and password, os use this as default
                     // now try to lookup the setting for our table
                     for (int i = 0; i < sizeof(apnlut)/sizeof(*apnlut); i ++) {
@@ -758,13 +725,9 @@
  
             do {
                 if (config) {
-                    apn      = *config ? config : "";
-                    config  += strlen(config)+1;
-                    username = *config ? config : "";
-                    config  += strlen(config)+1;
-                    password = *config ? config : "";
-                    config  += strlen(config)+1;
-                    if (!*config) config  = NULL;
+                    apn      = _APN_GET(config);
+                    username = _APN_GET(config);
+                    password = _APN_GET(config);
                     TRACE("Testing APN Settings(\"%s\",\"%s\",\"%s\")\r\n", apn, username, password);
                 }
                 // Set up the APN
@@ -793,7 +756,7 @@
                             ok = true;
                     }
                 }
-            } while (config); // maybe use next setting ? 
+            } while (config && *config); // maybe use next setting ? 
             if (!ok) {
                 ERROR("Your modem APN/password/username may be wrong\r\n");
                 return NOIP;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MDMAPN.h	Fri Jun 06 07:51:23 2014 +0000
@@ -0,0 +1,53 @@
+#pragma once 
+
+/* ----------------------------------------------------------------
+   APN stands for Access Point Name, a setting on your modem or phone
+   that identifies an external network your phone can access for data 
+   (e.g., 3G or 4G Internet service on your phone). 
+   
+   The APN settings can be forced when calling the join function.
+   Below is a list of known APNs that us used if no apn config 
+   is forced. This list could be extended by other settings.
+   
+   For further reading:
+   wiki apn: http://en.wikipedia.org/wiki/Access_Point_Name
+   wiki mcc/mnc: http://en.wikipedia.org/wiki/Mobile_country_code
+   google: https://www.google.de/search?q=APN+list   
+---------------------------------------------------------------- */
+
+//! helper to generate the APN string
+#define _APN(apn,username,password) apn "\0" username "\0" password "\0"
+
+//! helper to extract a field from the config string 
+#define _APN_GET(cfg) \
+    *cfg ? cfg : ""; \
+    cfg  += strlen(cfg) + 1
+                    
+//! APN lookup struct
+typedef struct { 
+    const char* mccmnc; //!< mobile country code (MCC) and mobile network code MNC  
+    const char* cfg;    //!< APN configuartion string, use _APN macro to generate
+} APN_t;
+
+//! default APN settings used by many networks
+static const char* apndef = _APN("internet",,); 
+
+//! this is a list of special APNs for different network operators 
+static const APN_t apnlut[] = {
+
+// Germany 
+    { /*T-Mobile*/ "26201",     _APN("internet.t-mobile","t-mobile","tm") },
+
+// Switzerland
+    { /*Swisscom*/ "22801",     _APN("gprs.swisscom.ch",,) },
+    
+// USA
+    { /*T-Mobile*/ "310026|310260|310490",
+                                _APN("epc.tmobile.com",,) 
+                                _APN("fast.tmobile.com",,) /*LTE*/ },
+    { /*AT&T*/     "310030|310150|310170|310260|310410|310560|310680",
+                                _APN("phone",,)
+                                _APN("wap.cingular","WAP@CINGULARGPRS.COM","CINGULAR1")
+                                _APN("isp.cingular","ISP@CINGULARGPRS.COM","CINGULAR1") },
+    // ...     
+};