OK View: http://sockets.mbed.org/demo/viewer
Dependencies: MMA7660 WebSocketClient WiflyInterface mbed
Fork of Websocket_Wifly_HelloWorld by
main.cpp@0:64c683256184, 2012-08-17 (annotated)
- Committer:
- samux
- Date:
- Fri Aug 17 12:01:03 2012 +0000
- Revision:
- 0:64c683256184
- Child:
- 1:31e50fea8be8
websocket with the new wifly interface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 0:64c683256184 | 1 | #include "mbed.h" |
samux | 0:64c683256184 | 2 | #include "WiflyInterface.h" |
samux | 0:64c683256184 | 3 | #include "Websocket.h" |
samux | 0:64c683256184 | 4 | |
samux | 0:64c683256184 | 5 | |
samux | 0:64c683256184 | 6 | /* wifly interface: |
samux | 0:64c683256184 | 7 | * - p9 and p10 are for the serial communication |
samux | 0:64c683256184 | 8 | * - p25 is for the reset pin |
samux | 0:64c683256184 | 9 | * - p26 is for the connection status |
samux | 0:64c683256184 | 10 | * - "mbed" is the ssid of the network |
samux | 0:64c683256184 | 11 | * - "password" is the password |
samux | 0:64c683256184 | 12 | * - true means that the security of the network is WPA |
samux | 0:64c683256184 | 13 | */ |
samux | 0:64c683256184 | 14 | WiflyInterface wifly(p9, p10, p25, p26, "mbed", "password", true); |
samux | 0:64c683256184 | 15 | |
samux | 0:64c683256184 | 16 | int main() { |
samux | 0:64c683256184 | 17 | wifly.init(); //Use DHCP |
samux | 0:64c683256184 | 18 | while (!wifly.connect()); |
samux | 0:64c683256184 | 19 | printf("IP Address is %s\n\r", wifly.getIPAddress()); |
samux | 0:64c683256184 | 20 | |
samux | 0:64c683256184 | 21 | Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo"); |
samux | 0:64c683256184 | 22 | while (!ws.connect()); |
samux | 0:64c683256184 | 23 | |
samux | 0:64c683256184 | 24 | while (1) { |
samux | 0:64c683256184 | 25 | ws.send("WebSocket Hello World over Wifly"); |
samux | 0:64c683256184 | 26 | wait(1.0); |
samux | 0:64c683256184 | 27 | } |
samux | 0:64c683256184 | 28 | } |