Official reference client implementation for Cumulocity SmartREST on u-blox C027.

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Vincent Wochnik

Files at this revision

API Documentation at this revision

Comitter:
xinlei
Date:
Wed Mar 04 11:14:30 2015 +0000
Parent:
79:f7330a8013ed
Child:
81:4a7761914901
Commit message:
Display MCC-MNC when join network fails.

Changed in this revision

MbedAgent.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/MbedAgent.h	Wed Mar 04 09:38:46 2015 +0000
+++ b/MbedAgent.h	Wed Mar 04 11:14:30 2015 +0000
@@ -20,8 +20,8 @@
 #include "LocationUpdate.h"
 #include "OperationSupport.h"
 
-//#define MBED_AGENT_HOST "management.m2m-devicecloud.com"
-#define MBED_AGENT_HOST "developer.cumulocity.com"
+#define MBED_AGENT_HOST "management.m2m-devicecloud.com"
+//#define MBED_AGENT_HOST "developer.cumulocity.com"
 #define MBED_AGENT_PORT 80
 #define MBED_AGENT_DEVICE_IDENTIFIER "com_cumulocity_MbedAgent_1.5.2"
 
--- a/main.cpp	Wed Mar 04 09:38:46 2015 +0000
+++ b/main.cpp	Wed Mar 04 11:14:30 2015 +0000
@@ -23,6 +23,13 @@
 //#define SIM_USER ""
 //#define SIM_PASS ""
 
+unsigned short getMNCLen(const char *imsi) {
+    if (strncmp(imsi, "310", 3) != 0) // Non American ISMI
+        return 2;
+    else
+        return 3;
+}
+
 int main()
 {
     MDMParser::DevStatus devStatus;
@@ -67,7 +74,12 @@
 #else
     if (mdm.join() == NOIP) {
 #endif
-        io.lcdPrint("Network join failure", "Wrong APN settting,", "username and password");
+        char s[8] = "unknown";
+        const char *p = devStatus.imsi;
+        if (p) {
+            snprintf(s, sizeof(s), "%.*s-%.*s", 3, p, getMNCLen(p), p+3);
+        }
+        io.lcdPrint("Wrong APN settting", "MCC-MNC:", s);
         goto error;
     }