From 483b87750c6e0dc9772ab3733a26e5f95e3f99a9 Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Mon, 4 Mar 2024 16:28:13 +0530 Subject: [PATCH] docs(wifi_provisioning): Use heap to allocate memory for the response Added a note to specify that the memory for the response of a custom endpoint should be allocated using the heap, as this memory gets freed by the protocomm layer once it has been passed to the transport layer. Closes https://github.com/espressif/esp-idf/issues/13263 --- docs/en/api-reference/provisioning/wifi_provisioning.rst | 2 +- examples/provisioning/wifi_prov_mgr/main/app_main.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/api-reference/provisioning/wifi_provisioning.rst b/docs/en/api-reference/provisioning/wifi_provisioning.rst index 3b7ffc59e1..e9c4364177 100644 --- a/docs/en/api-reference/provisioning/wifi_provisioning.rst +++ b/docs/en/api-reference/provisioning/wifi_provisioning.rst @@ -264,7 +264,7 @@ The client can also control the provisioning state of the device using ``wifi_ct Additional Endpoints ^^^^^^^^^^^^^^^^^^^^ -In case users want to have some additional protocomm endpoints customized to their requirements, this is done in two steps. First is creation of an endpoint with a specific name, and the second step is the registration of a handler for this endpoint. See :doc:`protocomm` for the function signature of an endpoint handler. A custom endpoint must be created after initialization and before starting the provisioning service. Whereas, the protocomm handler is registered for this endpoint only after starting the provisioning service. +In case users want to have some additional protocomm endpoints customized to their requirements, this is done in two steps. First is creation of an endpoint with a specific name, and the second step is the registration of a handler for this endpoint. See :doc:`protocomm` for the function signature of an endpoint handler. A custom endpoint must be created after initialization and before starting the provisioning service. Whereas, the protocomm handler is registered for this endpoint only after starting the provisioning service. Note that in the custom endpoint handler function, memory for the response of such protocomm endpoints should be allocated using heap as it gets freed by the protocomm layer once it has been sent by the transport layer. .. code-block:: c diff --git a/examples/provisioning/wifi_prov_mgr/main/app_main.c b/examples/provisioning/wifi_prov_mgr/main/app_main.c index f6c0232872..9c5f2a5064 100644 --- a/examples/provisioning/wifi_prov_mgr/main/app_main.c +++ b/examples/provisioning/wifi_prov_mgr/main/app_main.c @@ -230,6 +230,8 @@ static void get_device_service_name(char *service_name, size_t max) /* 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. + * Note that memory for the response buffer must be allocated using heap as this buffer + * gets freed by the protocomm layer once it has been sent by the transport layer. */ 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)