Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FINAL_PROJECT_4180 WebSocketClient WiflyInterface mbed-rtos mbed
Fork of Websocket_Wifly_HelloWorld by
main.cpp@1:31e50fea8be8, 2012-08-23 (annotated)
- Committer:
- samux
- Date:
- Thu Aug 23 14:09:06 2012 +0000
- Revision:
- 1:31e50fea8be8
- Parent:
- 0:64c683256184
- Child:
- 3:b88f93478f07
update with the last wiflyInterface/websocket library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| samux | 1:31e50fea8be8 | 1 | #include "mbed.h" |
| samux | 1:31e50fea8be8 | 2 | #include "WiflyInterface.h" |
| samux | 1:31e50fea8be8 | 3 | #include "Websocket.h" |
| samux | 1:31e50fea8be8 | 4 | |
| samux | 1:31e50fea8be8 | 5 | |
| samux | 1:31e50fea8be8 | 6 | /* wifly interface: |
| samux | 1:31e50fea8be8 | 7 | * - p9 and p10 are for the serial communication |
| samux | 1:31e50fea8be8 | 8 | * - p19 is for the reset pin |
| samux | 1:31e50fea8be8 | 9 | * - p26 is for the connection status |
| samux | 1:31e50fea8be8 | 10 | * - "mbed" is the ssid of the network |
| samux | 1:31e50fea8be8 | 11 | * - "password" is the password |
| samux | 1:31e50fea8be8 | 12 | * - WPA is the security |
| samux | 1:31e50fea8be8 | 13 | */ |
| samux | 1:31e50fea8be8 | 14 | WiflyInterface wifly(p9, p10, p19, p26, "mbed", "password", WPA); |
| samux | 1:31e50fea8be8 | 15 | |
| samux | 1:31e50fea8be8 | 16 | int main() { |
| samux | 1:31e50fea8be8 | 17 | wifly.init(); //Use DHCP |
| samux | 1:31e50fea8be8 | 18 | while (!wifly.connect()); |
| samux | 1:31e50fea8be8 | 19 | printf("IP Address is %s\n\r", wifly.getIPAddress()); |
| samux | 1:31e50fea8be8 | 20 | |
| samux | 1:31e50fea8be8 | 21 | Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo"); |
| samux | 1:31e50fea8be8 | 22 | while (!ws.connect()); |
| samux | 1:31e50fea8be8 | 23 | |
| samux | 1:31e50fea8be8 | 24 | while (1) { |
| samux | 1:31e50fea8be8 | 25 | ws.send("WebSocket Hello World over Wifly"); |
| samux | 1:31e50fea8be8 | 26 | wait(1.0); |
| samux | 1:31e50fea8be8 | 27 | } |
| samux | 0:64c683256184 | 28 | } |
