mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-04 22:36:32 +02:00
IDF release/v4.0 08219f3cf
This commit is contained in:
@ -114,6 +114,39 @@ esp_err_t protocomm_add_endpoint(protocomm_t *pc, const char *ep_name,
|
||||
*/
|
||||
esp_err_t protocomm_remove_endpoint(protocomm_t *pc, const char *ep_name);
|
||||
|
||||
/**
|
||||
* @brief Allocates internal resources for new transport session
|
||||
*
|
||||
* @note
|
||||
* - An endpoint must be bound to a valid protocomm instance,
|
||||
* created using `protocomm_new()`.
|
||||
*
|
||||
* @param[in] pc Pointer to the protocomm instance
|
||||
* @param[in] session_id Unique ID for a communication session
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Request handled successfully
|
||||
* - ESP_ERR_NO_MEM : Error allocating internal resource
|
||||
* - ESP_ERR_INVALID_ARG : Null instance/name arguments
|
||||
*/
|
||||
esp_err_t protocomm_open_session(protocomm_t *pc, uint32_t session_id);
|
||||
|
||||
/**
|
||||
* @brief Frees internal resources used by a transport session
|
||||
*
|
||||
* @note
|
||||
* - An endpoint must be bound to a valid protocomm instance,
|
||||
* created using `protocomm_new()`.
|
||||
*
|
||||
* @param[in] pc Pointer to the protocomm instance
|
||||
* @param[in] session_id Unique ID for a communication session
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Request handled successfully
|
||||
* - ESP_ERR_INVALID_ARG : Null instance/name arguments
|
||||
*/
|
||||
esp_err_t protocomm_close_session(protocomm_t *pc, uint32_t session_id);
|
||||
|
||||
/**
|
||||
* @brief Calls the registered handler of an endpoint session
|
||||
* for processing incoming data and generating the response
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <esp_gap_ble_api.h>
|
||||
|
||||
#include <protocomm.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -26,7 +24,8 @@ extern "C" {
|
||||
* BLE device name cannot be larger than this value
|
||||
* 31 bytes (max scan response size) - 1 byte (length) - 1 byte (type) = 29 bytes
|
||||
*/
|
||||
#define MAX_BLE_DEVNAME_LEN (ESP_BLE_SCAN_RSP_DATA_LEN_MAX - 2)
|
||||
#define MAX_BLE_DEVNAME_LEN 29
|
||||
#define BLE_UUID128_VAL_LENGTH 16
|
||||
|
||||
/**
|
||||
* @brief This structure maps handler required by protocomm layer to
|
||||
@ -49,7 +48,7 @@ typedef struct name_uuid {
|
||||
/**
|
||||
* @brief Config parameters for protocomm BLE service
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct protocomm_ble_config {
|
||||
/**
|
||||
* BLE device name being broadcast at the time of provisioning
|
||||
*/
|
||||
@ -58,7 +57,7 @@ typedef struct {
|
||||
/**
|
||||
* 128 bit UUID of the provisioning service
|
||||
*/
|
||||
uint8_t service_uuid[ESP_UUID_LEN_128];
|
||||
uint8_t service_uuid[BLE_UUID128_VAL_LENGTH];
|
||||
|
||||
/**
|
||||
* Number of entries in the Name-UUID lookup table
|
||||
|
@ -35,6 +35,8 @@ typedef struct protocomm_security_pop {
|
||||
uint16_t len;
|
||||
} protocomm_security_pop_t;
|
||||
|
||||
typedef void * protocomm_security_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Protocomm security object structure.
|
||||
*
|
||||
@ -54,28 +56,31 @@ typedef struct protocomm_security {
|
||||
* Function for initializing/allocating security
|
||||
* infrastructure
|
||||
*/
|
||||
esp_err_t (*init)();
|
||||
esp_err_t (*init)(protocomm_security_handle_t *handle);
|
||||
|
||||
/**
|
||||
* Function for deallocating security infrastructure
|
||||
*/
|
||||
esp_err_t (*cleanup)();
|
||||
esp_err_t (*cleanup)(protocomm_security_handle_t handle);
|
||||
|
||||
/**
|
||||
* Starts new secure transport session with specified ID
|
||||
*/
|
||||
esp_err_t (*new_transport_session)(uint32_t session_id);
|
||||
esp_err_t (*new_transport_session)(protocomm_security_handle_t handle,
|
||||
uint32_t session_id);
|
||||
|
||||
/**
|
||||
* Closes a secure transport session with specified ID
|
||||
*/
|
||||
esp_err_t (*close_transport_session)(uint32_t session_id);
|
||||
esp_err_t (*close_transport_session)(protocomm_security_handle_t handle,
|
||||
uint32_t session_id);
|
||||
|
||||
/**
|
||||
* Handler function for authenticating connection
|
||||
* request and establishing secure session
|
||||
*/
|
||||
esp_err_t (*security_req_handler)(const protocomm_security_pop_t *pop,
|
||||
esp_err_t (*security_req_handler)(protocomm_security_handle_t handle,
|
||||
const protocomm_security_pop_t *pop,
|
||||
uint32_t session_id,
|
||||
const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t **outbuf, ssize_t *outlen,
|
||||
@ -84,14 +89,16 @@ typedef struct protocomm_security {
|
||||
/**
|
||||
* Function which implements the encryption algorithm
|
||||
*/
|
||||
esp_err_t (*encrypt)(uint32_t session_id,
|
||||
esp_err_t (*encrypt)(protocomm_security_handle_t handle,
|
||||
uint32_t session_id,
|
||||
const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t *outbuf, ssize_t *outlen);
|
||||
|
||||
/**
|
||||
* Function which implements the decryption algorithm
|
||||
*/
|
||||
esp_err_t (*decrypt)(uint32_t session_id,
|
||||
esp_err_t (*decrypt)(protocomm_security_handle_t handle,
|
||||
uint32_t session_id,
|
||||
const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t *outbuf, ssize_t *outlen);
|
||||
} protocomm_security_t;
|
||||
|
Reference in New Issue
Block a user