Chapter 2. API Reference
Protocomm internally uses protobuf (protocol buffers) for secure session establishment. Though users can implement
their own security (even without using protobuf). One can even use protocomm without any security layer.
Protocomm provides framework for various transports - WiFi (SoftAP+HTTPD), BLE, console - in which case the
handler invocation is automatically taken care of on the device side (see Transport Examples below for code snippets).
Note that the client still needs to establish session (only for protocomm_security1) by performing the two way hand-
shake. See
Unified Provisioning
Transport Example (SoftAP + HTTP) with Security 1
For complete example see
/* Endpoint handler to be registered with protocomm.
* This simply echoes back the received data. */
esp_err_t
echo_req_handler
{
/* Session ID may be used for persistence */
printf("Session ID :
/* Echo back the received data */
*outlen
=
inlen;
*outbuf
=
malloc(inlen);
memcpy(*outbuf, inbuf, inlen);
/* Private data that was passed at the time of endpoint creation */
uint32_t
*priv
if
(priv) {
printf("Private data :
}
return
ESP_OK;
}
/* Example function for launching a protocomm instance over HTTP */
protocomm_t
*start_pc(const
{
protocomm_t *pc
/* Config for protocomm_httpd_start() */
protocomm_httpd_config_t pc_config
.data
=
.config
}
};
/* Start protocomm server on top of HTTP */
protocomm_httpd_start(pc, &pc_config);
/* Create Proof of Possession object from pop_string. It must be valid
* throughout the scope of protocomm endpoint. This need not
static,
→
* ie. could be dynamically allocated and freed at the time
endpoint
→
* removal */
const static
.data
=
.len
=
Espressif Systems
for more details about the secure handshake logic.
provisioning/legacy/softap_prov
(uint32_t
const
uint8_t
uint8_t
void
*priv_data)
%d", session_id);
/* Output data length updated */
/* This will be deallocated outside */
=
(uint32_t
*) priv_data;
%d", *priv);
char
*pop_string)
=
protocomm_new();
{
=
PROTOCOMM_HTTPD_DEFAULT_CONFIG()
protocomm_security_pop_t pop_obj
(const
uint8_t
*) strdup(pop_string),
strlen(pop_string)
Submit Document Feedback
session_id,
*inbuf,
ssize_t
**outbuf,
ssize_t
*outlen,
=
{
=
{
665
inlen,
be␣
of␣
(continues on next page)
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?