Espressif ESP32-S2 Programming Manual page 612

Hide thumbs Also See for ESP32-S2:
Table of Contents

Advertisement

Chapter 2. API Reference
/* Load server private key */
extern const
unsigned char
start");
extern const
unsigned char
end");
https_conf.prvtkey_pem
https_conf.prvtkey_len
esp_local_ctrl_config_t config
.transport
.transport_config
.httpd
},
.proto_sec
.version
.custom_handle
.pop
=
},
.handlers
=
/* User defined handler functions */
.get_prop_values
.set_prop_values
.usr_ctx
.usr_ctx_free_fn
},
/* Maximum number of properties that may be set */
.max_properties
};
/* Start esp_local_ctrl service */
ESP_ERROR_CHECK(esp_local_ctrl_start(&config));
You may set security for transport in ESP local control using following options:
1. PROTOCOM_SEC1: specifies that end to end encryption is used.
2. PROTOCOM_SEC0: specifies that data will be exchanged as a plain text.
3. PROTOCOM_SEC_CUSTOM: you can define your own security requirement. Please note that you will also
have to provide custom_handle of type protocomm_security_t * in this context.
Creating a property
Now that we know how to start the esp_local_ctrl service, let's add a property to it. Each property must have a
unique name (string), a type (e.g. enum), flags (bit fields) and size.
The size is to be kept 0, if we want our property value to be of variable length (e.g. if its a string or bytestream). For
fixed length property value data-types, like int, float, etc., setting the size field to the right value, helps esp_local_ctrl
to perform internal checks on arguments received with write requests.
The interpretation of type and flags fields is totally upto the application, hence they may be used as enumerations, bit-
fields, or even simple integers. One way is to use type values to classify properties, while flags to specify characteristics
of a property.
Here is an example property which is to function as a timestamp. It is assumed that the application defines
TYPE_TIMESTAMP and READONLY, which are used for setting the type and flags fields here.
/* Create a timestamp property */
esp_local_ctrl_prop_t timestamp
.name
.type
.size
.flags
Espressif Systems
prvtkey_pem_start[]
prvtkey_pem_end[]
=
prvtkey_pem_start;
=
prvtkey_pem_end
=
{
=
ESP_LOCAL_CTRL_TRANSPORT_HTTPD,
=
{
=
&https_conf
=
{
=
PROTOCOM_SEC0,
=
NULL,
NULL,
{
=
get_property_values,
=
set_property_values,
=
NULL,
=
NULL
=
10
=
{
=
"timestamp",
=
TYPE_TIMESTAMP,
=
sizeof(int32_t),
=
READONLY,
Submit Document Feedback
asm("_binary_prvtkey_pem_
asm("_binary_prvtkey_pem_
-
prvtkey_pem_start;
601
(continued from previous page)
(continues on next page)
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF