NerfUS
Dependencies: mbed mbed-rtos HardwareInterface EthernetInterface WebSocketClient
main.cpp@17:8c77b958edd7, 2017-03-01 (annotated)
- Committer:
- ericmatte
- Date:
- Wed Mar 01 03:55:37 2017 +0000
- Revision:
- 17:8c77b958edd7
- Parent:
- 13:850be84c78dd
Working Ethernet
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dupm2216 | 1:ed506b2298b4 | 1 | #include "rtos.h" |
Maxime Dupuis |
13:850be84c78dd | 2 | #include "HardwareLPC1768.hpp" |
ericmatte | 17:8c77b958edd7 | 3 | #include "WSRequest.hpp" |
dupm2216 | 0:e7c4a5d26268 | 4 | |
dupm2216 | 11:6ce1d834ecb7 | 5 | DigitalOut led(LED1); |
dupm2216 | 0:e7c4a5d26268 | 6 | |
ericmatte | 17:8c77b958edd7 | 7 | /** Allow simple communication with a websocket server */ |
ericmatte | 17:8c77b958edd7 | 8 | void serverCommunication() |
ericmatte | 17:8c77b958edd7 | 9 | { |
ericmatte | 17:8c77b958edd7 | 10 | WSRequest server("ws://192.168.64.42:8000/"); |
ericmatte | 17:8c77b958edd7 | 11 | char buf[32] = "Testing the server"; |
ericmatte | 17:8c77b958edd7 | 12 | printf("Sending message to server: %s", buf); |
ericmatte | 17:8c77b958edd7 | 13 | server.send(buf); |
ericmatte | 17:8c77b958edd7 | 14 | |
ericmatte | 17:8c77b958edd7 | 15 | while(1) |
ericmatte | 17:8c77b958edd7 | 16 | { |
ericmatte | 17:8c77b958edd7 | 17 | server.onMessage(buf); |
ericmatte | 17:8c77b958edd7 | 18 | printf("Received: %s\n\r", buf); |
ericmatte | 17:8c77b958edd7 | 19 | } |
ericmatte | 17:8c77b958edd7 | 20 | } |
ericmatte | 17:8c77b958edd7 | 21 | |
Maxime Dupuis |
2:6e467e4978f9 | 22 | int main() |
Maxime Dupuis |
2:6e467e4978f9 | 23 | { |
ericmatte | 17:8c77b958edd7 | 24 | // serverCommunication(); |
ericmatte | 17:8c77b958edd7 | 25 | |
Maxime Dupuis |
13:850be84c78dd | 26 | HardwareLPC1768 hardware_lpc1768(led); |
Maxime Dupuis |
2:6e467e4978f9 | 27 | while(1) |
Maxime Dupuis |
2:6e467e4978f9 | 28 | { |
ericmatte | 17:8c77b958edd7 | 29 | |
Maxime Dupuis |
13:850be84c78dd | 30 | hardware_lpc1768.blink(); |
dupm2216 | 0:e7c4a5d26268 | 31 | } |
dupm2216 | 0:e7c4a5d26268 | 32 | } |
dupm2216 | 11:6ce1d834ecb7 | 33 |