配置传输文件

[English]

配置文件传输协议使客户端能够管理服务器上的文件,并通过 L2CAP 面向连接通道 传输对象内容。

示例

bluetooth/ble_profiles/ble_otp/ble_otp_client. bluetooth/ble_profiles/ble_otp/ble_otp_server.

API 参考

Header File

Functions

esp_err_t esp_ble_otp_client_resume_read_checksum(uint16_t conn_handle, uint32_t offset, uint32_t length)

Resume read (checksum step)

备注

Feature bit calculate_op must be set. Caller should verify checksum and then call esp_ble_otp_client_read_object() with remaining offset.

参数
  • conn_handle[in] BLE connection handle

  • offset[in] Offset to start calculating from

  • length[in] Length to calculate

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if checksum not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_resume_write_current_size(uint16_t conn_handle, uint32_t total_size, esp_ble_otp_write_mode_t mode)

Resume write using Current Size method.

备注

Reads current size and resumes writing remaining bytes. Requires write_op support. For patching, use integrity method instead.

参数
  • conn_handle[in] BLE connection handle

  • total_size[in] Total object size to write

  • mode[in] Write mode

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_resume_write_checksum(uint16_t conn_handle, uint32_t offset, uint32_t length)

Resume write (checksum step)

备注

Feature bit calculate_op must be set. Caller should verify checksum and then call esp_ble_otp_client_write_object() for failed regions.

参数
  • conn_handle[in] BLE connection handle

  • offset[in] Offset to start calculating from

  • length[in] Length to calculate

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if checksum not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_discover_ots(uint16_t conn_handle)

Discover OTS service on the connected peer device.

备注

Allowed when OTS is idle/failed. Discovery must complete before OACP/OLCP.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_read_feature(uint16_t conn_handle, esp_ble_ots_feature_t *feature)

Read OTS Feature characteristic.

备注

Required before OACP/OLCP. Feature bits gate supported operations.

参数
  • conn_handle[in] BLE connection handle

  • feature[out] Pointer to store OTS Feature

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_select_first(uint16_t conn_handle)

Select first object in the list.

备注

Allowed only when session is idle. Selection must be stable before OACP.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_select_last(uint16_t conn_handle)

Select last object in the list.

备注

Allowed only when session is idle. Selection must be stable before OACP.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_select_previous(uint16_t conn_handle)

Select previous object in the list.

备注

Allowed only when session is idle. Selection must be stable before OACP.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_select_next(uint16_t conn_handle)

Select next object in the list.

备注

Allowed only when session is idle. Selection must be stable before OACP.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_select_by_id(uint16_t conn_handle, const esp_ble_ots_id_t *object_id)

Select object by ID.

备注

Allowed only when session is idle. Selection must be stable before OACP. Requires OLCP Go To support. Filters are ignored by Go To and reset to No Filter.

参数
  • conn_handle[in] BLE connection handle

  • object_id[in] Object ID to select

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_select_by_index(uint16_t conn_handle, uint32_t index)

Select object by index.

参数
  • conn_handle[in] BLE connection handle

  • index[in] Object index (0-based)

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_set_sort_order(uint16_t conn_handle, uint8_t sort_order)

Set object list sort order.

备注

Allowed only when session is idle.

参数
  • conn_handle[in] BLE connection handle

  • sort_order[in] Sort order (BLE_OTS_OLCP_SORT_BY_*)

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_request_num_objects(uint16_t conn_handle)

Request number of objects.

备注

Allowed only when session is idle.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_clear_mark(uint16_t conn_handle)

Clear marking of objects.

备注

Allowed only when session is idle.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_set_filter(uint16_t conn_handle, const esp_ble_ots_filter_t *filter)

Set object list filter.

备注

Allowed only when session is idle.

参数
  • conn_handle[in] BLE connection handle

  • filter[in] Filter type and parameter

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_read_object_info(uint16_t conn_handle, esp_ble_otp_object_info_t *object_info)

Read current object information.

备注

Requires object selected. Updates metadata state to VALID. Call this after OLCP selection (e.g. select_first) before read_object, write_object, or delete_object so that metadata is valid.

