aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
978 stars 625 forks source link

How would I get the IPV4 address of a device within the Mutual Auth demo example #1788

Closed readysteadygo2006 closed 2 years ago

readysteadygo2006 commented 2 years ago

Hi,

I'm building an application using the AWS SDK Mutual Auth demo as a starting point.

I want to get the IPV4 address of the device.

Normally I could use code such shown below to get the IP:

esp_netif_t *netif = **????**
esp_netif_ip_info_t ip_info;
esp_netif_get_ip_info(netif, &ip_info);
printf("My IP: " IPSTR "\n", IP2STR(&ip_info.ip));

However in the context of the demo example how do I initialize netif?

Thanks for any help you can provide!

tianmc1 commented 2 years ago

Hi @readysteadygo2006 ,

The demos in aws-iot-device-sdk-embedded-C runs on a POSIX machine (e.g. a laptop). Therefore the ESP specific code does not apply here. If you are running the demo on Linux, you can use getifaddrs to get information including IP address on the network interfaces. If the code is later used on a FreeRTOS embedded device, you can use FreeRTOS_GetAddressConfiguration().