This is the coordinator node.

Dependencies:   mbed-rtos mbed Zigbee_communication EthernetInterface WebSocketClient

Revision:
6:bd6001a78537
Parent:
4:d9968ed09187
Child:
7:4b85a9051b3a
--- a/main.cpp	Tue Feb 14 04:06:35 2017 +0000
+++ b/main.cpp	Tue Feb 14 20:34:45 2017 +0000
@@ -13,7 +13,8 @@
 DigitalOut myled(LED1);
 
 Mail<char, 250> mymail;
-XBee xbee(p8, p13, p14, &mymail);
+Mail<char[256], 16> webmail;
+XBee xbee(p8, p13, p14, &mymail, &webmail);
 
 void ReadSerial()
 {
@@ -28,6 +29,9 @@
     char PanID[2] = {PANIDMSB, PANIDLSB};
     
     xbee.SendATCommand('I', 'D', &PanID[0], 2);
+    wait(5);
+    xbee.SendATCommand('M','Y');
+    xbee.SendATCommand('O','P');
 }
 
 void BroadcastHelloWorld()
@@ -70,6 +74,21 @@
     }
 }
 
+void web()
+{
+    while (true) {
+        osEvent evt = webmail.get();
+        if (evt.status == osEventMail) 
+        {
+            pc.printf("received");
+            char *c = (char*)evt.value.p;
+            // Send email
+            pc.printf(c);
+            mymail.free(c);
+        }
+    }
+}
+
 int main() {
     pc.printf("\r\nI am coordinator\r\n");
     
@@ -78,10 +97,17 @@
     
     Thread thread(xbee_reader);
     Thread thread_reader(msg_reader);
+    Thread thread2(web);
     
     wait(3);
     ReadSerial();
     InitialisePANID(0x42, 0x69);
+    
+    xbee.appendBuffer("This message contains numbers ");
+    xbee.appendBuffer("1");
+    xbee.appendBuffer("0");
+    xbee.sendBuffer();
+    
     BroadcastHelloWorld();
     
     while(1) {