![](/media/cache/group/u-blox_logo_trans.png.50x50_q85.png)
portable version of the cumulocity demo
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
apndb.cpp@23:0a48eebaaba8, 2014-03-24 (annotated)
- Committer:
- vwochnik
- Date:
- Mon Mar 24 09:58:46 2014 +0000
- Revision:
- 23:0a48eebaaba8
- Child:
- 28:2004400abeec
fix
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 | 23:0a48eebaaba8 | 10 | { .mcc = "123", .mnc = "023", .apn = "apn", .user = "user", .pass = "" }, |
vwochnik | 23:0a48eebaaba8 | 11 | { .mcc = "123", .mnc = "023", .apn = "apn", .user = "user", .pass = "" }, |
vwochnik | 23:0a48eebaaba8 | 12 | { .mcc = "204", .mnc = "04", .apn = "Vodafone NL", .user = "user", .pass = "" }, |
vwochnik | 23:0a48eebaaba8 | 13 | { .mcc = "123", .mnc = "023", .apn = "apn", .user = "user", .pass = "" }, |
vwochnik | 23:0a48eebaaba8 | 14 | { .mcc = "123", .mnc = "023", .apn = "apn", .user = "user", .pass = "" } |
vwochnik | 23:0a48eebaaba8 | 15 | }; |
vwochnik | 23:0a48eebaaba8 | 16 | |
vwochnik | 23:0a48eebaaba8 | 17 | apndb_t * apndb_get(const char * imsi) |
vwochnik | 23:0a48eebaaba8 | 18 | { |
vwochnik | 23:0a48eebaaba8 | 19 | char chr1[8], chr2[8]; |
vwochnik | 23:0a48eebaaba8 | 20 | size_t len; |
vwochnik | 23:0a48eebaaba8 | 21 | |
vwochnik | 23:0a48eebaaba8 | 22 | for (size_t i = 0; i < APNDB_COUNT; i++) { |
vwochnik | 23:0a48eebaaba8 | 23 | strcpy(chr1, apndb[i].mcc); |
vwochnik | 23:0a48eebaaba8 | 24 | strcat(chr1, apndb[i].mnc); |
vwochnik | 23:0a48eebaaba8 | 25 | len = strlen(chr1); |
vwochnik | 23:0a48eebaaba8 | 26 | strncpy(chr2, imsi, len); |
vwochnik | 23:0a48eebaaba8 | 27 | chr2[len] = '\0'; |
vwochnik | 23:0a48eebaaba8 | 28 | |
vwochnik | 23:0a48eebaaba8 | 29 | if (strcmp(chr1, chr2) == 0) |
vwochnik | 23:0a48eebaaba8 | 30 | return &apndb[i]; |
vwochnik | 23:0a48eebaaba8 | 31 | } |
vwochnik | 23:0a48eebaaba8 | 32 | |
vwochnik | 23:0a48eebaaba8 | 33 | return NULL; |
vwochnik | 23:0a48eebaaba8 | 34 | } |