W5500 driver for mbed OS 5
Dependents: http-webserver-example mbed-os-example-sockets
Fork of W5500Interface by
Diff: W5500Interface.h
- Revision:
- 18:afec30f0922a
- Parent:
- 17:60f75e78f35d
--- a/W5500Interface.h Tue Aug 14 01:20:36 2018 +0000 +++ b/W5500Interface.h Thu Aug 16 07:33:40 2018 +0000 @@ -109,6 +109,29 @@ */ virtual const char *get_mac_address(); + /** Set a static IP address + * + * Configures this network interface to use a static IP address. + * Implicitly disables DHCP, which can be enabled in set_dhcp. + * Requires that the network is disconnected. + * + * @param ip_address Null-terminated representation of the local IP address + * @param netmask Null-terminated representation of the local network mask + * @param gateway Null-terminated representation of the local gateway + * @return 0 on success, negative error code on failure + */ + virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway); + + /** Enable or disable DHCP on the network + * + * Enables DHCP on connecting the network. Defaults to enabled unless + * a static IP address has been assigned. Requires that the network is + * disconnected. + * + * @param dhcp True to enable DHCP + * @return 0 on success, negative error code on failure + */ + virtual nsapi_error_t set_dhcp(bool dhcp); bool setDnsServerIP(const char* ip_address); @@ -304,10 +327,10 @@ private: WIZnet_Chip _w5500; - char ip_string[20]; - char netmask_string[20]; - char gateway_string[20]; - char mac_string[20]; + char ip_string[NSAPI_IPv4_SIZE]; + char netmask_string[NSAPI_IPv4_SIZE]; + char gateway_string[NSAPI_IPv4_SIZE]; + char mac_string[NSAPI_MAC_SIZE]; bool ip_set; int listen_port;