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
apndb.cpp@29:853741b9ea3b, 2014-05-26 (annotated)
- Committer:
- vwochnik
- Date:
- Mon May 26 08:10:27 2014 +0000
- Revision:
- 29:853741b9ea3b
- Parent:
- 28:2004400abeec
minor fixes for modem connection
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 | #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 | } |