esp-idf-provisioning-android icon indicating copy to clipboard operation
esp-idf-provisioning-android copied to clipboard

How to I get wireless network IP4 address (of ESP with Wifi, not phone with Wifi) after successful provision in Android

Open LeKyDF opened this issue 2 years ago • 6 comments

Screenshot 2023-01-04 at 11 50 24

For example in IOS

LeKyDF avatar Jan 04 '23 04:01 LeKyDF

Can anyone help me?

LeKyDF avatar Jan 04 '23 06:01 LeKyDF

Hi @LeKyDF , need to provide API to get IP address as it is not available in Android currently.

KhushbuShah25 avatar Jan 05 '23 09:01 KhushbuShah25

For the API, is it possible to retrieve the IP address before the BLE provisioning service is closed?

law-ko avatar Jan 18 '23 07:01 law-ko

Hi @khushbushah2302 , any answers to this? We understand how to use wifi_prov_mgr_endpoint_register but not sure how to implement the trigger after ESP get's IP address.

For the API, is it possible to retrieve the IP address before the BLE provisioning service is closed?

law-ko avatar Mar 21 '23 17:03 law-ko

Screen Shot 2023-03-21 at 10 15 35 AM Additional information. Can we change the provisioning library and send the IP message out before unregistering the endpoints?

law-ko avatar Mar 21 '23 17:03 law-ko

@khushbushah2302 , currently, the wifi_prov_mgr_endpoint_register only supports sending custom data out when received data coming in. However, is it possible that we can send the custom data out without receiving any data?

/* Handler for the optional provisioning endpoint registered by the application.
 * The data format can be chosen by applications. Here, we are using plain ascii text.
 * Applications can choose to use other formats like protobuf, JSON, XML, etc.
 */
esp_err_t custom_prov_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
                                          uint8_t **outbuf, ssize_t *outlen, void *priv_data)
{
    // Ignore inbuf
    if (inbuf) {
        ESP_LOGI(TAG, "Received data: %.*s", inlen, (char *)inbuf);
    }
    // Trigger based on GET_IP EVENTS
    char response[] = "{{ipv4.addr}}";
    *outbuf = (uint8_t *)strdup(response);
    if (*outbuf == NULL) {
        ESP_LOGE(TAG, "System out of memory");
        return ESP_ERR_NO_MEM;
    }
    *outlen = strlen(response) + 1; /* +1 for NULL terminating byte */

    return ESP_OK;
}

law-ko avatar Mar 24 '23 01:03 law-ko