portable version of the cumulocity demo

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Committer:
Cumulocity
Date:
Thu Jul 24 14:17:07 2014 +0000
Revision:
42:104746744af8
Parent:
29:853741b9ea3b
Child:
44:e34e48130533
added telekom apn, minor improvements

Who changed what in which revision?

UserRevisionLine numberNew 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 42:104746744af8 8 { .mcc = "262", .mnc = "02", .carrier = "Telekom", .apn = "m2m.business" },
Cumulocity 42:104746744af8 9 { .mcc = "262", .mnc = "06", .carrier = "Telekom", .apn = "m2m.business" },
Cumulocity 42:104746744af8 10 { .mcc = "204", .mnc = "04", .carrier = "Vodafone NL", .apn = "public4.m2minternet.com" },
Cumulocity 42:104746744af8 11 { .mcc = NULL, .mnc = NULL, .carrier = NULL, .apn = NULL } // ending terminator
vwochnik 23:0a48eebaaba8 12 };
vwochnik 23:0a48eebaaba8 13
vwochnik 23:0a48eebaaba8 14 apndb_t * apndb_get(const char * imsi)
vwochnik 23:0a48eebaaba8 15 {
vwochnik 23:0a48eebaaba8 16 char chr1[8], chr2[8];
vwochnik 23:0a48eebaaba8 17 size_t len;
Cumulocity 42:104746744af8 18 size_t i;
vwochnik 23:0a48eebaaba8 19
Cumulocity 42:104746744af8 20 i = 0;
Cumulocity 42:104746744af8 21 while (apndb[i].mcc != NULL) {
vwochnik 23:0a48eebaaba8 22 strcpy(chr1, apndb[i].mcc);
vwochnik 23:0a48eebaaba8 23 strcat(chr1, apndb[i].mnc);
vwochnik 23:0a48eebaaba8 24 len = strlen(chr1);
vwochnik 23:0a48eebaaba8 25 strncpy(chr2, imsi, len);
vwochnik 23:0a48eebaaba8 26 chr2[len] = '\0';
vwochnik 23:0a48eebaaba8 27
vwochnik 23:0a48eebaaba8 28 if (strcmp(chr1, chr2) == 0)
vwochnik 23:0a48eebaaba8 29 return &apndb[i];
Cumulocity 42:104746744af8 30 i++;
vwochnik 23:0a48eebaaba8 31 }
vwochnik 23:0a48eebaaba8 32
vwochnik 23:0a48eebaaba8 33 return NULL;
vwochnik 23:0a48eebaaba8 34 }