/* * $ Copyright Cypress Semiconductor $ */ /** @file * * Bluetooth Management (BTM) Application Programming Interface * * The BTM consists of several management entities: * 1. Device Control - controls the local device * 2. Device Discovery - manages inquiries, discover database * 3. ACL Channels - manages ACL connections (BR/EDR and LE) * 4. SCO Channels - manages SCO connections * 5. Security - manages all security functionality * 6. Power Management - manages park, sniff, hold, etc. * */ #pragma once #include "wiced_bt_types.h" #include "wiced_result.h" #include "hcidefs.h" #ifdef __cplusplus extern "C" { #endif /** * This section consists of several management entities: * - Device Control - controls the local device * - Device Discovery - manages inquiries, discover database * @if DUAL_MODE * - ACL Channels - manages ACL connections (BR/EDR and LE) * - SCO Channels - manages SCO connections * - Power Management - manages park, sniff, hold, etc. * @else * - ACL Channels - manages BLE ACL connections * - Security - manages all security functionality * @endif * * @addtogroup wicedbt_DeviceManagement Device Management * * @ingroup wicedbt * * @{ */ /****************************************************************************/ /** RSSI value not supplied (ignore it) */ #define BTM_INQ_RES_IGNORE_RSSI 0x7f /** Passed to BTM_SetScanConfig() to ignore */ #define BTM_SCAN_PARAM_IGNORE 0 /** TX Power Result (in response to #wiced_bt_dev_read_tx_power) */ typedef struct { wiced_result_t status; /**< Status of the operation */ uint8_t hci_status; /**< Status from controller (Refer Spec 5.0 Vol 2 Part D Error Codes) */ int8_t tx_power; /**< TX power in dB */ wiced_bt_device_address_t rem_bda; /**< Remote BD address */ } wiced_bt_tx_power_result_t; /** TX Power Result (in response to #wiced_bt_ble_set_adv_tx_power) */ typedef struct { uint16_t un_used1; /**< Unused */ uint16_t un_used2; /**< Unused */ uint8_t *p_param_buf; /**< Command status, see list of HCI Error codes in core spec*/ } wiced_bt_set_adv_tx_power_result_t; /** Result/Status */ typedef wiced_result_t wiced_bt_dev_status_t; /** Structure returned with Vendor Specific Command complete callback */ typedef struct { uint16_t opcode; /**< Vendor specific command opcode */ uint16_t param_len; /**< Return parameter length */ uint8_t *p_param_buf; /**< Return parameter buffer (Contains Command Specific data) */ } wiced_bt_dev_vendor_specific_command_complete_params_t; /** @cond DUAL_MODE */ /** Default Discovery Window (in 0.625 msec intervals) */ #define BTM_DEFAULT_DISC_WINDOW 0x0012 /** Default Discovery Interval (in 0.625 msec intervals) */ #define BTM_DEFAULT_DISC_INTERVAL 0x0800 /** Default Connection Window */ #define BTM_DEFAULT_CONN_WINDOW 0x0012 /** Default Connection Interval */ #define BTM_DEFAULT_CONN_INTERVAL 0x0800 /** BR-EDR Discoverable modes */ enum wiced_bt_discoverability_mode_e { BTM_NON_DISCOVERABLE = 0, /**< Non discoverable */ BTM_LIMITED_DISCOVERABLE = 1, /**< Limited BR/EDR discoverable */ BTM_GENERAL_DISCOVERABLE = 2 /**< General BR/EDR discoverable */ }; /** BR/EDR Connectable modes */ enum wiced_bt_connectability_mode_e { BTM_NON_CONNECTABLE = 0, /**< Not connectable */ BTM_CONNECTABLE = 1 /**< BR/EDR connectable */ }; /** Inquiry modes * @note These modes are associated with the inquiry active values */ enum wiced_bt_inquiry_mode_e { BTM_INQUIRY_NONE = 0, /**< Stop inquiry */ BTM_GENERAL_INQUIRY = 0x01, /**< General inquiry */ BTM_LIMITED_INQUIRY = 0x02, /**< Limited inquiry */ BTM_BR_INQUIRY_MASK = (BTM_GENERAL_INQUIRY | BTM_LIMITED_INQUIRY) /**< BR Inquiry Mask */ }; /** Discoverable Mask */ #define BTM_DISCOVERABLE_MASK (BTM_LIMITED_DISCOVERABLE|BTM_GENERAL_DISCOVERABLE) /** Max Value for Discoverable */ #define BTM_MAX_DISCOVERABLE BTM_GENERAL_DISCOVERABLE /** Connectable Mask */ #define BTM_CONNECTABLE_MASK (BTM_NON_CONNECTABLE | BTM_CONNECTABLE) /** Standard Scan Type : Device listens for the duration of the scan window*/ #define BTM_SCAN_TYPE_STANDARD 0 /** Interlaces Scan Type : Device performed two back to back scans */ #define BTM_SCAN_TYPE_INTERLACED 1 /** Inquiry results */ #define BTM_INQ_RESULT 0 /** Inquiry results with RSSI */ #define BTM_INQ_RESULT_WITH_RSSI 1 /** Extended Inquiry results */ #define BTM_INQ_RESULT_EXTENDED 2 /** Inquiry Filter Condition types (see wiced_bt_dev_inq_parms_t) */ enum wiced_bt_dev_filter_cond_e { BTM_CLR_INQUIRY_FILTER = 0, /**< No inquiry filter */ BTM_FILTER_COND_DEVICE_CLASS = HCI_FILTER_COND_DEVICE_CLASS, /**< Filter on device class */ BTM_FILTER_COND_BD_ADDR = HCI_FILTER_COND_BD_ADDR, /**< Filter on device addr */ }; /** BTM service definitions (used for storing EIR data to bit mask refer eir_uuid_mask in #wiced_bt_dev_inquiry_scan_result_t) */ enum { BTM_EIR_UUID_SERVCLASS_SERIAL_PORT, /**< Serial Port Service Index */ BTM_EIR_UUID_SERVCLASS_DIALUP_NETWORKING, /**< Dialup Networking Service Index */ BTM_EIR_UUID_SERVCLASS_IRMC_SYNC, /**< IRMC SYNC Service Index */ BTM_EIR_UUID_SERVCLASS_OBEX_OBJECT_PUSH, /**< OBEX Object Push Service Index */ BTM_EIR_UUID_SERVCLASS_OBEX_FILE_TRANSFER, /**< OBEX File Transfer Service Index */ BTM_EIR_UUID_SERVCLASS_IRMC_SYNC_COMMAND, /**< IRMC SYNC Command Service Index */ BTM_EIR_UUID_SERVCLASS_HEADSET, /**< Headset Service Index */ BTM_EIR_UUID_SERVCLASS_AUDIO_SOURCE, /**< Audio Source Service Index */ BTM_EIR_UUID_SERVCLASS_AUDIO_SINK, /**< Audio Sink Service Index */ BTM_EIR_UUID_SERVCLASS_AV_REM_CTRL_TARGET, /**< AVRCP TG Service Index */ BTM_EIR_UUID_SERVCLASS_AV_REMOTE_CONTROL, /**< AVRCP CT Service Index */ BTM_EIR_UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY, /**< Headset AG Service Index */ BTM_EIR_UUID_SERVCLASS_DIRECT_PRINTING, /**< Direct Printing Service Index */ BTM_EIR_UUID_SERVCLASS_HF_HANDSFREE, /**< HF Handsfree Service Index */ BTM_EIR_UUID_SERVCLASS_AG_HANDSFREE, /**< AG Handsfree Service Index */ BTM_EIR_UUID_SERVCLASS_HUMAN_INTERFACE, /**< Human Interface Service Index */ BTM_EIR_UUID_SERVCLASS_SAP, /**< SAP Service Index */ BTM_EIR_UUID_SERVCLASS_PBAP_PCE, /**< PBAP PCE Service Index */ BTM_EIR_UUID_SERVCLASS_PBAP_PSE, /**< PBAP PSE Service Index */ BTM_EIR_UUID_SERVCLASS_PHONE_ACCESS, /**< Phone Access Service Index */ BTM_EIR_UUID_SERVCLASS_HEADSET_HS, /**< Headset HS Service Index */ BTM_EIR_UUID_SERVCLASS_PNP_INFORMATION, /**< PNP Information Service Index */ BTM_EIR_UUID_SERVCLASS_MESSAGE_ACCESS, /**< Message Access Service Index */ BTM_EIR_UUID_SERVCLASS_MESSAGE_NOTIFICATION, /**< Message Notification Service Index */ BTM_EIR_UUID_SERVCLASS_HDP_SOURCE, /** HCI_SUCCESS \n * HCI_ERR_PAGE_TIMEOUT \n * HCI_ERR_MEMORY_FULL \n * HCI_ERR_CONNECTION_TOUT \n * HCI_ERR_PEER_USER \n * HCI_ERR_CONN_CAUSE_LOCAL_HOST \n * HCI_ERR_LMP_RESPONSE_TIMEOUT \n * HCI_ERR_CONN_FAILED_ESTABLISHMENT * */ typedef void (wiced_bt_connection_status_change_cback_t) (wiced_bt_device_address_t bd_addr, uint8_t *p_features, wiced_bool_t is_connected, uint16_t handle, wiced_bt_transport_t transport, uint8_t reason); /**< connection status change callback */ /** * Inquiry result callback. * * @param p_inquiry_result : Inquiry result data (NULL if inquiry is complete) * @param p_eir_data : Extended inquiry response data * */ typedef void (wiced_bt_inquiry_result_cback_t) (wiced_bt_dev_inquiry_scan_result_t *p_inquiry_result, uint8_t *p_eir_data); /**< inquiry result callback */ /** * Asynchronous operation complete callback. * * @param p_data : Operation dependent data * * @return void */ typedef void (wiced_bt_dev_cmpl_cback_t) (void *p_data); /** * Vendor specific command complete. * * @param p_command_complete_params : Command complete parameters. * * @return void */ typedef void (wiced_bt_dev_vendor_specific_command_complete_cback_t) (wiced_bt_dev_vendor_specific_command_complete_params_t *p_command_complete_params); /** * Remote name result callback. * * @param p_remote_name_result : Remote name result data * * @return void */ typedef void (wiced_bt_remote_name_cback_t) (wiced_bt_dev_remote_name_result_t *p_remote_name_result); /**< remote name result callback */ /** * Vendor event handler callback * * @param len : input data length * @param p : input data */ typedef void (wiced_bt_dev_vse_callback_t)(uint8_t len, uint8_t *p); /** * HCI trace callback * * Callback for HCI traces * Registered using wiced_bt_dev_register_hci_trace() * * @param[in] type : Trace type * @param[in] length : Length of the trace data * @param[in] p_data : Pointer to the data * * @return void */ typedef void (wiced_bt_hci_trace_cback_t)(wiced_bt_hci_trace_type_t type, uint16_t length, uint8_t* p_data); /**@} wicedbt */ /****************************************************** * Function Declarations ******************************************************/ /****************************************************************************/ /****************************************************************************/ /** * @cond DUAL_MODE * BR/EDR (Bluetooth Basic Rate / Enhanced Data Rate) Functions. * This module provids different set of BR/EDR API for discovery, inquiry * ACL & SCO Connection, Data transfer, BR/EDR Security etc. * * @addtogroup wicedbt_bredr BR/EDR (Bluetooth Basic Rate / Enhanced Data Rate) * @ingroup wicedbt_DeviceManagement * * @{ */ /****************************************************************************/ /****************************************************************************/ /** * This module provided various Bluetooth security functionality such as authorisation, authentication and encryption * * @addtogroup wiced_bredr_api Bluetooth BR/EDR API * @ingroup wicedbt_bredr * * @{ */ /****************************************************************************/ /** * Begin BR/EDR inquiry for peer devices. * * @param[in] p_inqparms : inquiry parameters * @param[in] p_inquiry_result_cback : inquiry results callback * * @return wiced_result_t * * WICED_BT_PENDING : if successfully initiated \n * WICED_BT_BUSY : if already in progress \n * WICED_BT_ILLEGAL_VALUE : if parameter(s) are out of range \n * WICED_BT_NO_RESOURCES : if could not allocate resources to start the command \n * WICED_BT_WRONG_MODE : if the device is not up */ wiced_result_t wiced_bt_start_inquiry (wiced_bt_dev_inq_parms_t *p_inqparms, wiced_bt_inquiry_result_cback_t *p_inquiry_result_cback); /** * * Cancel inquiry * * @return * * WICED_BT_SUCCESS : if successful \n * WICED_BT_NO_RESOURCES : if could not allocate a message buffer \n * WICED_BT_WRONG_MODE : if the device is not up. */ wiced_result_t wiced_bt_cancel_inquiry(void); /** * Read the local device address * * @param[out] bd_addr : Local bd address * * @return void * */ void wiced_bt_dev_read_local_addr (wiced_bt_device_address_t bd_addr); /** * * Set advanced connection parameters for subsequent BR/EDR connections * (remote clock offset, page scan mode, and other information obtained during inquiry) * * If not called, then default connection parameters will be used. * * @param[in] p_inquiry_scan_result : Inquiry scan result (from #wiced_bt_dev_inquiry_scan_result_t) * * @return wiced_result_t * * WICED_BT_SUCCESS : on success; \n * WICED_BT_FAILED : if an error occurred */ wiced_result_t wiced_bt_dev_set_advanced_connection_params (wiced_bt_dev_inquiry_scan_result_t *p_inquiry_scan_result); /** * * Send a vendor specific HCI command to the controller. * * @param[in] opcode : Opcode of vendor specific command * @param[in] param_len : Length of parameter buffer * @param[in] p_param_buf : Parameters * @param[in] p_cback : Callback for command complete * * @return * * WICED_BT_SUCCESS : Command sent. Does not expect command complete event. (command complete callback param is NULL) \n * WICED_BT_PENDING : Command sent. Waiting for command complete event. \n * WICED_BT_BUSY : Command not sent. Waiting for command complete event for prior command. * */ wiced_result_t wiced_bt_dev_vendor_specific_command (uint16_t opcode, uint8_t param_len, uint8_t *p_param_buf, wiced_bt_dev_vendor_specific_command_complete_cback_t *p_cback); /** * Set discoverability * * @note The duration must be less than or equal to the interval. * * @param[in] inq_mode : Discoverability mode (see #wiced_bt_discoverability_mode_e ) * @param[in] duration : Duration (in 0.625 msec intervals). BTM_DEFAULT_DISC_WINDOW, or range: 0x0012 ~ 0x1000 (11.25 ~ 2560 msecs) * @param[in] interval : Interval (in 0.625 msec intervals). BTM_DEFAULT_DISC_INTERVAL, or range: 0x0012 ~ 0x1000 (11.25 ~ 2560 msecs) * * @return * * WICED_BT_SUCCESS : If successful \n * WICED_BT_BUSY : If a setting of the filter is already in progress \n * WICED_BT_NO_RESOURCES : If couldn't get a memory pool buffer \n * WICED_BT_ILLEGAL_VALUE : If a bad parameter was detected \n * WICED_BT_WRONG_MODE : If the device is not up */ wiced_result_t wiced_bt_dev_set_discoverability (uint8_t inq_mode, uint16_t duration, uint16_t interval); /** * * Set connectablilty * * @note The duration (window parameter) must be less than or equal to the interval. * * @param[in] page_mode : Connectability mode (see #wiced_bt_connectability_mode_e ) * @param[in] window : Duration (in 0.625 msec intervals). BTM_DEFAULT_CONN_WINDOW, or range: 0x0012 ~ 0x1000 (11.25 ~ 2560 msecs) * @param[in] interval : Interval (in 0.625 msec intervals). BTM_DEFAULT_CONN_INTERVAL, or range: 0x0012 ~ 0x1000 (11.25 ~ 2560 msecs) * * @return * * WICED_BT_SUCCESS : If successful \n * WICED_BT_ILLEGAL_VALUE : If a bad parameter is detected \n * WICED_BT_NO_RESOURCES : If could not allocate a message buffer \n * WICED_BT_WRONG_MODE : If the device is not up */ wiced_result_t wiced_bt_dev_set_connectability (uint8_t page_mode, uint16_t window, uint16_t interval); /** * * Register callback for connection status change * * * @param[in] p_wiced_bt_connection_status_change_cback - Callback for connection status change * * @return wiced_result_t * * WICED_BT_SUCCESS : on success; \n * WICED_BT_FAILED : if an error occurred */ wiced_result_t wiced_bt_dev_register_connection_status_change(wiced_bt_connection_status_change_cback_t *p_wiced_bt_connection_status_change_cback); /** * * Set a connection into sniff mode. * * @param[in] remote_bda : Link for which to put into sniff mode * @param[in] min_period : Minimum sniff period (range 0x0006 to 0x0540) (in 0.625 msec) * @param[in] max_period : Maximum sniff period (range 0x0006 to 0x0540) (in 0.625 msec) * @param[in] attempt : Number of attempts for switching to sniff mode (range 0x0001 – 0x7FFF) (in 0.625 msec) * @param[in] timeout : Timeout for attempting to switch to sniff mode (range 0x0000 – 0x7FFF) (in 0.625 msec) * * @return WICED_BT_PENDING if successfully initiated, otherwise error */ wiced_result_t wiced_bt_dev_set_sniff_mode (wiced_bt_device_address_t remote_bda, uint16_t min_period, uint16_t max_period, uint16_t attempt, uint16_t timeout); /** * Take a connection out of sniff mode. * A check is made if the connection is already in sniff mode, * and if not, the cancel sniff mode is ignored. * * @return WICED_BT_PENDING if successfully initiated, otherwise error * */ wiced_result_t wiced_bt_dev_cancel_sniff_mode (wiced_bt_device_address_t remote_bda); /** * * Set sniff subrating parameters for an active connection * * @param[in] remote_bda : device address of desired ACL connection * @param[in] max_latency : maximum latency (in 0.625ms units) (range: 0x0002-0xFFFE) * @param[in] min_remote_timeout : minimum remote timeout (in 0.625ms units) (range: 0x0000 – 0xFFFE) * @param[in] min_local_timeout : minimum local timeout (in 0.625ms units) (range: 0x0000 – 0xFFFE) * * @return * * WICED_BT_SUCCESS : on success; \n * WICED_BT_ILLEGAL_ACTION : if an error occurred */ wiced_result_t wiced_bt_dev_set_sniff_subrating (wiced_bt_device_address_t remote_bda, uint16_t max_latency, uint16_t min_remote_timeout, uint16_t min_local_timeout); /** * * Get Receive Signal Strenth Index (RSSI) for the requested link * * @param[in] remote_bda : BD address of connection to read rssi * @param[in] transport : Transport type * @param[in] p_cback : Result callback (wiced_bt_dev_rssi_result_t will be passed to the callback) * * @return * * WICED_BT_PENDING : if command issued to controller. \n * WICED_BT_NO_RESOURCES : if couldn't allocate memory to issue command \n * WICED_BT_UNKNOWN_ADDR : if no active link with bd addr specified \n * WICED_BT_BUSY : if command is already in progress * */ wiced_result_t wiced_bt_dev_read_rssi (wiced_bt_device_address_t remote_bda, wiced_bt_transport_t transport, wiced_bt_dev_cmpl_cback_t *p_cback); /** * * Write EIR data to controller. * * @param[in] p_buff : EIR data as per the spec (Spec 5.0 Vol 3 Part C, Section 8 ) * @param[in] len : Total Length of EIR data being passed * * @return * WICED_BT_SUCCESS : if successful \n * WICED_BT_NO_RESOURCES : if couldn't allocate memory to issue command \n * WICED_BT_UNSUPPORTED : if local device cannot support request \n * */ wiced_result_t wiced_bt_dev_write_eir (uint8_t *p_buff, uint16_t len); /** * * This function is called to switch the role between master and * slave. If role is already set it will do nothing. If the * command was initiated, the callback function is called upon * completion. * * @param[in] remote_bd_addr : BD address of remote device * @param[in] new_role : New role (BTM_ROLE_MASTER or BTM_ROLE_SLAVE) * @param[in] p_cback : Result callback (wiced_bt_dev_switch_role_result_t will be passed to the callback) * * @return wiced_result_t * */ wiced_result_t wiced_bt_dev_switch_role( wiced_bt_device_address_t remote_bd_addr, uint8_t new_role, wiced_bt_dev_cmpl_cback_t *p_cback ); /** * * This function is called to send HCI_SET_AFH_CHANNELS command * to BR/EDR controller. * * Channel n is bad = 0. * Channel n is unknown = 1. * The most significant bit is reserved and shall be set to 0. * At least 20 channels shall be marked as unknown. * * @param afh_channel_map : AFH Host Channel Classification array * * @return * WICED_BT_UNSUPPORTED : if feature does not supported \n * WICED_BT_WRONG_MODE : if device is in wrong mode \n * WICED_BT_NO_RESOURCES : if device does not have buffers to process the request * */ wiced_bt_dev_status_t wiced_bt_dev_set_afh_channel_classification(const wiced_bt_br_chnl_map_t afh_channel_map); /** * * Get BT Friendly name from remote device. * * @param[in] bd_addr : Peer bd address * @param[in] p_remote_name_result_cback : remote name result callback * * @return wiced_result_t * * WICED_BT_PENDING : if successfully initiated \n * WICED_BT_BUSY : if already in progress \n * WICED_BT_ILLEGAL_VALUE : if parameter(s) are out of range \n * WICED_BT_NO_RESOURCES : if could not allocate resources to start the command \n * WICED_BT_WRONG_MODE : if the device is not up. **/ wiced_result_t wiced_bt_dev_get_remote_name (wiced_bt_device_address_t bd_addr, wiced_bt_remote_name_cback_t *p_remote_name_result_cback); /** * * Application can invoke this function to enable the coex functionality * * @param[in] seci_baud_rate : SECI baud rate. Ensure to set a valid baud rate which will be used * for the SECI communication between BT and WLAN chip. Maximum supported * value is up to 4M * * @return wiced_result_t * **/ wiced_result_t wiced_bt_coex_enable( uint32_t seci_baud_rate ); /** * * Application can invoke this function to disable the coex functionality * * @return void * */ void wiced_bt_coex_disable( void ); /** * * This function is called to set the channel assessment mode on or off * * @param[in] enable_or_disable : Enable or disable AFH channel assessment * * @return wiced_result_t * **/ wiced_result_t wiced_bt_dev_set_afh_channel_assessment(wiced_bool_t enable_or_disable); /** * * This function is called to set the packet types used for * a specific SCO connection and for all connections. * * @param[in] sco_inx: Specific connection and -1 for all connections. * @param[in] pkt_types: One or more of the following \n * BTM_SCO_PKT_TYPES_MASK_HV1 \n * BTM_SCO_PKT_TYPES_MASK_HV2 \n * BTM_SCO_PKT_TYPES_MASK_HV3 \n * BTM_SCO_PKT_TYPES_MASK_EV3 \n * BTM_SCO_PKT_TYPES_MASK_EV4 \n * BTM_SCO_PKT_TYPES_MASK_EV5 \n * BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 \n * BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 \n * BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 \n * BTM_SCO_PKT_TYPES_MASK_NO_3_EV5 \n * BTM_SCO_LINK_ALL_MASK - enables all supported types * * @return wiced_bt_dev_status_t */ wiced_bt_dev_status_t wiced_bt_sco_setPacketTypes(int16_t sco_inx, uint16_t pkt_types); /** * This function is set the ACL packet types that * the device supports for specific connection and all connections if bd address with all zeros. * * @param[in] remote_bda: BD Address for specific conection and for all connections it should be all 0's. * @param[in] pkt_types: Packet types supported by the device. * One or more of the following (bitmask): \n * BTM_ACL_PKT_TYPES_MASK_DM1 \n * BTM_ACL_PKT_TYPES_MASK_DH1 \n * BTM_ACL_PKT_TYPES_MASK_DM3 \n * BTM_ACL_PKT_TYPES_MASK_DH3 \n * BTM_ACL_PKT_TYPES_MASK_DM5 \n * BTM_ACL_PKT_TYPES_MASK_DH5 \n * BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 \n * BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 \n * BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 \n * BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 \n * BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 * * @return wiced_result_t */ wiced_result_t wiced_bt_dev_setAclPacketTypes(wiced_bt_device_address_t remote_bda, uint16_t pkt_types); /** * @} */ /** * * This module provided various Bluetooth BR/EDR security functionality such as authorisation, authentication and encryption. * * @addtogroup br_edr_sec_api_functions BR/EDR Security Function * @ingroup wicedbt_bredr * * @note General Security APIs are listed in \ref ble_common_sec_api_functions section. * @{ */ /** * PIN code reply (use in response to BTM_PIN_REQUEST_EVT in #wiced_bt_management_cback_t) * * @param[in] bd_addr : Address of the device for which PIN was requested * @param[in] res : result of the operation WICED_BT_SUCCESS if success * @param[in] pin_len : length in bytes of the PIN Code * @param[in] p_pin : pointer to array with the PIN Code * * @return void * @note BR/EDR Only */ void wiced_bt_dev_pin_code_reply (wiced_bt_device_address_t bd_addr, wiced_result_t res, uint8_t pin_len, uint8_t *p_pin); /** * * Provide the pairing passkey (in response to BTM_PASSKEY_REQUEST_EVT of #wiced_bt_management_cback_t) * * @param[in] res : result of the operation WICED_BT_SUCCESS if success * @param[in] bd_addr : Address of the peer device * @param[in] passkey : numeric value in the range of 0 - 999999(0xF423F). * * @return void * @note BR/EDR only */ void wiced_bt_dev_pass_key_req_reply(wiced_result_t res, wiced_bt_device_address_t bd_addr, uint32_t passkey); /** * * Read the local OOB data from controller (for sending * to peer device over oob message). When * operation is completed, local OOB data will be * provided via BTM_READ_LOCAL_OOB_DATA_COMPLETE_EVT. * * @note BR/EDR Only */ wiced_result_t wiced_bt_dev_read_local_oob_data(void); /** * * Provide the remote OOB extended data for Simple Pairing * in response to BTM_REMOTE_OOB_DATA_REQUEST_EVT * * @param[in] res : response reply * @param[in] bd_addr : Address of the peer device * @param[in] is_extended_oob_data : TRUE if extended OOB data (set according to BTM_REMOTE_OOB_DATA_REQUEST_EVT request) * @param[in] c_192 : simple pairing Hash C derived from the P-192 public key. * @param[in] r_192 : simple pairing Randomizer R associated with the P-192 public key. * @param[in] c_256 : simple pairing Hash C derived from the P-256 public key (if is_extended_oob_data=TRUE) * @param[in] r_256 : simple pairing Randomizer R associated with the P-256 public key (if is_extended_oob_data=TRUE) * * @note BR/EDR Only */ void wiced_bt_dev_remote_oob_data_reply (wiced_result_t res, wiced_bt_device_address_t bd_addr, wiced_bool_t is_extended_oob_data, BT_OCTET16 c_192, BT_OCTET16 r_192, BT_OCTET16 c_256, BT_OCTET16 r_256); /** * Build the OOB data block to be used to send OOB extended * data over OOB (non-Bluetooth) link. * * @param[out] p_data : OOB data block location * @param[in] max_len : OOB data block size * @param[in] is_extended_oob_data : TRUE if extended OOB data (for Secure Connections) * @param[in] c_192 : simple pairing Hash C derived from the P-192 public key. * @param[in] r_192 : simple pairing Randomizer R associated with the P-192 public key. * @param[in] c_256 : simple pairing Hash C derived from the P-256 public key (if is_extended_oob_data=TRUE) * @param[in] r_256 : simple pairing Randomizer R associated with the P-256 public key (if is_extended_oob_data=TRUE) * * @return Number of bytes put into OOB data block. * * @note BR/EDR Only */ uint16_t wiced_bt_dev_build_oob_data(uint8_t *p_data, uint16_t max_len, wiced_bool_t is_extended_oob_data, BT_OCTET16 c_192, BT_OCTET16 r_192, BT_OCTET16 c_256, BT_OCTET16 r_256); /** * * This function is called to provide the OOB data for * SMP in response to BTM_SMP_REMOTE_OOB_DATA_REQUEST_EVT * * @param[in] bd_addr - Address of the peer device * @param[in] res - result of the operation WICED_BT_SUCCESS if success * @param[in] len - oob data length * @param[in] p_data - oob data * * @note BR/EDR Only */ void wiced_bt_smp_oob_data_reply(wiced_bt_device_address_t bd_addr, wiced_result_t res, uint8_t len, uint8_t *p_data); /** * * Create local BLE SC (secure connection) OOB data. When * operation is completed, local OOB data will be * provided via BTM_SMP_SC_LOCAL_OOB_DATA_NOTIFICATION_EVT. * * @param[in] bd_addr : intended remote address for the OOB data * @param[in] bd_addr_type : BLE_ADDR_PUBLIC or BLE_ADDR_PUBLIC * * @return TRUE: creation of local SC OOB data set started. * * @note BR/EDR Only */ wiced_bool_t wiced_bt_smp_create_local_sc_oob_data (wiced_bt_device_address_t bd_addr, wiced_bt_ble_address_type_t bd_addr_type); /** * * Provide the SC OOB data for SMP in response to * BTM_SMP_SC_REMOTE_OOB_DATA_REQUEST_EVT * * @param[in] p_oob_data : oob data * * @note BR/EDR Only */ void wiced_bt_smp_sc_oob_reply (wiced_bt_smp_sc_oob_data_t *p_oob_data); /** * * This function is called to parse the OOB data payload * received over OOB (non-Bluetooth) link * * @param[in] p_data : oob data * @param[in] eir_tag : EIR Data type( version5.0, Volume 3, Part C Section 5.2.2.7 ) * @param[out] p_len : the length of the data with the given EIR Data type * * @return The beginning of the data with the given EIR Data type. * NULL, if the tag is not found. * @note BR/EDR Only */ uint8_t* wiced_bt_dev_read_oob_data(uint8_t *p_data, uint8_t eir_tag, uint8_t *p_len); /** * * Disable BT secure connection * * @note This utility is used for LRAC application to disable the BT secure connection only. * If the interference issue is fixed, this utility may be removed * This utility shall be called before the bt stack is initialized * (by calling app_bt_init()). */ void wiced_bt_dev_lrac_disable_secure_connection(void); /** *@} *@} *@} */ /* @endcond*/ /****************************************************************************/ /** * This sections provides Bluetooth utilities functions related to trace, local bda, tx power etc. * * @addtogroup wicedbt_utility Utilities * @ingroup wicedbt_DeviceManagement * * @{ */ /****************************************************************************/ /** * * Register to get the hci traces * * @param[in] p_cback : Callback for hci traces * * @return void * */ void wiced_bt_dev_register_hci_trace( wiced_bt_hci_trace_cback_t* p_cback ); /** * * Set Local Bluetooth Device Address. If application passes BLE_ADDR_RANDOM as an address type, * the stack will setup a static random address. For the static random address top two bits of the * bd_addr should be set. The stack will enforce that. * * @param[in] bd_addr : device address to use * @param[in] addr_type : device address type , should be BLE_ADDR_RANDOM or BLE_ADDR_PUBLIC * BLE_ADDR_RANDOM should be only for single BLE mode, not for BR-EDR or Dual Mode * * @return void * * @note BD_Address must be in Big Endian format * * Example Data | AB | CD | EF | 01 | 23 | 45 | * Address | 0 | 1 | 2 | 3 | 4 | 5 | * For above example it will set AB:CD:EF:01:23:45 bd address */ void wiced_bt_set_local_bdaddr( wiced_bt_device_address_t bd_addr , wiced_bt_ble_address_type_t addr_type); /** * * This function is called to get the role of the local device * for the ACL connection with the specified remote device * * @param[in] remote_bd_addr : BD address of remote device * @param[in] transport : BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE * * @param[out] p_role : Role of the local device * * @return WICED_BT_UNKNOWN_ADDR if no active link with bd addr specified * */ wiced_result_t wiced_bt_dev_get_role( wiced_bt_device_address_t remote_bd_addr, uint8_t *p_role, wiced_bt_transport_t transport ); /** * Command to set the tx power on link * This command will adjust the transmit power attenuation on a per connection basis. * * @param[in] bd_addr : peer address * To set Adv Tx power keep bd_addr NULL * @param[in] power : power value in db * @param[in] p_cb : Result callback (wiced_bt_set_adv_tx_power_result_t will be passed to the callback) * * @return wiced_result_t * **/ wiced_result_t wiced_bt_set_tx_power ( wiced_bt_device_address_t bd_addr , int8_t power, wiced_bt_dev_vendor_specific_command_complete_cback_t *p_cb ); /** * Read the transmit power for the requested link * * @param[in] remote_bda : BD address of connection to read tx power * @param[in] transport : Transport type * @param[in] p_cback : Result callback (wiced_bt_tx_power_result_t will be passed to the callback) * * @return * * WICED_BT_PENDING : if command issued to controller. \n * WICED_BT_NO_RESOURCES : if couldn't allocate memory to issue command \n * WICED_BT_UNKNOWN_ADDR : if no active link with bd addr specified \n * WICED_BT_BUSY : if command is already in progress * */ wiced_result_t wiced_bt_dev_read_tx_power (wiced_bt_device_address_t remote_bda, wiced_bt_transport_t transport, wiced_bt_dev_cmpl_cback_t *p_cback); /** * * Enable or disable pairing * * @param[in] allow_pairing : (TRUE or FALSE) whether or not the device allows pairing. * @param[in] connect_only_paired : (TRUE or FALSE) whether or not to only allow paired devices to connect. * * @return void * */ void wiced_bt_set_pairable_mode(uint8_t allow_pairing, uint8_t connect_only_paired); /** * * Application can register Vendor-Specific HCI event callback * * @param[in] cb : callback function to register * * @return WICED_SUCCESS * WICED_ERROR if out of usage */ wiced_result_t wiced_bt_dev_register_vse_callback(wiced_bt_dev_vse_callback_t cb); /** * * Application can deregister Vendor-Specific HCI event callback * * @param[in] cb : callback function to deregister * * @return WICED_SUCCESS * WICED_ERROR if the input callback function was not registered yet */ wiced_result_t wiced_bt_dev_deregister_vse_callback(wiced_bt_dev_vse_callback_t cb); /** * * This API is called to get the statistics for an ACL link * * Limitation This API works when there is only one ACL connection * * @param[in] bda : bluetooth device address of desired link quality statistics * @param[in] transport : Tranport type LE/BR-EDR * @param[in] action : WICED_CLEAR_LINK_QUALITY_STATS = reset the link quality statistics to 0, * WICED_READ_LINK_QUALITY_STATS = read link quality statistics, * WICED_READ_THEN_CLEAR_LINK_QUALITY_STATS = read link quality statistics, then clear it * @param[in] p_cback : Result callback (wiced_bt_dev_cmpl_cback_t will be passed to the callback) * * @return * * WICED_BT_SUCCESS : If successful \n * WICED_BT_PENDING : If command succesfully sent down \n * WICED_BT_BUSY : If already in progress \n * WICED_BT_NO_RESORCES : If no memory/buffers available to sent down to controller \n * WICED_BT_UNKNOWN_ADDR : If given BD_ADDRESS is invalid \n * * @note Callback function argument is a pointer of type wiced_bt_lq_stats_result_t * * */ wiced_bt_dev_status_t wiced_bt_dev_link_quality_stats(wiced_bt_device_address_t bda, wiced_bt_transport_t transport, uint8_t action, wiced_bt_dev_cmpl_cback_t *p_cback); #ifdef USE_WICED_HCI /** * MCU host push all the saved NVRAM informatoin mainly paired device Info * * @param[in] paired_device_info : Remote device address, Link key * * @return WICED_BT_SUCCESS if successful * */ wiced_result_t wiced_bt_dev_push_nvram_data(wiced_bt_device_link_keys_t *paired_device_info); #endif /**@} wicedbt_utility */ /** * @if DUAL_MODE * Bluetooth generic security API. * * @addtogroup ble_common_sec_api_functions Generic Security API * @ingroup br_edr_sec_api_functions * @ingroup btm_ble_sec_api_functions * @else * Bluetooth BLE Security Functions. * @ingroup btm_ble_sec_api_functions * @endif * @{ */ /** * * Configure device to allow connections only with * secure connections supported devices * * @note API must be called only once after BTM_ENABLED_EVT event * received, before starting bluetooth activity * * @return void */ void wiced_bt_dev_configure_secure_connections_only_mode (void); /** * * Bond with peer device. If the connection is already up, but not secure, pairing is attempted. * * @note PIN parameters are only needed when bonding with legacy devices (pre-2.1 Core Spec) * * @param[in] bd_addr : Peer device bd address to pair with. * @param[in] bd_addr_type : BLE_ADDR_PUBLIC or BLE_ADDR_RANDOM (applies to LE devices only) * @param[in] transport : BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE * @param[in] pin_len : Length of input parameter p_pin (0 if not used). * @param[in] p_pin : Pointer to Pin Code to use (NULL if not used). * * @return * * WICED_BT_PENDING : if successfully initiated, \n * WICED_BT_SUCCESS : if already paired to the device, else error code */ wiced_result_t wiced_bt_dev_sec_bond (wiced_bt_device_address_t bd_addr, wiced_bt_ble_address_type_t bd_addr_type, wiced_bt_transport_t transport, uint8_t pin_len, uint8_t *p_pin); /** * * Cancel an ongoing bonding process with peer device. * * @param[in] bd_addr : Peer device bd address to pair with. * * @return * * WICED_BT_PENDING : if cancel initiated, \n * WICED_BT_SUCCESS : if cancel has completed already, else error code. */ wiced_result_t wiced_bt_dev_sec_bond_cancel (wiced_bt_device_address_t bd_addr); /** * * Encrypt the specified connection. * Status is notified using BTM_ENCRYPTION_STATUS_EVT of #wiced_bt_management_cback_t. * * @param[in] bd_addr : Address of peer device * @param[in] transport : BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE * @param[in] p_ref_data : Encryption type #wiced_bt_ble_sec_action_type_t * * @return * * WICED_BT_SUCCESS : already encrypted \n * WICED_BT_PENDING : command will be returned in the callback \n * WICED_BT_WRONG_MODE : connection not up. \n * WICED_BT_BUSY : security procedures are currently active */ wiced_result_t wiced_bt_dev_set_encryption (wiced_bt_device_address_t bd_addr, wiced_bt_transport_t transport, void *p_ref_data); /** * * Confirm the numeric value for pairing (in response to BTM_USER_CONFIRMATION_REQUEST_EVT of #wiced_bt_management_cback_t) * * @param[in] res : result of the operation WICED_BT_SUCCESS if success * @param[in] bd_addr : Address of the peer device * * @return void */ void wiced_bt_dev_confirm_req_reply(wiced_result_t res, wiced_bt_device_address_t bd_addr); /** * * Inform remote device of keypress during pairing. * * Used during the passkey entry by a device with KeyboardOnly IO capabilities * (typically a HID keyboard device). * * @param[in] bd_addr : Address of the peer device * @param[in] type : notification type * */ void wiced_bt_dev_send_key_press_notif(wiced_bt_device_address_t bd_addr, wiced_bt_dev_passkey_entry_type_t type); /** * * get bonded device list * * @param[out] p_paired_device_list : array for getting bd address of bonded devices * @param[in] p_num_devices : list size of p_pared_device_list total number of bonded devices stored * * @return wiced_result_t * */ wiced_result_t wiced_bt_dev_get_bonded_devices(wiced_bt_dev_bonded_device_info_t *p_paired_device_list,uint16_t *p_num_devices); /** * * remove bonding with remote device with assigned bd_addr * Note: This API cannot be used while being connected to the remote bd_addr * * @param[in] bd_addr : bd_addr of remote device to be removed from bonding list * * * @return wiced_result_t * */ wiced_result_t wiced_bt_dev_delete_bonded_device(wiced_bt_device_address_t bd_addr); /** * * Get security flags for the device * * @param[in] bd_addr : peer address * @param[out] p_sec_flags : security flags (see #wiced_bt_sec_flags_e) * * @return TRUE if successful * */ wiced_bool_t wiced_bt_dev_get_security_state(wiced_bt_device_address_t bd_addr, uint8_t *p_sec_flags); /** * @} */ /** * @addtogroup btm_ble_sec_api_functions BLE Security * @if DUAL_MODE * @ingroup btm_ble_api_functions * * Bluetooth LE security API (authorisation, authentication and encryption) * * @note General Security APIs are listed in \ref ble_common_sec_api_functions section. * @else * BLE Security API. * @ingroup wicedbt_DeviceManagement * @endif * @{ */ /** * * get le key mask from stored key information of nv ram * * @param[in] bd_addr : remote bd address * @param[out] p_key_mask : ble key mask stored * * @return wiced_result_t * */ wiced_result_t wiced_bt_dev_get_ble_keys(wiced_bt_device_address_t bd_addr, wiced_bt_dev_le_key_type_t *p_key_mask); /** * * add link key information to internal address resolution db * * @param[in] p_link_keys : link keys information stored in application side * * @return wiced_result_t * */ wiced_result_t wiced_bt_dev_add_device_to_address_resolution_db(wiced_bt_device_link_keys_t *p_link_keys); /** * * remove link key information from internal address resolution db * * @param[in] p_link_keys : link keys information stored in application side * * @return wiced_result_t * */ wiced_result_t wiced_bt_dev_remove_device_from_address_resolution_db(wiced_bt_device_link_keys_t *p_link_keys); /**@} btm_ble_sec_api_functions */ #ifdef __cplusplus } #endif