Forked ethernet interface library
Dependencies: Socket lwip-eth lwip-sys lwip
Dependents: CI-data-logger-server
Fork of EthernetInterface by
Diff: EthernetInterface.cpp
- Revision:
- 55:894e18951229
- Parent:
- 37:926eb6517318
--- a/EthernetInterface.cpp Wed May 11 22:18:04 2016 +0000 +++ b/EthernetInterface.cpp Sun Jun 18 03:31:42 2017 +0000 @@ -26,6 +26,7 @@ #include "lwip/tcpip.h" #include "mbed.h" +#include "string.h" /* TCP/IP and Network Interface Initialisation */ static struct netif netif; @@ -35,6 +36,7 @@ static char gateway[17] = "\0"; static char networkmask[17] = "\0"; static bool use_dhcp = false; +static char myName[33]; // holds the name, when setName() is called static Semaphore tcpip_inited(0); static Semaphore netif_linked(0); @@ -137,6 +139,22 @@ return 0; } +int EthernetInterface::setName(const char * myname) { + int i; + + strncpy(myName, myname, 32); + myName[32] = '\0'; // be sure it is NULL terminated. + // make the name 'safe' + /*for (i=0; i<32 && myName[i]; i++) { + if (!inRange(myName[i], '0', '9') + && !inRange(myName[i], 'A', 'Z') + && !inRange(myName[i], 'a', 'z')) + myName[i] = '-'; + }*/ + netif_set_hostname(&netif, myName); + return 0; +} + char* EthernetInterface::getMACAddress() { return mac_addr; }