EasyManua.ls Logo

Espressif ESP32-S2 - Page 677

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
(continued from previous page)
};
/* Set security for communication at application level. Just like for
* request handlers, setting security creates an endpoint and
,registers
* the handler provided by protocomm_security1. One can similarly use
* protocomm_security0. Only one type of security can be set for a
* protocomm instance at a time. */
protocomm_set_security(pc, "security_endpoint", &protocomm_security1,
,&pop_obj);
/* Private data passed to the endpoint must be valid throughout the
,scope
* of protocomm endpoint. This need not be static, ie. could be
,dynamically
* allocated and freed at the time of endpoint removal */
static uint32_t priv_data = 1234;
/* Add a new endpoint for the protocomm instance, identified by a
,unique name
* and register a handler function along with private data to be
,passed at the
* time of handler execution. Multiple endpoints can be added as long
,as they
* are identified by unique names */
protocomm_add_endpoint(pc, "echo_req_endpoint",
echo_req_handler, (void *) &priv_data);
return pc;
}
/* Example function for stopping a protocomm instance */
void stop_pc(protocomm_t *pc)
{
/* Remove endpoint identified by it's unique name */
protocomm_remove_endpoint(pc, "echo_req_endpoint");
/* Remove security endpoint identified by it's name */
protocomm_unset_security(pc, "security_endpoint");
/* Stop HTTP server */
protocomm_httpd_stop(pc);
/* Delete (deallocate) the protocomm instance */
protocomm_delete(pc);
}
Transport Example (BLE) with Security 0
For complete example see provisioning/legacy/ble_prov
/* Example function for launching a secure protocomm instance over BLE */
protocomm_t *start_pc()
{
protocomm_t *pc = protocomm_new();
/* Endpoint UUIDs */
protocomm_ble_name_uuid_t nu_lookup_table[] = {
{"security_endpoint", 0xFF51},
{"echo_req_endpoint", 0xFF52}
};
(continues on next page)
Espressif Systems 666
Submit Document Feedback
Release v4.4

Table of Contents