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: C12832_lcd EthernetInterface WebSocketClient mbed-rtos mbed
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "C12832_lcd.h" // Include for LCD code 00004 #include "Websocket.h" 00005 00006 C12832_LCD lcd; //Initialize LCD Screen 00007 DigitalOut led(LED1); 00008 int main() { 00009 00010 static const char* mbedIp = "192.168.137.2"; //IP 00011 static const char* mbedMask = "255.255.255.0"; // Mask 00012 static const char* mbedGateway = "192.168.137.1"; //Gateway 00013 00014 EthernetInterface eth; 00015 // eth.init(); //Use DHCP 00016 eth.init(mbedIp,mbedMask,mbedGateway); 00017 eth.connect(); 00018 printf("IP Address is %s\n", eth.getIPAddress()); // display at terminal 00019 lcd.printf("IP address: %s \n",eth.getIPAddress()); // display LCD screen 00020 00021 00022 // websocket 00023 Websocket ws("ws://192.168.1.109:8000/ws"); 00024 bool c = ws.connect(); 00025 printf("Connect result: %s\n", c?"OK":"Failed"); 00026 00027 ws.send("hello world"); 00028 00029 }
Generated on Tue Jul 12 2022 14:10:31 by
1.7.2