Skip to main content

TAL Bluetooth API Reference

Overview

The header tal_bluetooth.h exposes the TuyaOpen TAL Bluetooth API: stack initialization, advertising, scanning, connections, GATT-style data exchange, and MTU negotiation. Events are delivered through the callback registered in tal_ble_bt_init. Types such as TAL_BLE_ADV_PARAMS_T are defined in tal_bluetooth_def.h.

Audience: Developers integrating BLE central or peripheral behavior on supported platforms.

Return values

Functions return OPERATE_RET (OPRT_OK on success). Several APIs note that RSSI, connection parameter updates, and similar outcomes are also reported asynchronously via BLE events.

Initialization and identity

FunctionDescription
tal_ble_bt_initInitialize Bluetooth for the given role; register event callback.
tal_ble_bt_deinitDeinitialize Bluetooth (or one role).
tal_ble_address_setSet local identity address.
tal_ble_address_getRead local identity address.
tal_ble_bt_link_maxGet maximum link count or MTU-related limit per platform.

Advertising (peripheral)

FunctionDescription
tal_ble_advertising_startStart advertising.
tal_ble_advertising_data_setSet advertising and scan response payload.
tal_ble_advertising_stopStop advertising.
tal_ble_advertising_data_updateUpdate payloads; behavior depends on whether advertising is active.

Scanning (central)

FunctionDescription
tal_ble_scan_startStart scanning; adv and scan response data arrive through TAL_BLE_EVT_ADV_REPORT.
tal_ble_scan_stopStop scanning.

Connection management

FunctionDescription
tal_ble_connect_and_discoveryStart connection; completion via TAL_BLE_EVT_CENTRAL_CONNECT.
tal_ble_disconnectDisconnect; works for central or peripheral (fill handle and address per role).
tal_ble_conn_param_updateRequest connection parameter update; result via TAL_BLE_EVT_CONN_PARAM_UPDATE.
tal_ble_rssi_getRequest RSSI; sample delivered via TAL_BLE_EVT_LINK_RSSI.

Data path (GATT-style helpers)

FunctionDescription
tal_ble_server_common_sendPeripheral: notify or indicate on common channel.
tal_ble_server_common_notifyPeripheral: notify by characteristic index.
tal_ble_server_common_read_updatePeripheral: update readable value.
tal_ble_server_common_read_update_extPeripheral: update by characteristic index.
tal_ble_client_common_sendCentral: write to peer.
tal_ble_client_common_readCentral: read from peer.

MTU exchange

FunctionDescription
tal_ble_server_exchange_mtu_replyPeripheral: reply to MTU exchange.
tal_ble_client_exchange_mtu_requestCentral: request MTU exchange.

Platform notes

  • Feature availability depends on the chip, SDK configuration, and TKL adapter (for example classic BT versus BLE-only parts).
  • Always implement the event callback passed to tal_ble_bt_init; many APIs complete work asynchronously through events.

References