Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Fix: Support for lwip getip with espressif (#2135)
Browse files Browse the repository at this point in the history
* Fix: Support for lwip getip with espressif

* Update iot_wifi.c

* Update iot_test_wifi.c

* Update iot_wifi.c

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
Co-authored-by: Archit Aggarwal <architag@amazon.com>
  • Loading branch information
3 people authored Jun 30, 2020
1 parent e1333c4 commit 814b5b1
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions vendors/espressif/boards/esp32/ports/wifi/iot_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#if AFR_ESP_LWIP
#include "lwip/dns.h"
#include "lwip/netdb.h"
#include "tcpip_adapter.h"
#else
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
Expand Down Expand Up @@ -1072,29 +1073,55 @@ WIFIReturnCode_t WIFI_Ping( uint8_t * pucIPAddr,
return eWiFiNotSupported;
}
/*-----------------------------------------------------------*/

WIFIReturnCode_t WIFI_GetIP( uint8_t * pucIPAddr )
{
WIFIReturnCode_t xRetVal = eWiFiFailure;

if (pucIPAddr == NULL) {
return xRetVal;
}
#if !AFR_ESP_LWIP
/* Try to acquire the semaphore. */
if( xSemaphoreTake( xWiFiSem, xSemaphoreWaitTicks ) == pdTRUE )
{
#if !AFR_ESP_LWIP
*( ( uint32_t * ) pucIPAddr ) = FreeRTOS_GetIPAddress();
xRetVal = eWiFiSuccess;
configPRINTF(("%s: local ip address is %d.%d.%d.%d\n",
__FUNCTION__,
pucIPAddr[0],
pucIPAddr[1],
pucIPAddr[2],
pucIPAddr[3]));
#else /* running lwip */
tcpip_adapter_ip_info_t ipInfo;
int ret;

ret = tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ipInfo);
if (ret == ESP_OK)
{
xRetVal = eWiFiSuccess;
memcpy( pucIPAddr, &ipInfo.ip.addr, sizeof( ipInfo.ip.addr ) );
configPRINTF(("%s: local ip address is %d.%d.%d.%d\n",
__FUNCTION__,
pucIPAddr[0],
pucIPAddr[1],
pucIPAddr[2],
pucIPAddr[3]));
}
else
{
configPRINTF(("%s: tcpip_adapter_get_ip_info_error: %d",
__FUNCTION__,
ret));
}
#endif
/* Return the semaphore. */
xSemaphoreGive( xWiFiSem );
}
else
{
xRetVal = eWiFiTimeout;
}
#endif

return xRetVal;
}
/*-----------------------------------------------------------*/
Expand Down

0 comments on commit 814b5b1

Please sign in to comment.