mini code pour xbee

Dependencies:   mbed ConfigFile EthernetInterface WebSocketClient mbed-rtos

Fork of app4Coordo by APP Team

Files at this revision

API Documentation at this revision

Comitter:
passelin
Date:
Mon Feb 24 18:57:38 2014 +0000
Parent:
2:5942af2ffe8b
Child:
4:7d7d6e4b6810
Commit message:
config file fonctionnel

Changed in this revision

ConfigFile.lib 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ConfigFile.lib	Mon Feb 24 18:57:38 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/shintamainjp/code/ConfigFile/#f6ceafabe9f8
--- 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();