参数
  • conn_handle[in] BLE connection handle

  • object_info[out] Pointer to store object information

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_write_name(uint16_t conn_handle, const uint8_t *name, size_t name_len)

Write Object Name metadata.

备注

Requires object selected. Name must be non-empty and contain no ASCII control characters. Long write is not supported; if length exceeds ATT_MTU-3, return ESP_ERR_NOT_SUPPORTED.

参数
  • conn_handle[in] BLE connection handle

  • name[in] Object name buffer

  • name_len[in] Object name length

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if long write is required

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_write_prop(uint16_t conn_handle, const esp_ble_ots_prop_t *prop)

Write Object Properties metadata.

备注

Requires object selected.

参数
  • conn_handle[in] BLE connection handle

  • prop[in] Object properties

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_discover_all_start(uint16_t conn_handle)

Discover all objects (OLCP First)

备注

Requires OTS discovered and OLCP supported. Caller should iterate with esp_ble_otp_client_discover_next().

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if OLCP not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_discover_next(uint16_t conn_handle)

Discover next object (OLCP Next)

备注

Requires OTS discovered and OLCP supported.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if OLCP not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_discover_by_filter(uint16_t conn_handle, const esp_ble_ots_filter_t *filter)

Discover objects by filter.

备注

Requires OTS discovered, OLCP supported, and Object List Filter exposed.

参数
  • conn_handle[in] BLE connection handle

  • filter[in] Filter to apply

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if OLCP or filter not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_select_directory_listing(uint16_t conn_handle)

Select the Directory Listing Object (Object ID 0x000000000000)

备注

Requires OTS discovered and OLCP Go-To supported.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if OLCP not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_read_directory_listing(uint16_t conn_handle)

Read Directory Listing Object contents.

备注

Selects Directory Listing Object (ID 0x000000000000), reads current size, and starts OACP Read for the full contents.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if OLCP not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_create_object(uint16_t conn_handle, uint16_t object_type, uint32_t object_size)

Create a new object.

备注

Feature bit create_op must be set. After success, client should write a valid Object Name (non-empty, no ASCII control characters). If disconnected before naming, the server may delete the object as malformed.

参数
  • conn_handle[in] BLE connection handle

  • object_type[in] Object type

  • object_size[in] Allocated object size

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_delete_object(uint16_t conn_handle)

Delete current object.

备注

Requires object selected + metadata valid + server object property delete_prop set. Feature bit delete_op must be set. Server may respond with OACP RSP Invalid Object (e.g. object not found/deleted).

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_ERR_NOT_SUPPORTED if object’s delete property is not set

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_read_object(uint16_t conn_handle, uint32_t offset, uint32_t length)

Read object data via Object Transfer Channel.

备注

Requires: OTS discovered + object selected + metadata valid. Feature bit read_op must be set. After OLCP selection (e.g. select_first), metadata is UNKNOWN; call esp_ble_otp_client_read_object_info() first, or this returns ESP_ERR_INVALID_STATE.

参数
  • conn_handle[in] BLE connection handle

  • offset[in] Offset to start reading from

  • length[in] Length to read (0 = read all remaining data)

返回

  • ESP_OK on success (transfer will be initiated, wait for events)

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role, or metadata not valid

  • ESP_ERR_NOT_SUPPORTED if read_op not supported

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_write_object(uint16_t conn_handle, uint32_t offset, uint32_t length, esp_ble_otp_write_mode_t mode)

Write object data via Object Transfer Channel.

备注

Requires: OTS discovered + object selected + metadata valid. Feature bit write_op must be set. Object Properties must permit write. After OLCP selection, call esp_ble_otp_client_read_object_info() first if metadata not valid. Offset must be <= Current Size; Offset + Length must be <= Allocated Size, unless mode requests append/truncate/patch and the corresponding feature bit is supported. For resume (Current Size method), use the current size as the offset.

参数
  • conn_handle[in] BLE connection handle

  • offset[in] Offset to start writing at

  • length[in] Length to write

  • mode[in] Write mode

返回

  • ESP_OK on success (transfer will be initiated, wait for events)

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role, or metadata not valid

  • ESP_ERR_NOT_SUPPORTED if write_op not supported or object properties do not permit write

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_calculate_checksum(uint16_t conn_handle, uint32_t offset, uint32_t length)

