portable version of the cumulocity demo

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

apndb.cpp

Committer:
Cumulocity
Date:
2014-07-24
Revision:
42:104746744af8
Parent:
29:853741b9ea3b
Child:
44:e34e48130533

File content as of revision 42:104746744af8:

#include "apndb.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"

// Contains all tuples
apndb_t apndb[] = {
    { .mcc = "262", .mnc = "02", .carrier = "Telekom", .apn = "m2m.business" },
    { .mcc = "262", .mnc = "06", .carrier = "Telekom", .apn = "m2m.business" },
    { .mcc = "204", .mnc = "04", .carrier = "Vodafone NL", .apn = "public4.m2minternet.com" },
    { .mcc = NULL, .mnc = NULL, .carrier = NULL, .apn = NULL } // ending terminator
};

apndb_t * apndb_get(const char * imsi)
{
    char chr1[8], chr2[8];
    size_t len;
    size_t i;
    
    i = 0;
    while (apndb[i].mcc != NULL) {
        strcpy(chr1, apndb[i].mcc);
        strcat(chr1, apndb[i].mnc);
        len = strlen(chr1);
        strncpy(chr2, imsi, len);
        chr2[len] = '\0';
        
        if (strcmp(chr1, chr2) == 0)
            return &apndb[i];
        i++;
    }
    
    return NULL;
}