SmartREST client reference implementation for the u-blox C027 mbed compatible device.

Dependencies:   C027 C027_Support mbed mbed-rtos MbedSmartRest LM75B MMA7660 C12832

Fork of MbedSmartRestTest by Vincent Wochnik

Committer:
vwochnik
Date:
Thu Jul 03 18:52:04 2014 +0000
Revision:
35:ee1c6289e617
Parent:
29:853741b9ea3b
official cumulocity library

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 #define APNDB_COUNT 5
vwochnik 23:0a48eebaaba8 7
vwochnik 23:0a48eebaaba8 8 // Contains all tuples
vwochnik 23:0a48eebaaba8 9 apndb_t apndb[] = {
vwochnik 29:853741b9ea3b 10 { .mcc = "204", .mnc = "04", .carrier = "Vodafone NL", .apn = "public4.m2minternet.com" }
vwochnik 23:0a48eebaaba8 11 };
vwochnik 23:0a48eebaaba8 12
vwochnik 23:0a48eebaaba8 13 apndb_t * apndb_get(const char * imsi)
vwochnik 23:0a48eebaaba8 14 {
vwochnik 23:0a48eebaaba8 15 char chr1[8], chr2[8];
vwochnik 23:0a48eebaaba8 16 size_t len;
vwochnik 23:0a48eebaaba8 17
vwochnik 23:0a48eebaaba8 18 for (size_t i = 0; i < APNDB_COUNT; i++) {
vwochnik 23:0a48eebaaba8 19 strcpy(chr1, apndb[i].mcc);
vwochnik 23:0a48eebaaba8 20 strcat(chr1, apndb[i].mnc);
vwochnik 23:0a48eebaaba8 21 len = strlen(chr1);
vwochnik 23:0a48eebaaba8 22 strncpy(chr2, imsi, len);
vwochnik 23:0a48eebaaba8 23 chr2[len] = '\0';
vwochnik 23:0a48eebaaba8 24
vwochnik 23:0a48eebaaba8 25 if (strcmp(chr1, chr2) == 0)
vwochnik 23:0a48eebaaba8 26 return &apndb[i];
vwochnik 23:0a48eebaaba8 27 }
vwochnik 23:0a48eebaaba8 28
vwochnik 23:0a48eebaaba8 29 return NULL;
vwochnik 23:0a48eebaaba8 30 }