Calculate checksum of object data.

备注

Feature bit calculate_op must be set. This API is used by resume procedures to verify partial data.

参数
  • conn_handle[in] BLE connection handle

  • offset[in] Offset to start calculating from

  • length[in] Length to calculate (0 = calculate all remaining data)

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_execute_object(uint16_t conn_handle, const uint8_t *parameters, uint8_t param_len)

Execute object (if supported)

备注

Requires selected object + metadata valid + execute_prop enabled. Feature bit execute_op must be set. If committing a write, this is allowed after EOF even when session is busy.

参数
  • conn_handle[in] BLE connection handle

  • parameters[in] Execute parameters (optional, can be NULL)

  • param_len[in] Parameter length

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_abort(uint16_t conn_handle)

Abort current object operation.

备注

ABORTED event is reported only after OACP Abort response.

参数

conn_handle[in] BLE connection handle

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in client role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_send_data(const esp_ble_otp_transfer_info_t *transfer_info, const uint8_t *data, uint16_t data_len)

Send data over Object Transfer Channel (after read/write operation initiated)

参数
  • transfer_info[in] Transfer channel information (from event)

  • data[in] Data to send

  • data_len[in] Data length

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if transfer channel is not ready

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_client_disconnect_transfer_channel(const esp_ble_otp_transfer_info_t *transfer_info)

Disconnect Object Transfer Channel.

参数

transfer_info[in] Transfer channel information (from event)

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_server_set_feature(const esp_ble_ots_feature_t *feature)

Set OTS feature (Server only)

参数

feature[in] OTS Feature to set

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in server role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_server_register_oacp_callback(esp_err_t (*callback)(uint8_t op_code, const uint8_t *parameter, uint16_t param_len, void *ctx), void *ctx)

Register callback for OACP operations (Server only)

参数
  • callback[in] Callback function to handle OACP operations Return ESP_OK to accept, ESP_ERR_* to reject with corresponding error code

  • ctx[in] User context passed to the callback

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in server role

esp_err_t esp_ble_otp_server_register_olcp_callback(esp_err_t (*callback)(uint8_t op_code, const uint8_t *parameter, uint16_t param_len, void *ctx), void *ctx)

Register callback for OLCP operations (Server only)

参数
  • callback[in] Callback function to handle OLCP operations Return ESP_OK to accept, ESP_ERR_* to reject with corresponding error code

  • ctx[in] User context passed to the callback

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in server role

esp_err_t esp_ble_otp_server_send_oacp_response(uint8_t req_op_code, uint8_t rsp_code, const uint8_t *rsp_parameter, uint8_t param_len)

Send OACP response (Server only)

参数
  • req_op_code[in] Request op code

  • rsp_code[in] Response code

  • rsp_parameter[in] Response parameter (can be NULL)

  • param_len[in] Parameter length

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in server role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_server_send_olcp_response(uint8_t req_op_code, uint8_t rsp_code, const uint8_t *rsp_parameter, uint8_t param_len)

Send OLCP response (Server only)

参数
  • req_op_code[in] Request op code

  • rsp_code[in] Response code

  • rsp_parameter[in] Response parameter (can be NULL)

  • param_len[in] Parameter length

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if OTP is not initialized or not in server role

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_server_send_data(const esp_ble_otp_transfer_info_t *transfer_info, const uint8_t *data, uint16_t data_len)

Send data over Object Transfer Channel (Server only)

参数
  • transfer_info[in] Transfer channel information (from event)

  • data[in] Data to send

  • data_len[in] Data length

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_INVALID_STATE if transfer channel is not ready

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_server_disconnect_transfer_channel(const esp_ble_otp_transfer_info_t *transfer_info)

Disconnect Object Transfer Channel (Server only)

参数

transfer_info[in] Transfer channel information (from event)

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_init(const esp_ble_otp_config_t *config)

Initialize OTP.

参数

config[in] OTP configuration

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG on invalid parameters

  • ESP_ERR_NO_MEM if memory allocation failed

  • ESP_FAIL on other error

