APP Team / Mbed 2 deprecated app4Coordo

Dependencies:   mbed ConfigFile EthernetInterface WebSocketClient mbed-rtos

Fork of app4Coordo by APP Team

Revision:
3:85025db3fbd1
Parent:
2:5942af2ffe8b
Child:
4:7d7d6e4b6810
--- a/main.cpp	Sat Feb 22 23:45:52 2014 +0000
+++ b/main.cpp	Mon Feb 24 18:57:38 2014 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include <string>
+#include "ConfigFile.h"
 
 DigitalOut myled(LED1);
 DigitalOut myled2(LED2);
@@ -10,8 +11,37 @@
 string test;
 bool trame_ready;
 
+LocalFileSystem local("local");
+ConfigFile cfg;
+
 enum {STEP_START, STEP_LENGTH, STEP_TYPE, STEP_MAC, STEP_NET, STEP_OPT, STEP_DATA, STEP_CHECK};
 
+void configInit()
+{
+    char *key1 = "PANID";
+    char *key2 = "URL";
+    char value[BUFSIZ];
+    
+    // Read a configuration file from a mbed.   
+    if (!cfg.read("/local/initconf.cfg")) 
+    {
+        error("Failure to read a configuration file.\n");
+    }
+ 
+    /*
+     * Get a configuration value.
+     */
+    if (cfg.getValue(key1, &value[0], sizeof(value))) 
+    {
+        printf("'%s'='%s'\n", key1, value);
+    }
+    
+    if (cfg.getValue(key2, &value[0], sizeof(value))) 
+    {
+        printf("'%s'='%s'\n", key2, value);
+    }
+}
+
 void xbee_init()
 {
     reset = 0;
@@ -113,6 +143,8 @@
 
 int main() 
 {
+    
+    configInit();
     xbee_init();