This is the coordinator node.

Dependencies:   mbed-rtos mbed Zigbee_communication EthernetInterface WebSocketClient

Files at this revision

API Documentation at this revision

Comitter:
ShaolinPoutine
Date:
Tue Feb 14 21:06:06 2017 +0000
Parent:
5:7019f4f6b538
Parent:
6:bd6001a78537
Commit message:
Added web comm

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.lib Show annotated file Show diff for this revision Revisions of this file
Zigbee_communication.lib Show annotated file Show diff for this revision Revisions of this file
Zigbee_communication.lib.orig 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/EthernetInterface.lib	Tue Feb 14 21:06:06 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/EthernetInterface/#183490eb1b4a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Tue Feb 14 21:06:06 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- a/Zigbee_communication.lib	Tue Feb 14 19:59:03 2017 +0000
+++ b/Zigbee_communication.lib	Tue Feb 14 21:06:06 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/APP31/code/Zigbee_communication/#902d0f74333c
+https://developer.mbed.org/teams/APP31/code/Zigbee_communication/#13ab66e244c3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Zigbee_communication.lib.orig	Tue Feb 14 21:06:06 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/APP31/code/Zigbee_communication/#902d0f74333c
--- a/main.cpp	Tue Feb 14 19:59:03 2017 +0000
+++ b/main.cpp	Tue Feb 14 21:06:06 2017 +0000
@@ -8,12 +8,17 @@
 #include "rtos.h"
 #include "xbee.h"
 
+#include "EthernetInterface.h"
+#include "Websocket.h"
+
 // 4269
 Serial pc(USBTX, USBRX);
 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);
+Websocket* ws;
 
 void ReadSerial()
 {
@@ -28,6 +33,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()
@@ -72,6 +80,14 @@
 
 int main() {
     pc.printf("\r\nI am coordinator\r\n");
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP Address is %s\n\r", eth.getIPAddress());
+ 
+    ws = new Websocket("ws://192.168.137.1:4242");
+    ws->connect();
+    
     
     Ticker ticker;
     ticker.attach(&tick, 1);
@@ -82,8 +98,17 @@
     wait(3);
     ReadSerial();
     InitialisePANID(0x42, 0x69);
-    BroadcastHelloWorld();
     
     while(1) {
+        osEvent evt = webmail.get();
+        if (evt.status == osEventMail) 
+        {
+            char *c = (char(*))evt.value.p;
+            // Send email
+            ws->send("sending");
+            ws->send(c);
+            wait(1);
+            mymail.free(c);
+        }
     }
 }
\ No newline at end of file