esp_err_t esp_ble_otp_deinit(void)

Deinitialize OTP.

返回

  • ESP_OK on success

  • ESP_ERR_INVALID_STATE if OTP is not initialized

  • ESP_FAIL on other error

Unions

union esp_ble_otp_event_data_t
#include <esp_otp.h>

OTP Event Data Union.

Public Members

uint16_t conn_handle

BLE connection handle

uint8_t op_code

OACP op code

struct esp_ble_otp_event_data_t::[anonymous] oacp_started

OACP started event data

struct esp_ble_otp_event_data_t::[anonymous] oacp_aborted

OACP aborted event data

esp_ble_ots_feature_t feature

OTS Feature

struct esp_ble_otp_event_data_t::[anonymous] ots_discovered

OTS discovered event data

esp_ble_otp_object_info_t object_info

Selected object information

struct esp_ble_otp_event_data_t::[anonymous] object_selected

Object selected event data

esp_ble_ots_change_t change

Object change notification

struct esp_ble_otp_event_data_t::[anonymous] object_changed

Object changed event data

esp_ble_otp_oacp_rsp_t response

OACP response

struct esp_ble_otp_event_data_t::[anonymous] oacp_response

OACP response event data

esp_ble_otp_olcp_rsp_t response

OLCP response

struct esp_ble_otp_event_data_t::[anonymous] olcp_response

OLCP response event data

esp_ble_otp_transfer_info_t transfer_info

Transfer channel information

struct esp_ble_otp_event_data_t::[anonymous] transfer_channel_connected

Transfer channel connected event data

struct esp_ble_otp_event_data_t::[anonymous] transfer_channel_disconnected

Transfer channel disconnected event data

uint8_t data[BLE_OTP_EVENT_DATA_MAX_LEN]

Copy of received data

uint16_t data_len

Data length in this chunk

Data length sent

uint16_t chunk_offset

Byte offset of this chunk within the SDU (0 for single-chunk)

uint16_t total_len

Total SDU length (same for all chunks of one SDU)

struct esp_ble_otp_event_data_t::[anonymous] transfer_data_received

Transfer data received event data

struct esp_ble_otp_event_data_t::[anonymous] transfer_data_sent

Transfer data sent event data

struct esp_ble_otp_event_data_t::[anonymous] transfer_eof

Transfer EOF event data

bool success

Transfer success status

struct esp_ble_otp_event_data_t::[anonymous] transfer_complete

Transfer complete event data

esp_err_t error

Error code

struct esp_ble_otp_event_data_t::[anonymous] transfer_error

Transfer error event data

Structures

struct esp_ble_otp_config_t

OTP Configuration.

Public Members

esp_ble_otp_role_t role

OTP role (Client or Server)

uint16_t psm

PSM for Object Transfer Channel (default: BLE_OTP_PSM_DEFAULT)

uint16_t l2cap_coc_mtu

L2CAP CoC MTU for object transfer (default: BLE_OTP_L2CAP_COC_MTU_DEFAULT)

bool auto_discover_ots

Auto discover OTS service when connected (Client only, default: true)

struct esp_ble_otp_object_info_t

OTP Object Information.

Public Members

esp_ble_ots_id_t object_id

Object ID

uint8_t object_name[BLE_OTS_ATT_VAL_LEN]

Object name

uint16_t object_type

Object type

esp_ble_ots_size_t object_size

Object size

esp_ble_ots_prop_t object_prop

Object properties

esp_ble_ots_utc_t first_created

First created time (if available)

esp_ble_ots_utc_t last_modified

Last modified time (if available)

struct esp_ble_otp_oacp_rsp_t

OTP OACP Response Data.

备注

rsp_code uses BLE_OTS_OACP_RSP_* (e.g. Success, Invalid Object for object not found/deleted).

Public Members

uint8_t req_op_code

Request op code

uint8_t rsp_code

Response code (BLE_OTS_OACP_RSP_*)

uint8_t rsp_parameter[20]

Response parameter

struct esp_ble_otp_olcp_rsp_t

OTP OLCP Response Data.

Public Members

uint8_t req_op_code

Request op code

uint8_t rsp_code

Response code

