Own fork of C027_Support

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of C027_Support by u-blox

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MDMAPN.h Source File

MDMAPN.h

00001 #pragma once 
00002 
00003 /* ----------------------------------------------------------------
00004    APN stands for Access Point Name, a setting on your modem or phone
00005    that identifies an external network your phone can access for data 
00006    (e.g. 3G or 4G Internet service on your phone). 
00007    
00008    The APN settings can be forced when calling the join function.
00009    Below is a list of known APNs that us used if no apn config 
00010    is forced. This list could be extended by other settings.
00011    
00012    For further reading:
00013    wiki apn: http://en.wikipedia.org/wiki/Access_Point_Name
00014    wiki mcc/mnc: http://en.wikipedia.org/wiki/Mobile_country_code
00015    google: https://www.google.de/search?q=APN+list   
00016 ---------------------------------------------------------------- */
00017 
00018 //! helper to generate the APN string
00019 #define _APN(apn,username,password) apn "\0" username "\0" password "\0"
00020 
00021 //! helper to extract a field from the config string 
00022 #define _APN_GET(cfg) \
00023     *cfg ? cfg : ""; \
00024     cfg  += strlen(cfg) + 1
00025                     
00026 //! APN lookup struct
00027 typedef struct { 
00028     const char* mccmnc; //!< mobile country code (MCC) and mobile network code MNC  
00029     const char* cfg;    //!< APN configuartion string, use _APN macro to generate
00030 } APN_t;
00031 
00032 //! default APN settings used by many networks
00033 static const char* apndef = _APN(,,)
00034                             _APN("internet",,);
00035 
00036 /*! this is a list of special APNs for different network operators 
00037     There is no need to enter the default apn internet in the table; 
00038     apndef will be used if no entry matches.
00039     
00040     The APN without username/password have to be listed first.
00041 */
00042 static const APN_t apnlut[] = {
00043 // MCC Country
00044 //  { /* Operator */ "MCC-MNC[,MNC]" _APN(APN,USERNAME,PASSWORD) },
00045 // MCC must be 3 digits
00046 // MNC must be either 2 or 3 digits
00047 // MCC must be separated by '-' from MNC, multiple MNC can be separated by ','
00048 
00049 // 232 Austria - AUT
00050     { /* T-Mobile */ "232-03",    _APN("m2m.business",,) },
00051 
00052 // 460 China - CN
00053     { /* CN Mobile */"460-00",    _APN("cmnet",,)
00054                                   _APN("cmwap",,) },
00055     { /* Unicom */   "460-01",    _APN("3gnet",,)
00056                                   _APN("uninet","uninet","uninet") },
00057                                 
00058 // 262 Germany - DE
00059 //    { /* T-Mobile */ "262-01",  _APN("internet.t-mobile","t-mobile","tm") },
00060     { /* T-Mobile */ "262-02,06", _APN("m2m.business",,) },
00061     { /* T-Mobile */ "262-01",    _APN("internet.m2mportal.de", "m2m", "sim")
00062                                   _APN("internet.telekom",,) },
00063 // 222 Italy - IT
00064     { /* TIM */      "222-01",    _APN("ibox.tim.it",,) },
00065     { /* Vodafone */ "222-10",    _APN("web.omnitel.it",,) },
00066     { /* Wind */     "222-88",    _APN("internet.wind.biz",,) },
00067 
00068 // 440 Japan - JP
00069     { /* Softbank */ "440-04,06,20,40,41,42,43,44,45,46,47,48,90,91,92,93,94,95"
00070                          ",96,97,98"
00071                                   _APN("open.softbank.ne.jp","opensoftbank","ebMNuX1FIHg9d3DA")
00072                                   _APN("smile.world","dna1trop","so2t3k3m2a") },
00073     { /* NTTDoCoMo */"440-09,10,11,12,13,14,15,16,17,18,19,21,22,23,24,25,26,27,"
00074                          "28,29,30,31,32,33,34,35,36,37,38,39,58,59,60,61,62,63,"
00075                          "64,65,66,67,68,69,87,99",
00076                                   _APN("bmobilewap",,) /*BMobile*/
00077                                   _APN("mpr2.bizho.net","Mopera U",) /* DoCoMo */
00078                                   _APN("3g-uno.ntt.com",,) /* DoCoMo */
00079                                   _APN("3gd-ocn.ntt.com",,) /* DoCoMo */
00080                                   _APN("nttcom.fr",,) /* DoCoMo */
00081                                   _APN("bmobile.ne.jp","bmobile@wifi2","bmobile") /*BMobile*/ },
00082 
00083 // 204 Netherlands - NL
00084     { /* Vodafone */ "204-04",    _APN("public4.m2minternet.com",,) 
00085                                   _APN("test.teleena.com",,) },
00086     { /* Teleena */  "204-07",    _APN("test.teleena.com",,) },
00087 
00088 // 293 Slovenia - SI
00089     { /* Si.mobil */ "293-40",    _APN("internet.simobil.si",,) },
00090     { /* Tusmobil */ "293-70",    _APN("internet.tusmobil.si",,) },
00091 
00092 // 240 Sweden SE
00093     { /* Telia */    "240-01",    _APN("online.telia.se",,) },
00094     { /* Telenor */  "240-06,08", _APN("services.telenor.se",,) },
00095     { /* Tele2 */    "240-07",    _APN("m2m.tele2.com",,)
00096                                   _APN("mobileinternet.tele2.se",,) },
00097 
00098 // 228 Switzerland - CH
00099     { /* Swisscom */ "228-01",    _APN("swisscom-test.m2m.ch",,)
00100                                   _APN("gprs.swisscom.ch",,) },
00101     { /* Orange */   "228-03",    _APN("internet",,) /* contract */
00102                                   _APN("click",,)    /* pre-pay */ },
00103                                   
00104 // 270 Luxembourg
00105     { /* Post */     "270-01",    _APN("postm2m.lu",,)},
00106 
00107 // 234 United Kingdom - GB
00108     { /* O2 */       "234-02,10,11",
00109                                   _APN("mobile.o2.co.uk","faster","web") /* contract */
00110                                   _APN("mobile.o2.co.uk","bypass","web") /* pre-pay */
00111                                   _APN("payandgo.o2.co.uk","payandgo","payandgo") },
00112     { /* Vodafone */ "234-15",    _APN("internet","web","web")          /* contract */
00113                                   _APN("pp.vodafone.co.uk","wap","wap")  /* pre-pay */ },
00114     { /* Three */    "234-20",    _APN("three.co.uk",,) },
00115     { /* EE */       "234-33,30", _APN("EEm2m",,)
00116                                   _APN("m2mdata",,) },
00117 
00118 // 310 United States of America - US
00119     { /* Kore Telematics */ "505-02",   _APN("od1.korem2m.com",,) },
00120     { /* T-Mobile */ "310-026,260,490",
00121                                   _APN("epc.tmobile.com",,)
00122                                   _APN("fast.tmobile.com",,) /* LTE */ },
00123     { /* AT&T */     "310-030,150,170,260,410,560,680",
00124                                   _APN("phone",,)
00125                                   _APN("wap.cingular","WAP@CINGULARGPRS.COM","CINGULAR1")
00126                                   _APN("isp.cingular","ISP@CINGULARGPRS.COM","CINGULAR1") },
00127                                   
00128 // 602 UAE
00129     { /* Etisalat */ "602-602",   _APN("internet.etisalat",,)},
00130 
00131 // 732 Colombia
00132     { /* Comcel */   "732-101",   _APN("internet.comcel.com.co",,)
00133                                   _APN("internet.movistar.com.co",,) },
00134 
00135 // 405 India
00136     { /* Reliance */ "405-21",    _APN("unlimitiot",,)
00137                                   _APN("IoTtest",,) },
00138 
00139 // 901 International - INT
00140     { /* Transatel */ "901-37",   _APN("netgprs.com","tsl","tsl") },
00141 };
00142 
00143 inline const char* apnconfig(const char* imsi)
00144 {
00145     const char* config = NULL;
00146     if (imsi && *imsi) {
00147         // many carriers use internet without username and password, os use this as default
00148         // now try to lookup the setting for our table
00149         for (int i = 0; i < sizeof(apnlut)/sizeof(*apnlut) && !config; i ++) {
00150             const char* p = apnlut[i].mccmnc;
00151             // check the MCC
00152             if ((0 == memcmp(imsi, p, 3))) {
00153                 p += 3;
00154                 // check all the MNC, MNC length can be 2 or 3 digits
00155                 while (((p[0] == '-') || (p[0] == ',')) && 
00156                         (p[1] >= '0') && (p[1] <= '9') && 
00157                         (p[2] >= '0') && (p[2] <= '9') && !config) {
00158                     int l = ((p[3] >= '0') && (p[3] <= '9')) ? 3 : 2;
00159                     if (0 == memcmp(imsi+3,p+1,l))
00160                         config = apnlut[i].cfg;
00161                     p += 1 + l;
00162                 } 
00163             }
00164         }
00165     }
00166     // use default if not found
00167     if (!config)
00168         config = apndef;
00169     return config;
00170 }