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
pull/13338/head
harshal.patil 2024-03-04 16:28:13 +05:30
rodzic acb733845f
commit 483b87750c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 5B5EC97C35B9A2E5
2 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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)