portable version of the cumulocity demo
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
apndb.cpp@53:76de473cf5a7, 2014-09-03 (annotated)
- Committer:
- Cumulocity
- Date:
- Wed Sep 03 14:32:36 2014 +0000
- Revision:
- 53:76de473cf5a7
- Parent:
- 44:e34e48130533
Added APN for Telekom Deutschland
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vwochnik | 23:0a48eebaaba8 | 1 | #include "apndb.h" |
vwochnik | 23:0a48eebaaba8 | 2 | #include "stdlib.h" |
vwochnik | 23:0a48eebaaba8 | 3 | #include "stdio.h" |
vwochnik | 23:0a48eebaaba8 | 4 | #include "string.h" |
vwochnik | 23:0a48eebaaba8 | 5 | |
vwochnik | 23:0a48eebaaba8 | 6 | // Contains all tuples |
vwochnik | 23:0a48eebaaba8 | 7 | apndb_t apndb[] = { |
Cumulocity | 53:76de473cf5a7 | 8 | { .mcc = "262", .mnc = "01", .carrier = "Telekom Deutschland", .apn = "internet.m2mportal.de" }, |
Cumulocity | 53:76de473cf5a7 | 9 | { .mcc = "262", .mnc = "02", .carrier = "Telekom", .apn = "m2m.business" }, |
Cumulocity | 44:e34e48130533 | 10 | { .mcc = "232", .mnc = "03", .carrier = "Telekom", .apn = "m2m.business" }, |
Cumulocity | 42:104746744af8 | 11 | { .mcc = "262", .mnc = "06", .carrier = "Telekom", .apn = "m2m.business" }, |
Cumulocity | 42:104746744af8 | 12 | { .mcc = "204", .mnc = "04", .carrier = "Vodafone NL", .apn = "public4.m2minternet.com" }, |
Cumulocity | 42:104746744af8 | 13 | { .mcc = NULL, .mnc = NULL, .carrier = NULL, .apn = NULL } // ending terminator |
vwochnik | 23:0a48eebaaba8 | 14 | }; |
vwochnik | 23:0a48eebaaba8 | 15 | |
vwochnik | 23:0a48eebaaba8 | 16 | apndb_t * apndb_get(const char * imsi) |
vwochnik | 23:0a48eebaaba8 | 17 | { |
vwochnik | 23:0a48eebaaba8 | 18 | char chr1[8], chr2[8]; |
vwochnik | 23:0a48eebaaba8 | 19 | size_t len; |
Cumulocity | 42:104746744af8 | 20 | size_t i; |
vwochnik | 23:0a48eebaaba8 | 21 | |
Cumulocity | 42:104746744af8 | 22 | i = 0; |
Cumulocity | 42:104746744af8 | 23 | while (apndb[i].mcc != NULL) { |
vwochnik | 23:0a48eebaaba8 | 24 | strcpy(chr1, apndb[i].mcc); |
vwochnik | 23:0a48eebaaba8 | 25 | strcat(chr1, apndb[i].mnc); |
vwochnik | 23:0a48eebaaba8 | 26 | len = strlen(chr1); |
vwochnik | 23:0a48eebaaba8 | 27 | strncpy(chr2, imsi, len); |
vwochnik | 23:0a48eebaaba8 | 28 | chr2[len] = '\0'; |
vwochnik | 23:0a48eebaaba8 | 29 | |
vwochnik | 23:0a48eebaaba8 | 30 | if (strcmp(chr1, chr2) == 0) |
vwochnik | 23:0a48eebaaba8 | 31 | return &apndb[i]; |
Cumulocity | 42:104746744af8 | 32 | i++; |
vwochnik | 23:0a48eebaaba8 | 33 | } |
vwochnik | 23:0a48eebaaba8 | 34 | |
vwochnik | 23:0a48eebaaba8 | 35 | return NULL; |
vwochnik | 23:0a48eebaaba8 | 36 | } |