WiFi: Decuple IP stack bringup and IP address provisioning

pull/3975/head
Bartek Szatkowski 2016-09-26 16:53:18 +01:00 committed by Martin Kojtal
parent c80641fe11
commit f122695fd3
3 changed files with 29 additions and 5 deletions

View File

@ -34,6 +34,16 @@ void IPStackInterface::bringdown()
lwip_bringdown();
}
int IPStackInterface::start_dhcp(uint timeout)
{
return lwip_start_dhcp(timeout);
}
int IPStackINterface::start_static_ip(const char *ip, const char *netmask, const char *gw)
{
return lwip_start_static_ip();
}
const char * IPStackInterface::get_mac_address()
{
return lwip_get_mac_address();

View File

@ -403,7 +403,7 @@ int lwip_bringup(emac_interface_t *emac, bool dhcp, const char *ip, const char *
}
// Zero out socket set
lwip_arena_init();
lwip_arena_init(15000);
#if LWIP_IPV6
netif_create_ip6_linklocal_address(&lwip_netif, 1/*from MAC*/);
@ -510,10 +510,6 @@ int lwip_bringdown(void)
}
#endif
lwip_connected = false;
// TO DO - actually remove addresses from stack, and shut down properly
return 0;
}
/* LWIP error remapping */
static int lwip_err_remap(err_t err) {

View File

@ -43,6 +43,24 @@ public:
*/
virtual void bringdown();
/**
* Sends the dhcp request
*
* @param timeout Request timeout in ms
* @return NSAPI_ERROR_OK in case of success, error code otherwise
*/
virtual int start_dhcp(uint timeout = 15000);
/**
* Starts the interface with static IP
*
* @param ip Static IP to use (in XYZ.XYZ.XYZ.XYZ format)
* @param netmask Network mask to use (in XYZ.XYZ.XYZ.XYZ format)
* @param gw Gateway IP address (in XYZ.XYZ.XYZ.XYZ format)
* @return NSAPI_ERROR_OK in case of success, error code otherwise
*/
virtual int start_static_ip(const char *ip, const char *netmask, const char *gw);
/**
* Returns MAC address
*