uint8_t rsp_parameter[6]

Response parameter

uint32_t num_objects

Number of objects (for Request Number of Objects)

struct esp_ble_otp_transfer_info_t

OTP Transfer Channel Information.

Public Members

esp_ble_conn_l2cap_coc_chan_t channel

L2CAP CoC channel handle

uint16_t conn_handle

BLE connection handle

uint16_t psm

PSM

uint16_t mtu

MTU

esp_ble_ots_id_t object_id

Object ID being transferred

bool is_read

True if reading from server, false if writing to server

Macros

BLE_OTP_PSM_DEFAULT

Default PSM for Object Transfer Channel (Bluetooth SIG assigned)

BLE_OTP_L2CAP_COC_MTU_DEFAULT

Default L2CAP CoC MTU for object transfer

BLE_OTP_L2CAP_COC_MTU_MIN

Minimum L2CAP CoC MTU

BLE_OTP_EVENT_DATA_MAX_LEN

Max length of data copy in TRANSFER_DATA_RECEIVED event (avoids stack overflow in handler task)

BLE_OTP_OBJECT_SIZE_UNKNOWN

Object size unknown until metadata is received

BLE_OTP_EVENT_OTS_DISCOVERED

OTS service discovered

BLE_OTP_EVENT_OTS_DISCOVERY_FAILED

OTS service discovery failed

BLE_OTP_EVENT_OBJECT_SELECTED

Object selected (via OLCP)

BLE_OTP_EVENT_OBJECT_CHANGED

Object changed notification received

BLE_OTP_EVENT_OACP_STARTED

OACP procedure started

BLE_OTP_EVENT_OACP_ABORTED

OACP procedure aborted

BLE_OTP_EVENT_OACP_RESPONSE

OACP response received (rsp_code e.g. Success, Invalid Object / object not found, etc.)

BLE_OTP_EVENT_OLCP_RESPONSE

OLCP response received

BLE_OTP_EVENT_TRANSFER_CHANNEL_CONNECTED

Object Transfer Channel (L2CAP CoC) connected

BLE_OTP_EVENT_TRANSFER_CHANNEL_DISCONNECTED

Object Transfer Channel (L2CAP CoC) disconnected

BLE_OTP_EVENT_TRANSFER_DATA_RECEIVED

Object transfer data received

BLE_OTP_EVENT_TRANSFER_DATA_SENT

Object transfer data sent

BLE_OTP_EVENT_TRANSFER_EOF

Object content fully received/sent

BLE_OTP_EVENT_TRANSFER_COMPLETE

Read/Write completed after EOF and success

BLE_OTP_EVENT_TRANSFER_ERROR

Object transfer error

Enumerations

enum esp_ble_otp_role_t

OTP Role.

Values:

enumerator BLE_OTP_ROLE_CLIENT

OTP Client role

enumerator BLE_OTP_ROLE_SERVER

OTP Server role

enum esp_ble_otp_write_mode_t

OTP API rules (summary)

  • OTS must be discovered before any OACP/OLCP.

  • Feature bits gate OACP/OLCP operations.

  • Metadata is set valid by esp_ble_otp_client_read_object_info(); call it after OLCP selection (e.g. select_first) before Read/Write/Delete when needed.

  • Read/Write requires: OTS discovered + object selected + metadata valid.

  • Execute requires selected object + metadata valid + execute_prop enabled. It is also used to commit write after EOF.

  • Abort is reported only after OACP Abort response.

Error code rules:

  • ESP_ERR_INVALID_STATE: state prerequisites not satisfied.

  • ESP_ERR_NOT_SUPPORTED: feature bit disabled or operation unsupported.

  • ESP_ERR_INVALID_ARG: invalid parameters.

  • ESP_FAIL: unexpected stack or internal error.

Write Object Mode

Values:

enumerator BLE_OTP_WRITE_MODE_OVERWRITE

Overwrite within current size

enumerator BLE_OTP_WRITE_MODE_TRUNCATE

Truncate object after write

enumerator BLE_OTP_WRITE_MODE_APPEND

Append beyond allocated size

enumerator BLE_OTP_WRITE_MODE_PATCH

Patch within current size