websocket and ble
Dependencies: WebSocketClient WiflyInterface mbed
Diff: main.cpp
- Revision:
- 0:92abfdf28c93
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Feb 07 06:08:45 2015 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" + + +Serial device(p9,p10); +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +#include "WiflyInterface.h" +#include "Websocket.h" +WiflyInterface wifly(p13, p14, p19, p26, "WWNet", "mmmmmmmm", WPA); +char buf[10]; + +int main() { + + wifly.init(); //Use DHCP + while (!wifly.connect()); + led1=1; + + Websocket ws("ws://sockets.mbed.org/ws/mbedschool/viewer"); + while (!ws.connect()); + led2=1; + ws.send("ws connect"); + + int i=0; + //set mbed baud rate the same as BLE mini baud rate + device.baud(38400); + //simple polling demonstrate serial communication + while(1) { + if(device.readable()) { + char data[1]; + data[0] = device.getc(); + ws.send(data); + + i++; + } + wait(0.1); + } +}