Object Transfer Profile
The Object Transfer Profile enables a client to manage objects on a server and transfer object contents over an L2CAP connection-oriented channel.
Examples
bluetooth/ble_profiles/ble_otp/ble_otp_client. bluetooth/ble_profiles/ble_otp/ble_otp_server.
API Reference
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)
Note
Feature bit
calculate_opmust be set. Caller should verify checksum and then call esp_ble_otp_client_read_object() with remaining offset.- Parameters
conn_handle – [in] BLE connection handle
offset – [in] Offset to start calculating from
length – [in] Length to calculate
- Returns
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.
Note
Reads current size and resumes writing remaining bytes. Requires write_op support. For patching, use integrity method instead.
- Parameters
conn_handle – [in] BLE connection handle
total_size – [in] Total object size to write
mode – [in] Write mode
- Returns
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)
Note
Feature bit
calculate_opmust be set. Caller should verify checksum and then call esp_ble_otp_client_write_object() for failed regions.- Parameters
conn_handle – [in] BLE connection handle
offset – [in] Offset to start calculating from
length – [in] Length to calculate
- Returns
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.
Note
Allowed when OTS is idle/failed. Discovery must complete before OACP/OLCP.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Required before OACP/OLCP. Feature bits gate supported operations.
- Parameters
conn_handle – [in] BLE connection handle
feature – [out] Pointer to store OTS Feature
- Returns
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.
Note
Allowed only when session is idle. Selection must be stable before OACP.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Allowed only when session is idle. Selection must be stable before OACP.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Allowed only when session is idle. Selection must be stable before OACP.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Allowed only when session is idle. Selection must be stable before OACP.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
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.
- Parameters
conn_handle – [in] BLE connection handle
object_id – [in] Object ID to select
- Returns
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.
- Parameters
conn_handle – [in] BLE connection handle
index – [in] Object index (0-based)
- Returns
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.
Note
Allowed only when session is idle.
- Parameters
conn_handle – [in] BLE connection handle
sort_order – [in] Sort order (BLE_OTS_OLCP_SORT_BY_*)
- Returns
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.
Note
Allowed only when session is idle.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Allowed only when session is idle.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Allowed only when session is idle.
- Parameters
conn_handle – [in] BLE connection handle
filter – [in] Filter type and parameter
- Returns
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.
Note
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.
- Parameters
conn_handle – [in] BLE connection handle
object_info – [out] Pointer to store object information
- Returns
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.
Note
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.
- Parameters
conn_handle – [in] BLE connection handle
name – [in] Object name buffer
name_len – [in] Object name length
- Returns
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.
Note
Requires object selected.
- Parameters
conn_handle – [in] BLE connection handle
prop – [in] Object properties
- Returns
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)
Note
Requires OTS discovered and OLCP supported. Caller should iterate with esp_ble_otp_client_discover_next().
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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)
Note
Requires OTS discovered and OLCP supported.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Requires OTS discovered, OLCP supported, and Object List Filter exposed.
- Parameters
conn_handle – [in] BLE connection handle
filter – [in] Filter to apply
- Returns
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)
Note
Requires OTS discovered and OLCP Go-To supported.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Selects Directory Listing Object (ID 0x000000000000), reads current size, and starts OACP Read for the full contents.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Feature bit
create_opmust 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.- Parameters
conn_handle – [in] BLE connection handle
object_type – [in] Object type
object_size – [in] Allocated object size
- Returns
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.
Note
Requires object selected + metadata valid + server object property delete_prop set. Feature bit
delete_opmust be set. Server may respond with OACP RSP Invalid Object (e.g. object not found/deleted).- Parameters
conn_handle – [in] BLE connection handle
- Returns
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.
Note
Requires: OTS discovered + object selected + metadata valid. Feature bit
read_opmust 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.- Parameters
conn_handle – [in] BLE connection handle
offset – [in] Offset to start reading from
length – [in] Length to read (0 = read all remaining data)
- Returns
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.
Note
Requires: OTS discovered + object selected + metadata valid. Feature bit
write_opmust 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.- Parameters
conn_handle – [in] BLE connection handle
offset – [in] Offset to start writing at
length – [in] Length to write
mode – [in] Write mode
- Returns
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.
Note
Feature bit
calculate_opmust be set. This API is used by resume procedures to verify partial data.- Parameters
conn_handle – [in] BLE connection handle
offset – [in] Offset to start calculating from
length – [in] Length to calculate (0 = calculate all remaining data)
- Returns
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)
Note
Requires selected object + metadata valid + execute_prop enabled. Feature bit
execute_opmust be set. If committing a write, this is allowed after EOF even when session is busy.- Parameters
conn_handle – [in] BLE connection handle
parameters – [in] Execute parameters (optional, can be NULL)
param_len – [in] Parameter length
- Returns
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.
Note
ABORTED event is reported only after OACP Abort response.
- Parameters
conn_handle – [in] BLE connection handle
- Returns
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)
- Parameters
transfer_info – [in] Transfer channel information (from event)
data – [in] Data to send
data_len – [in] Data length
- Returns
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.
- Parameters
transfer_info – [in] Transfer channel information (from event)
- Returns
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)
- Parameters
feature – [in] OTS Feature to set
- Returns
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)
- Parameters
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
- Returns
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)
- Parameters
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
- Returns
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)
- Parameters
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
- Returns
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)
- Parameters
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
- Returns
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)
- Parameters
transfer_info – [in] Transfer channel information (from event)
data – [in] Data to send
data_len – [in] Data length
- Returns
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)
- Parameters
transfer_info – [in] Transfer channel information (from event)
- Returns
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.
- Parameters
config – [in] OTP configuration
- Returns
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.
- Returns
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
-
uint16_t conn_handle
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)
-
esp_ble_otp_role_t role
-
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)
-
esp_ble_ots_id_t object_id
-
struct esp_ble_otp_oacp_rsp_t
OTP OACP Response Data.
Note
rsp_code uses BLE_OTS_OACP_RSP_* (e.g. Success, Invalid Object for object not found/deleted).
-
struct esp_ble_otp_olcp_rsp_t
OTP OLCP Response Data.
-
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
-
esp_ble_conn_l2cap_coc_chan_t channel
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
-
enumerator BLE_OTP_ROLE_CLIENT
-
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