Merge branch 'docs/custom_endpoint_response_memory_allocation' into 'master'

docs(wifi_provisioning): Use heap to allocate memory for the response

Closes IDFGH-12210

See merge request espressif/esp-idf!29402
pull/13338/head
Mahavir Jain 2024-03-05 16:30:36 +08:00
commit c8651c1041
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)