mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-19 08:23:22 +08:00
修复mico-sdk错误
This commit is contained in:
@@ -1,349 +1,349 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Defines functions for using the MICO Bluetooth Framework
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico.h"
|
||||
#include "mico_bt_types.h"
|
||||
#include "mico_bt_dev.h"
|
||||
#include "mico_bt_smart_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/** MICO Bluetooth Framework mode of operation
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MICO_BT_MPAF_MODE, /**< The framework uses Multi-Profile Application Framework (MPAF). The entire Bluetooth stack runs on the controller. The host controls the controller using remote procedure calls (RPC) */
|
||||
MICO_BT_HCI_MODE, /**< The framework uses standard Host Controller Interface (HCI). The upper stack runs on the host and the lower stack runs on the controller */
|
||||
} mico_bt_mode_t;
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/** MICO Bluetooth packet.
|
||||
* An opaque data type representing a generic, zero-copy packet used for transporting data to/from the Bluetooth controller.
|
||||
*/
|
||||
typedef struct bt_packet mico_bt_packet_t;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
extern mico_worker_thread_t mico_bt_worker_thread;
|
||||
extern mico_worker_thread_t mico_bt_evt_worker_thread;
|
||||
|
||||
#define MICO_BT_WORKER_THREAD ((mico_worker_thread_t *)&mico_bt_worker_thread)
|
||||
#define MICO_BT_EVT_WORKER_THREAD ((mico_worker_thread_t *)&mico_bt_evt_worker_thread)
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @defgroup micobt Bluetooth
|
||||
*
|
||||
* MICO Bluetooth Framework Functions
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btfwmgmt Framework
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Framework Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initialise the MICO Bluetooth Framework
|
||||
*
|
||||
* This function initialises the local Bluetooth device and the framework core
|
||||
* components to operate in the mode specified. Upon return, the device is
|
||||
* powered.
|
||||
*
|
||||
* @note To switch mode, invoke @ref mico_bt_deinit to tear down the current
|
||||
* operating mode, and call this function with the desired mode.
|
||||
*
|
||||
* @param mode : The framework mode of operation, only MICO_BT_HCI_MODE is
|
||||
* supported now
|
||||
* @param device_name : A user-friendly name of the local Bluetooth device. A
|
||||
* name longer than 21 characters will be truncated.
|
||||
* @param client_links : Max cocurrent connections as a BLE client
|
||||
* @param server_links :
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
|
||||
OSStatus mico_bt_init( mico_bt_mode_t mode, const char* device_name, uint8_t client_links, uint8_t server_links );
|
||||
|
||||
/** Deinitialise the MICO Bluetooth Framework
|
||||
*
|
||||
* This function tears down all active framework components. Depending on the
|
||||
* hardware platform used, it may also power down the Bluetooth device.
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_deinit( void );
|
||||
|
||||
/** Initialise the device address of the local Bluetooth device
|
||||
*
|
||||
* This function provides users with a option to overwrite the default address of
|
||||
* the local Bluetooth device with the address provided. Once called, @ref mico_bt_init()
|
||||
* overwrites the default address with the address provided. Users can selectively
|
||||
* overwrite bits of the default address by setting the correspondping bits in the
|
||||
* 'mask' argument to 1.
|
||||
*
|
||||
* @warning When used, this function *MUST* be called before mico_bt_init()
|
||||
*
|
||||
* @param[in] address : new address
|
||||
* @param[in] mask : masking bits
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_init_address( const mico_bt_device_address_t* address, const mico_bt_device_address_t* mask );
|
||||
|
||||
|
||||
/** Start manufacturing test mode
|
||||
*
|
||||
* @param[in] config : Configuration of the UART peripheral that connects to the host PC
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_start_mfgtest_mode( const mico_uart_config_t* config );
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btdevmgmt Device
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Device Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Retrieve the device address of the local Bluetooth device
|
||||
*
|
||||
* @param[out] address : device address
|
||||
*
|
||||
* @return MICO_TRUE : is device address successfully retrieved;
|
||||
* MICO_FALSE : if not or if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_device_get_address( mico_bt_device_address_t* address );
|
||||
|
||||
/** Retrieve the user-friendly name of the local Bluetooth device
|
||||
*
|
||||
* @return pointer to the device name string
|
||||
*/
|
||||
const char* mico_bt_device_get_name( void );
|
||||
|
||||
/** Check if the local Bluetooth device is powered
|
||||
*
|
||||
* @return MICO_TRUE : if powered on;
|
||||
* MICO_FALSE : if not powered or if an error occurred
|
||||
*/
|
||||
mico_bool_t mico_bt_device_is_on( void );
|
||||
|
||||
/** Check if the local Bluetooth device is connectable state
|
||||
*
|
||||
* @return MICO_TRUE : is in connectable state;
|
||||
* MICO_FALSE : if not or if an error occurred
|
||||
*/
|
||||
mico_bool_t mico_bt_device_is_connectable( void );
|
||||
|
||||
/** Check if the local Bluetooth device is discoverable state
|
||||
*
|
||||
* @return MICO_TRUE : is in discoverable state;
|
||||
* MICO_FALSE : if not or if an error occurred
|
||||
*/
|
||||
mico_bool_t mico_bt_device_is_discoverable( void );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btdevmgmt Device
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Pairing Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Start a MiCO bluetooth LE pairing procedure
|
||||
*
|
||||
*
|
||||
* @param address : The remote device address
|
||||
* @param type : The remote device address type
|
||||
* @param settings : Security settings used in pairing procedure
|
||||
*
|
||||
* @return MICO_BT_PENDING if successfully initiated,
|
||||
* MICO_BT_SUCCESS if already paired to the device, else
|
||||
* error code
|
||||
*/
|
||||
OSStatus mico_bt_start_pairing( mico_bt_device_address_t address, mico_bt_smart_address_type_t type, const mico_bt_smart_security_settings_t* settings );
|
||||
|
||||
/** Stop a MiCO bluetooth LE pairing procedure
|
||||
*
|
||||
* @param address : The remote device address
|
||||
*
|
||||
* @return MICO_BT_PENDING if cancel initiated,
|
||||
* MICO_BT_SUCCESS if cancel has completed already, else error code.
|
||||
*/
|
||||
OSStatus mico_bt_stop_pairing( mico_bt_device_address_t address );
|
||||
|
||||
/** Satrt a MiCO bluetooth LE encryption procedure
|
||||
*
|
||||
* @param address : The remote device address
|
||||
*
|
||||
* @return MICO_BT_SUCCESS : already encrypted
|
||||
* MICO_BT_PENDING : command will be returned in the callback
|
||||
* MICO_BT_WRONG_MODE : connection not up.
|
||||
* MICO_BT_BUSY : security procedures are currently active
|
||||
*/
|
||||
OSStatus mico_bt_start_encryption( mico_bt_device_address_t* address );
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btpktmgmt Packet
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Packet Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Delete a MICO Bluetooth packet
|
||||
*
|
||||
* This function returns the packet's memory space back to the source, allowing
|
||||
* for reuse.
|
||||
*
|
||||
* @param packet : The pointer to the packet to delete
|
||||
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_BADARG : if bad argument(s) are inserted;
|
||||
* MICO_ERROR : if an error occurred.
|
||||
*/
|
||||
OSStatus mico_bt_packet_delete( mico_bt_packet_t* packet );
|
||||
|
||||
/** Get a pointer to the packet data
|
||||
*
|
||||
* This function retrieves a pointer to the start of the data section in the
|
||||
* packet. It also returns the current data size and the remaining data space
|
||||
* in the packet.
|
||||
*
|
||||
* @param packet : The pointer to the packet
|
||||
* @param data : A pointer that will receive the pointer to the
|
||||
* start of the data section in the packet
|
||||
* @param current_data_size : A pointer that will receive the size of the data
|
||||
* in the packet in bytes
|
||||
* @param available_space : A pointer that will receive the available data
|
||||
* space in the packet in bytes
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_BADARG : if bad argument(s) are inserted;
|
||||
* MICO_ERROR : if an error occurred.
|
||||
*/
|
||||
OSStatus mico_bt_packet_get_data( const mico_bt_packet_t* packet, uint8_t** data, uint32_t* current_data_size, uint32_t* available_space );
|
||||
|
||||
/** Set the end of the packet data
|
||||
*
|
||||
* This function updates the end of the data section and the data size in the
|
||||
* packet.
|
||||
*
|
||||
* @param packet : The pointer to the packet
|
||||
* @param data_end : The pointer to the end of the data section in the packet
|
||||
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_BADARG : if bad argument(s) are inserted;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_packet_set_data_end( mico_bt_packet_t* packet, const uint8_t* data_end );
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbwhitelist SmartBridge Whitelist Filter
|
||||
* @ingroup smartbridge
|
||||
*
|
||||
* SmartBridge Whitelist Filter Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/** Get the maximum number of devices supported by the whitelist
|
||||
*
|
||||
* @note
|
||||
* This function retrieves the maximum number of Bluetooth Smart devices which can
|
||||
* be added to the whitelist.
|
||||
*
|
||||
* @param[out] size : device count
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_get_whitelist_capability( uint8_t* size );
|
||||
|
||||
|
||||
/** Clear the whitelist
|
||||
*
|
||||
* @note
|
||||
* This function instructs the Bluetooth Controller to remove all devices from the
|
||||
* whitelist
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_clear_whitelist( void );
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Defines functions for using the MICO Bluetooth Framework
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico.h"
|
||||
#include "mico_bt_types.h"
|
||||
#include "mico_bt_dev.h"
|
||||
#include "mico_bt_smart_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/** MICO Bluetooth Framework mode of operation
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MICO_BT_MPAF_MODE, /**< The framework uses Multi-Profile Application Framework (MPAF). The entire Bluetooth stack runs on the controller. The host controls the controller using remote procedure calls (RPC) */
|
||||
MICO_BT_HCI_MODE, /**< The framework uses standard Host Controller Interface (HCI). The upper stack runs on the host and the lower stack runs on the controller */
|
||||
} mico_bt_mode_t;
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/** MICO Bluetooth packet.
|
||||
* An opaque data type representing a generic, zero-copy packet used for transporting data to/from the Bluetooth controller.
|
||||
*/
|
||||
typedef struct bt_packet mico_bt_packet_t;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
extern mico_worker_thread_t mico_bt_worker_thread;
|
||||
extern mico_worker_thread_t mico_bt_evt_worker_thread;
|
||||
|
||||
#define MICO_BT_WORKER_THREAD ((mico_worker_thread_t *)&mico_bt_worker_thread)
|
||||
#define MICO_BT_EVT_WORKER_THREAD ((mico_worker_thread_t *)&mico_bt_evt_worker_thread)
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @defgroup micobt Bluetooth
|
||||
*
|
||||
* MICO Bluetooth Framework Functions
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btfwmgmt Framework
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Framework Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initialise the MICO Bluetooth Framework
|
||||
*
|
||||
* This function initialises the local Bluetooth device and the framework core
|
||||
* components to operate in the mode specified. Upon return, the device is
|
||||
* powered.
|
||||
*
|
||||
* @note To switch mode, invoke @ref mico_bt_deinit to tear down the current
|
||||
* operating mode, and call this function with the desired mode.
|
||||
*
|
||||
* @param mode : The framework mode of operation, only MICO_BT_HCI_MODE is
|
||||
* supported now
|
||||
* @param device_name : A user-friendly name of the local Bluetooth device. A
|
||||
* name longer than 21 characters will be truncated.
|
||||
* @param client_links : Max cocurrent connections as a BLE client
|
||||
* @param server_links :
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
|
||||
OSStatus mico_bt_init( mico_bt_mode_t mode, const char* device_name, uint8_t client_links, uint8_t server_links );
|
||||
|
||||
/** Deinitialise the MICO Bluetooth Framework
|
||||
*
|
||||
* This function tears down all active framework components. Depending on the
|
||||
* hardware platform used, it may also power down the Bluetooth device.
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_deinit( void );
|
||||
|
||||
/** Initialise the device address of the local Bluetooth device
|
||||
*
|
||||
* This function provides users with a option to overwrite the default address of
|
||||
* the local Bluetooth device with the address provided. Once called, @ref mico_bt_init()
|
||||
* overwrites the default address with the address provided. Users can selectively
|
||||
* overwrite bits of the default address by setting the correspondping bits in the
|
||||
* 'mask' argument to 1.
|
||||
*
|
||||
* @warning When used, this function *MUST* be called before mico_bt_init()
|
||||
*
|
||||
* @param[in] address : new address
|
||||
* @param[in] mask : masking bits
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_init_address( const mico_bt_device_address_t* address, const mico_bt_device_address_t* mask );
|
||||
|
||||
|
||||
/** Start manufacturing test mode
|
||||
*
|
||||
* @param[in] config : Configuration of the UART peripheral that connects to the host PC
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_start_mfgtest_mode( const mico_uart_config_t* config );
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btdevmgmt Device
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Device Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Retrieve the device address of the local Bluetooth device
|
||||
*
|
||||
* @param[out] address : device address
|
||||
*
|
||||
* @return MICO_TRUE : is device address successfully retrieved;
|
||||
* MICO_FALSE : if not or if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_device_get_address( mico_bt_device_address_t* address );
|
||||
|
||||
/** Retrieve the user-friendly name of the local Bluetooth device
|
||||
*
|
||||
* @return pointer to the device name string
|
||||
*/
|
||||
const char* mico_bt_device_get_name( void );
|
||||
|
||||
/** Check if the local Bluetooth device is powered
|
||||
*
|
||||
* @return MICO_TRUE : if powered on;
|
||||
* MICO_FALSE : if not powered or if an error occurred
|
||||
*/
|
||||
mico_bool_t mico_bt_device_is_on( void );
|
||||
|
||||
/** Check if the local Bluetooth device is connectable state
|
||||
*
|
||||
* @return MICO_TRUE : is in connectable state;
|
||||
* MICO_FALSE : if not or if an error occurred
|
||||
*/
|
||||
mico_bool_t mico_bt_device_is_connectable( void );
|
||||
|
||||
/** Check if the local Bluetooth device is discoverable state
|
||||
*
|
||||
* @return MICO_TRUE : is in discoverable state;
|
||||
* MICO_FALSE : if not or if an error occurred
|
||||
*/
|
||||
mico_bool_t mico_bt_device_is_discoverable( void );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btdevmgmt Device
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Pairing Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Start a MiCO bluetooth LE pairing procedure
|
||||
*
|
||||
*
|
||||
* @param address : The remote device address
|
||||
* @param type : The remote device address type
|
||||
* @param settings : Security settings used in pairing procedure
|
||||
*
|
||||
* @return MICO_BT_PENDING if successfully initiated,
|
||||
* MICO_BT_SUCCESS if already paired to the device, else
|
||||
* error code
|
||||
*/
|
||||
OSStatus mico_bt_start_pairing( mico_bt_device_address_t address, mico_bt_smart_address_type_t type, const mico_bt_smart_security_settings_t* settings );
|
||||
|
||||
/** Stop a MiCO bluetooth LE pairing procedure
|
||||
*
|
||||
* @param address : The remote device address
|
||||
*
|
||||
* @return MICO_BT_PENDING if cancel initiated,
|
||||
* MICO_BT_SUCCESS if cancel has completed already, else error code.
|
||||
*/
|
||||
OSStatus mico_bt_stop_pairing( mico_bt_device_address_t address );
|
||||
|
||||
/** Satrt a MiCO bluetooth LE encryption procedure
|
||||
*
|
||||
* @param address : The remote device address
|
||||
*
|
||||
* @return MICO_BT_SUCCESS : already encrypted
|
||||
* MICO_BT_PENDING : command will be returned in the callback
|
||||
* MICO_BT_WRONG_MODE : connection not up.
|
||||
* MICO_BT_BUSY : security procedures are currently active
|
||||
*/
|
||||
OSStatus mico_bt_start_encryption( mico_bt_device_address_t* address );
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btpktmgmt Packet
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Packet Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Delete a MICO Bluetooth packet
|
||||
*
|
||||
* This function returns the packet's memory space back to the source, allowing
|
||||
* for reuse.
|
||||
*
|
||||
* @param packet : The pointer to the packet to delete
|
||||
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_BADARG : if bad argument(s) are inserted;
|
||||
* MICO_ERROR : if an error occurred.
|
||||
*/
|
||||
OSStatus mico_bt_packet_delete( mico_bt_packet_t* packet );
|
||||
|
||||
/** Get a pointer to the packet data
|
||||
*
|
||||
* This function retrieves a pointer to the start of the data section in the
|
||||
* packet. It also returns the current data size and the remaining data space
|
||||
* in the packet.
|
||||
*
|
||||
* @param packet : The pointer to the packet
|
||||
* @param data : A pointer that will receive the pointer to the
|
||||
* start of the data section in the packet
|
||||
* @param current_data_size : A pointer that will receive the size of the data
|
||||
* in the packet in bytes
|
||||
* @param available_space : A pointer that will receive the available data
|
||||
* space in the packet in bytes
|
||||
*
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_BADARG : if bad argument(s) are inserted;
|
||||
* MICO_ERROR : if an error occurred.
|
||||
*/
|
||||
OSStatus mico_bt_packet_get_data( const mico_bt_packet_t* packet, uint8_t** data, uint32_t* current_data_size, uint32_t* available_space );
|
||||
|
||||
/** Set the end of the packet data
|
||||
*
|
||||
* This function updates the end of the data section and the data size in the
|
||||
* packet.
|
||||
*
|
||||
* @param packet : The pointer to the packet
|
||||
* @param data_end : The pointer to the end of the data section in the packet
|
||||
|
||||
* @return MICO_SUCCESS : on success;
|
||||
* MICO_BADARG : if bad argument(s) are inserted;
|
||||
* MICO_ERROR : if an error occurred
|
||||
*/
|
||||
OSStatus mico_bt_packet_set_data_end( mico_bt_packet_t* packet, const uint8_t* data_end );
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbwhitelist SmartBridge Whitelist Filter
|
||||
* @ingroup smartbridge
|
||||
*
|
||||
* SmartBridge Whitelist Filter Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/** Get the maximum number of devices supported by the whitelist
|
||||
*
|
||||
* @note
|
||||
* This function retrieves the maximum number of Bluetooth Smart devices which can
|
||||
* be added to the whitelist.
|
||||
*
|
||||
* @param[out] size : device count
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_get_whitelist_capability( uint8_t* size );
|
||||
|
||||
|
||||
/** Clear the whitelist
|
||||
*
|
||||
* @note
|
||||
* This function instructs the Bluetooth Controller to remove all devices from the
|
||||
* whitelist
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_clear_whitelist( void );
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -1,394 +1,394 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico_bt_smart_interface.h"
|
||||
#include "LinkListUtils.h"
|
||||
#include "mico_bt_gatt.h"
|
||||
/** @file
|
||||
* Defines functions for bridging Bluetooth Smart with Wi-Fi
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* BT smart peripheral socket status
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPHERAL_SOCKET_DISCONNECTED, /**< Socket is disconnected */
|
||||
PERIPHERAL_SOCKET_CONNECTING, /**< Socket is in connecting state */
|
||||
PERIPHERAL_SOCKET_CONNECTED, /**< Socket is connected with a remote device */
|
||||
} mico_bt_peripheral_socket_status_t;
|
||||
|
||||
/**
|
||||
* Advertising filter policy
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPHERAL_ADVERT_FILTER_ALL_CONNECTION_REQ_ALL_SCAN_REQ = 0x00, /**< Process scan and connection requests from all devices (i.e., the White List is not in use) (default) */
|
||||
PERIPHERAL_ADVERT_FILTER_ALL_CONNECTION_REQ_WHITELIST_SCAN_REQ = 0x01, /**< Process connection requests from all devices and only scan requests from devices that are in the White List. */
|
||||
PERIPHERAL_ADVERT_FILTER_WHITELIST_CONNECTION_REQ_ALL_SCAN_REQ = 0x02, /**< Process scan requests from all devices and only connection requests from devices that are in the White List */
|
||||
PERIPHERAL_ADVERT_FILTER_WHITELIST_CONNECTION_REQ_WHITELIST_SCAN_REQ = 0x03, /**< Process scan and connection requests only from devices in the White List. */
|
||||
PERIPHERAL_ADVERT_FILTER_MAX
|
||||
} mico_bt_peripheral_adv_filter_policy_t;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
typedef struct _bt_ext_attribute_value_t mico_bt_ext_attribute_value_t;
|
||||
|
||||
/**
|
||||
* Socket to create a BT smart peripheral connection
|
||||
*/
|
||||
typedef struct mico_bt_peripheral_socket mico_bt_peripheral_socket_t;
|
||||
|
||||
/**
|
||||
* Socket connection callback
|
||||
*/
|
||||
typedef OSStatus (* mico_bt_peripheral_connection_callback_t) ( mico_bt_peripheral_socket_t* socket );
|
||||
|
||||
/**
|
||||
* Socket disconnection callback
|
||||
*/
|
||||
typedef OSStatus (* mico_bt_peripheral_disconnection_callback_t) ( mico_bt_peripheral_socket_t* socket );
|
||||
|
||||
/**
|
||||
* Attrubute request callback
|
||||
*/
|
||||
typedef mico_bt_gatt_status_t (* mico_bt_peripheral_attribute_handler)( mico_bt_ext_attribute_value_t *attribute, mico_bt_gatt_request_type_t op );
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
|
||||
#define BT_SMART_S_NONE ( 0x0 )
|
||||
#define BT_SMART_S_INDICATE ( 0x1 << 0 )
|
||||
#define BT_SMART_S_NOTIFICATION ( 0x1 << 1 )
|
||||
|
||||
typedef uint8_t bt_smart_server_send_type_t;
|
||||
|
||||
struct _bt_ext_attribute_value_t
|
||||
{
|
||||
linked_list_node_t this_node; /* Linked-list node of this characteristic */
|
||||
uint16_t handle; /* Attribute handle */
|
||||
uint16_t value_length; /* Attribute value length */
|
||||
uint16_t value_buffer_length; /* Attribute value buffer length */
|
||||
uint8_t* p_value; /* Pointer to characteristic value */
|
||||
mico_bt_peripheral_attribute_handler attribute_handler;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Socket to create a Smart Peripheral connection
|
||||
* @warning The content of the socket structure is for INTERNAL USE only. Modifying
|
||||
* the content of this structure is prohibited. Please use the Bluetooth SmartBridge
|
||||
* API to retrieve socket information.
|
||||
*/
|
||||
struct mico_bt_peripheral_socket
|
||||
{
|
||||
mico_bt_smart_device_t remote_device; /**< Remote Bluetooth device MiCO is connected with (BLE server) */
|
||||
uint16_t connection_handle; /**< Connection handle */
|
||||
uint8_t state; /**< Internal state */
|
||||
uint8_t actions; /**< Internal socket actions */
|
||||
mico_bt_peripheral_connection_callback_t connection_callback; /**< Callback for handling connection event by remote device */
|
||||
mico_bt_peripheral_disconnection_callback_t disconnection_callback; /**< Callback for handling disconnection event by remote device */
|
||||
mico_bt_smart_bonding_callback_t bonding_callback; /**< Callback for handling bonding evnet by remote device */
|
||||
mico_bt_smart_security_settings_t security_settings; /**< Security settings */
|
||||
mico_bt_smart_bond_request_t bond_req; /**< Bond Request Structure */
|
||||
mico_semaphore_t semaphore; /**< Semaphore */
|
||||
linked_list_t attribute_database; /**< Attribute database */
|
||||
uint16_t mtu;
|
||||
};
|
||||
|
||||
/******************************************************
|
||||
* Function declarations
|
||||
******************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup smartbridge SmartBridge
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth SmartBridge Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbmgmt SmartBridge Management
|
||||
* @ingroup smartbridge
|
||||
*
|
||||
* SmartBridge Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/** Initialise the MiCO BT peripheral
|
||||
*
|
||||
* @note
|
||||
* This function initialises:
|
||||
* \li Generic Attribute Profile (GATT) Server
|
||||
* \li Generic Access Profile (GAP) Peripheral Role
|
||||
* \li Security settings used when conneted by BT client
|
||||
* \li Initialises the socket internals to make it ready to connect to
|
||||
* a Bluetooth Smart Central
|
||||
*
|
||||
*
|
||||
* @return MICO_BT_SUCCESS: success , else @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_init( mico_bt_peripheral_socket_t* socket,
|
||||
const mico_bt_smart_security_settings_t* settings,
|
||||
mico_bt_peripheral_connection_callback_t connection_callback,
|
||||
mico_bt_peripheral_disconnection_callback_t disconnection_callback,
|
||||
mico_bt_smart_bonding_callback_t bonding_callback );
|
||||
|
||||
|
||||
/** Deinitialise the MiCO BT peripheral
|
||||
*
|
||||
* @note
|
||||
* This function deinitialises:
|
||||
* \li Generic Attribute Profile (GATT) Server
|
||||
* \li Generic Access Profile (GAP) Peripheral Role
|
||||
* \li Create BT peripheral Socket ready to be connected
|
||||
*
|
||||
* @return MICO_BT_SUCCESS: success
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_deinit( void );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbsock BT peripheral Socket and Connection Management
|
||||
* @ingroup SmartPeripheral
|
||||
*
|
||||
* BT peripheral Socket and Connection Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/** Get BT peripheral socket status
|
||||
*
|
||||
* @param[in] socket : pointer to the socket to get the status
|
||||
* @param[out] status : socket status
|
||||
*
|
||||
* @return MICO_BT_SUCCESS: success
|
||||
* MICO_BT_SMART_APPL_UNINITIALISED: Smart peripheral framework is uninitialized
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_get_socket_status( mico_bt_peripheral_socket_t* socket, mico_bt_peripheral_socket_status_t* status );
|
||||
|
||||
/** Disconnect BT peripheral connection
|
||||
*
|
||||
* @note
|
||||
* This function disconnects a connection with remote client.
|
||||
*
|
||||
* @return MICO_BT_SUCCESS: success
|
||||
* MICO_BT_SMART_APPL_UNINITIALISED: Smart peripheral framework is uninitialized
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_disconnect( void );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbscan Smart Peripheral Advert
|
||||
* @ingroup SmartPeripheral
|
||||
*
|
||||
* Smart Peripheral Advertising Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Start advertising local Bluetooth Smart devices
|
||||
*
|
||||
* @note
|
||||
* This function instructs the Bluetooth controller to start advertising. Advertising data
|
||||
* sould be set first use mico_bt_ble_set_advertisement_data().
|
||||
*
|
||||
* @warning
|
||||
* \li complete_callback is an intermediate report callback.
|
||||
*
|
||||
* @param[in] settings : advertising settings
|
||||
* @param[in] complete_callback : callback function which is called when advertising is
|
||||
* complete,running under MICO_BT_EVT_WORKER_THREAD
|
||||
*
|
||||
* @return MICO_BG_SUCCESS, else @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_start_advertisements( mico_bt_smart_advertising_settings_t* settings,
|
||||
mico_bt_smart_advertising_complete_callback_t complete_callback);
|
||||
|
||||
/** Stop the ongoing advertising process
|
||||
*
|
||||
* This function instructs the Bluetooth controller to advertising local
|
||||
* Bluetooth Smart devices.
|
||||
*
|
||||
* @return MICO_BG_SUCCESS, else @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_stop_advertisements( void );
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbwhitelist SmartBridge Whitelist Filter
|
||||
* @ingroup smartbridge
|
||||
*
|
||||
* SmartBridge Whitelist Filter Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Update the devices in white list.
|
||||
*
|
||||
* @param[in] add : Add or remove this device specified by device_address.
|
||||
* @param[in] device_address : Bluetooth address of the device to add to the whitelist
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_update_advertisements_white_list( mico_bool_t add, mico_bt_device_address_t device_address );
|
||||
|
||||
/** Get the number of devices in white list
|
||||
*
|
||||
* @param[out] size : The number of devices in white list.
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_get_advertisements_white_list_size( uint8_t *size );
|
||||
|
||||
/** Set Advertisements Filter Policy
|
||||
*
|
||||
* @param[in] policy : Advertisements filter policy
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_set_advertisements_filter_policy( mico_bt_peripheral_adv_filter_policy_t policy );
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbattr Smart peripheral Attribute Value database
|
||||
* @ingroup SmartPeripheral
|
||||
*
|
||||
* Smart Peripheral External Attribute Value Database Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Add an external attribute vale to BT peripheral
|
||||
*
|
||||
* @param handle[in] : Handle of an attribution
|
||||
* @param length[in] : Attribute value length (0, if value is not existed)
|
||||
* @param value[in] : Point to the Attribute value (NULL, if value is not existed)
|
||||
* @param handler[in] : Attribute request handler is synchronized triggerd
|
||||
* after an attribute write by remote GATT write operation
|
||||
* or before anattribute read by remote GATT read operation
|
||||
*
|
||||
* @return The address of the external attrbute value object, NULL if failed
|
||||
*/
|
||||
mico_bt_ext_attribute_value_t* mico_bt_peripheral_ext_attribute_add( uint16_t handle, uint16_t length, const uint8_t* value, mico_bt_peripheral_attribute_handler handler );
|
||||
|
||||
|
||||
/** Remove an external attribute vale from BT peripheral
|
||||
*
|
||||
* @param attribute[in] : The address of the external attrbute value object
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_ext_attribute_remove( mico_bt_ext_attribute_value_t* attribute );
|
||||
|
||||
/** Find an external attribute value from BT peripheral using handle
|
||||
*
|
||||
* @param handle[in] : Handle of an attribute
|
||||
* @param attribute_found[in,out] : Pointer to the external attribute address find by handle
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_ext_attribute_find_by_handle( uint16_t handle, mico_bt_ext_attribute_value_t** attribute_found );
|
||||
|
||||
|
||||
/** Write or update data to the external attribute value object
|
||||
*
|
||||
* @note
|
||||
* The value will copy to attrubute object, free after write
|
||||
*
|
||||
* @param handle[in] : Handle of an attribute
|
||||
* @param length[in] : Data length
|
||||
* @param length[in] : Attrubute value offset where data is written to
|
||||
* @param value[in] : Point to the data
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_ext_attribute_value_write( mico_bt_ext_attribute_value_t* attribute, uint16_t length, uint16_t value_offset, const uint8_t* value );
|
||||
|
||||
|
||||
/** Remove all external attribute vale from BT peripheral
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_ext_attribute_remove_all( void );
|
||||
|
||||
|
||||
/** Send external attribute value to BT client using indicate
|
||||
*
|
||||
*
|
||||
* @param socket[in] : Pointer to the socket to send attribute value
|
||||
* @param attribute[in] : Pointer to the external attribute that hold the value to be sent
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_gatt_indicate_attribute_value ( mico_bt_peripheral_socket_t* socket, const mico_bt_ext_attribute_value_t* attribute );
|
||||
|
||||
|
||||
/** Send external attribute value to BT client using notify
|
||||
*
|
||||
*
|
||||
* @param socket[in] : Pointer to the socket to send attribute value
|
||||
* @param attribute[in] : Pointer to the external attribute that hold the value to be sent
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_gatt_notify_attribute_value( mico_bt_peripheral_socket_t* socket, const mico_bt_ext_attribute_value_t* attribute );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico_bt_smart_interface.h"
|
||||
#include "LinkListUtils.h"
|
||||
#include "mico_bt_gatt.h"
|
||||
/** @file
|
||||
* Defines functions for bridging Bluetooth Smart with Wi-Fi
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* BT smart peripheral socket status
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPHERAL_SOCKET_DISCONNECTED, /**< Socket is disconnected */
|
||||
PERIPHERAL_SOCKET_CONNECTING, /**< Socket is in connecting state */
|
||||
PERIPHERAL_SOCKET_CONNECTED, /**< Socket is connected with a remote device */
|
||||
} mico_bt_peripheral_socket_status_t;
|
||||
|
||||
/**
|
||||
* Advertising filter policy
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPHERAL_ADVERT_FILTER_ALL_CONNECTION_REQ_ALL_SCAN_REQ = 0x00, /**< Process scan and connection requests from all devices (i.e., the White List is not in use) (default) */
|
||||
PERIPHERAL_ADVERT_FILTER_ALL_CONNECTION_REQ_WHITELIST_SCAN_REQ = 0x01, /**< Process connection requests from all devices and only scan requests from devices that are in the White List. */
|
||||
PERIPHERAL_ADVERT_FILTER_WHITELIST_CONNECTION_REQ_ALL_SCAN_REQ = 0x02, /**< Process scan requests from all devices and only connection requests from devices that are in the White List */
|
||||
PERIPHERAL_ADVERT_FILTER_WHITELIST_CONNECTION_REQ_WHITELIST_SCAN_REQ = 0x03, /**< Process scan and connection requests only from devices in the White List. */
|
||||
PERIPHERAL_ADVERT_FILTER_MAX
|
||||
} mico_bt_peripheral_adv_filter_policy_t;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
typedef struct _bt_ext_attribute_value_t mico_bt_ext_attribute_value_t;
|
||||
|
||||
/**
|
||||
* Socket to create a BT smart peripheral connection
|
||||
*/
|
||||
typedef struct mico_bt_peripheral_socket mico_bt_peripheral_socket_t;
|
||||
|
||||
/**
|
||||
* Socket connection callback
|
||||
*/
|
||||
typedef OSStatus (* mico_bt_peripheral_connection_callback_t) ( mico_bt_peripheral_socket_t* socket );
|
||||
|
||||
/**
|
||||
* Socket disconnection callback
|
||||
*/
|
||||
typedef OSStatus (* mico_bt_peripheral_disconnection_callback_t) ( mico_bt_peripheral_socket_t* socket );
|
||||
|
||||
/**
|
||||
* Attrubute request callback
|
||||
*/
|
||||
typedef mico_bt_gatt_status_t (* mico_bt_peripheral_attribute_handler)( mico_bt_ext_attribute_value_t *attribute, mico_bt_gatt_request_type_t op );
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
|
||||
#define BT_SMART_S_NONE ( 0x0 )
|
||||
#define BT_SMART_S_INDICATE ( 0x1 << 0 )
|
||||
#define BT_SMART_S_NOTIFICATION ( 0x1 << 1 )
|
||||
|
||||
typedef uint8_t bt_smart_server_send_type_t;
|
||||
|
||||
struct _bt_ext_attribute_value_t
|
||||
{
|
||||
linked_list_node_t this_node; /* Linked-list node of this characteristic */
|
||||
uint16_t handle; /* Attribute handle */
|
||||
uint16_t value_length; /* Attribute value length */
|
||||
uint16_t value_buffer_length; /* Attribute value buffer length */
|
||||
uint8_t* p_value; /* Pointer to characteristic value */
|
||||
mico_bt_peripheral_attribute_handler attribute_handler;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Socket to create a Smart Peripheral connection
|
||||
* @warning The content of the socket structure is for INTERNAL USE only. Modifying
|
||||
* the content of this structure is prohibited. Please use the Bluetooth SmartBridge
|
||||
* API to retrieve socket information.
|
||||
*/
|
||||
struct mico_bt_peripheral_socket
|
||||
{
|
||||
mico_bt_smart_device_t remote_device; /**< Remote Bluetooth device MiCO is connected with (BLE server) */
|
||||
uint16_t connection_handle; /**< Connection handle */
|
||||
uint8_t state; /**< Internal state */
|
||||
uint8_t actions; /**< Internal socket actions */
|
||||
mico_bt_peripheral_connection_callback_t connection_callback; /**< Callback for handling connection event by remote device */
|
||||
mico_bt_peripheral_disconnection_callback_t disconnection_callback; /**< Callback for handling disconnection event by remote device */
|
||||
mico_bt_smart_bonding_callback_t bonding_callback; /**< Callback for handling bonding evnet by remote device */
|
||||
mico_bt_smart_security_settings_t security_settings; /**< Security settings */
|
||||
mico_bt_smart_bond_request_t bond_req; /**< Bond Request Structure */
|
||||
mico_semaphore_t semaphore; /**< Semaphore */
|
||||
linked_list_t attribute_database; /**< Attribute database */
|
||||
uint16_t mtu;
|
||||
};
|
||||
|
||||
/******************************************************
|
||||
* Function declarations
|
||||
******************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup smartbridge SmartBridge
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth SmartBridge Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbmgmt SmartBridge Management
|
||||
* @ingroup smartbridge
|
||||
*
|
||||
* SmartBridge Management Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/** Initialise the MiCO BT peripheral
|
||||
*
|
||||
* @note
|
||||
* This function initialises:
|
||||
* \li Generic Attribute Profile (GATT) Server
|
||||
* \li Generic Access Profile (GAP) Peripheral Role
|
||||
* \li Security settings used when conneted by BT client
|
||||
* \li Initialises the socket internals to make it ready to connect to
|
||||
* a Bluetooth Smart Central
|
||||
*
|
||||
*
|
||||
* @return MICO_BT_SUCCESS: success , else @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_init( mico_bt_peripheral_socket_t* socket,
|
||||
const mico_bt_smart_security_settings_t* settings,
|
||||
mico_bt_peripheral_connection_callback_t connection_callback,
|
||||
mico_bt_peripheral_disconnection_callback_t disconnection_callback,
|
||||
mico_bt_smart_bonding_callback_t bonding_callback );
|
||||
|
||||
|
||||
/** Deinitialise the MiCO BT peripheral
|
||||
*
|
||||
* @note
|
||||
* This function deinitialises:
|
||||
* \li Generic Attribute Profile (GATT) Server
|
||||
* \li Generic Access Profile (GAP) Peripheral Role
|
||||
* \li Create BT peripheral Socket ready to be connected
|
||||
*
|
||||
* @return MICO_BT_SUCCESS: success
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_deinit( void );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbsock BT peripheral Socket and Connection Management
|
||||
* @ingroup SmartPeripheral
|
||||
*
|
||||
* BT peripheral Socket and Connection Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/** Get BT peripheral socket status
|
||||
*
|
||||
* @param[in] socket : pointer to the socket to get the status
|
||||
* @param[out] status : socket status
|
||||
*
|
||||
* @return MICO_BT_SUCCESS: success
|
||||
* MICO_BT_SMART_APPL_UNINITIALISED: Smart peripheral framework is uninitialized
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_get_socket_status( mico_bt_peripheral_socket_t* socket, mico_bt_peripheral_socket_status_t* status );
|
||||
|
||||
/** Disconnect BT peripheral connection
|
||||
*
|
||||
* @note
|
||||
* This function disconnects a connection with remote client.
|
||||
*
|
||||
* @return MICO_BT_SUCCESS: success
|
||||
* MICO_BT_SMART_APPL_UNINITIALISED: Smart peripheral framework is uninitialized
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_disconnect( void );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbscan Smart Peripheral Advert
|
||||
* @ingroup SmartPeripheral
|
||||
*
|
||||
* Smart Peripheral Advertising Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Start advertising local Bluetooth Smart devices
|
||||
*
|
||||
* @note
|
||||
* This function instructs the Bluetooth controller to start advertising. Advertising data
|
||||
* sould be set first use mico_bt_ble_set_advertisement_data().
|
||||
*
|
||||
* @warning
|
||||
* \li complete_callback is an intermediate report callback.
|
||||
*
|
||||
* @param[in] settings : advertising settings
|
||||
* @param[in] complete_callback : callback function which is called when advertising is
|
||||
* complete,running under MICO_BT_EVT_WORKER_THREAD
|
||||
*
|
||||
* @return MICO_BG_SUCCESS, else @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_start_advertisements( mico_bt_smart_advertising_settings_t* settings,
|
||||
mico_bt_smart_advertising_complete_callback_t complete_callback);
|
||||
|
||||
/** Stop the ongoing advertising process
|
||||
*
|
||||
* This function instructs the Bluetooth controller to advertising local
|
||||
* Bluetooth Smart devices.
|
||||
*
|
||||
* @return MICO_BG_SUCCESS, else @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_stop_advertisements( void );
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbwhitelist SmartBridge Whitelist Filter
|
||||
* @ingroup smartbridge
|
||||
*
|
||||
* SmartBridge Whitelist Filter Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Update the devices in white list.
|
||||
*
|
||||
* @param[in] add : Add or remove this device specified by device_address.
|
||||
* @param[in] device_address : Bluetooth address of the device to add to the whitelist
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_update_advertisements_white_list( mico_bool_t add, mico_bt_device_address_t device_address );
|
||||
|
||||
/** Get the number of devices in white list
|
||||
*
|
||||
* @param[out] size : The number of devices in white list.
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_get_advertisements_white_list_size( uint8_t *size );
|
||||
|
||||
/** Set Advertisements Filter Policy
|
||||
*
|
||||
* @param[in] policy : Advertisements filter policy
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_set_advertisements_filter_policy( mico_bt_peripheral_adv_filter_policy_t policy );
|
||||
|
||||
/** @} */
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbattr Smart peripheral Attribute Value database
|
||||
* @ingroup SmartPeripheral
|
||||
*
|
||||
* Smart Peripheral External Attribute Value Database Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Add an external attribute vale to BT peripheral
|
||||
*
|
||||
* @param handle[in] : Handle of an attribution
|
||||
* @param length[in] : Attribute value length (0, if value is not existed)
|
||||
* @param value[in] : Point to the Attribute value (NULL, if value is not existed)
|
||||
* @param handler[in] : Attribute request handler is synchronized triggerd
|
||||
* after an attribute write by remote GATT write operation
|
||||
* or before anattribute read by remote GATT read operation
|
||||
*
|
||||
* @return The address of the external attrbute value object, NULL if failed
|
||||
*/
|
||||
mico_bt_ext_attribute_value_t* mico_bt_peripheral_ext_attribute_add( uint16_t handle, uint16_t length, const uint8_t* value, mico_bt_peripheral_attribute_handler handler );
|
||||
|
||||
|
||||
/** Remove an external attribute vale from BT peripheral
|
||||
*
|
||||
* @param attribute[in] : The address of the external attrbute value object
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_ext_attribute_remove( mico_bt_ext_attribute_value_t* attribute );
|
||||
|
||||
/** Find an external attribute value from BT peripheral using handle
|
||||
*
|
||||
* @param handle[in] : Handle of an attribute
|
||||
* @param attribute_found[in,out] : Pointer to the external attribute address find by handle
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_ext_attribute_find_by_handle( uint16_t handle, mico_bt_ext_attribute_value_t** attribute_found );
|
||||
|
||||
|
||||
/** Write or update data to the external attribute value object
|
||||
*
|
||||
* @note
|
||||
* The value will copy to attrubute object, free after write
|
||||
*
|
||||
* @param handle[in] : Handle of an attribute
|
||||
* @param length[in] : Data length
|
||||
* @param length[in] : Attrubute value offset where data is written to
|
||||
* @param value[in] : Point to the data
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_ext_attribute_value_write( mico_bt_ext_attribute_value_t* attribute, uint16_t length, uint16_t value_offset, const uint8_t* value );
|
||||
|
||||
|
||||
/** Remove all external attribute vale from BT peripheral
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_ext_attribute_remove_all( void );
|
||||
|
||||
|
||||
/** Send external attribute value to BT client using indicate
|
||||
*
|
||||
*
|
||||
* @param socket[in] : Pointer to the socket to send attribute value
|
||||
* @param attribute[in] : Pointer to the external attribute that hold the value to be sent
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_gatt_indicate_attribute_value ( mico_bt_peripheral_socket_t* socket, const mico_bt_ext_attribute_value_t* attribute );
|
||||
|
||||
|
||||
/** Send external attribute value to BT client using notify
|
||||
*
|
||||
*
|
||||
* @param socket[in] : Pointer to the socket to send attribute value
|
||||
* @param attribute[in] : Pointer to the external attribute that hold the value to be sent
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_peripheral_gatt_notify_attribute_value( mico_bt_peripheral_socket_t* socket, const mico_bt_ext_attribute_value_t* attribute );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,417 +1,417 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Defines structures and functions for Bluetooth Smart Attribute abstraction
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico.h"
|
||||
#include "mico_bt_smartbridge_constants.h"
|
||||
#include "mico_bt_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/** @cond !ADDTHIS*/
|
||||
/* Attribute structure fixed length */
|
||||
#define ATTR_COMMON_FIELDS_SIZE ( sizeof(mico_bt_smart_attribute_t*) + sizeof(uint16_t) + sizeof(mico_bt_uuid_t) + sizeof(uint8_t) + sizeof(uint32_t) + + sizeof(uint32_t))
|
||||
|
||||
#define ATTR_NO_VALUE_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(uint8_t) )
|
||||
#define ATTR_LONG_VALUE_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(uint8_t) * MAX_CHARACTERISTIC_VALUE_LENGTH )
|
||||
#define ATTR_SERVICE_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_service_t) )
|
||||
#define ATTR_INCLUDE_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_include_t) )
|
||||
#define ATTR_CHARACTERISTIC_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_characteristic_t) )
|
||||
#define ATTR_CHARACTERISTIC_VALUE_SIZE( value_length ) ( ATTR_COMMON_FIELDS_SIZE + (sizeof(uint8_t) * value_length) )
|
||||
#define ATTR_EXTENDED_PROPERTIES_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_extended_properties_t) )
|
||||
#define ATTR_USER_DESCRIPTION_SIZE( string_length ) ( ATTR_COMMON_FIELDS_SIZE + (sizeof(char) * string_length) )
|
||||
#define ATTR_CLIENT_CONFIG_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_client_config_t) )
|
||||
#define ATTR_SERVER_CONFIG_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_server_config_t) )
|
||||
#define ATTR_PRESENTATION_FORMAT_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_presentation_format_t) )
|
||||
#define ATTR_AGGREGATE_FORMAT_SIZE( handle_count ) ( ATTR_COMMON_FIELDS_SIZE + (sizeof(uint16_t) * handle_count) )
|
||||
|
||||
/* Maximum characteristic value length */
|
||||
#define MAX_CHARACTERISTIC_VALUE_LENGTH 512
|
||||
/** @endcond */
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Attribute type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MICO_ATTRIBUTE_TYPE_NO_VALUE, /**< Attribute with no value */
|
||||
MICO_ATTRIBUTE_TYPE_LONG_VALUE, /**< Attribute with long value */
|
||||
MICO_ATTRIBUTE_TYPE_PRIMARY_SERVICE, /**< Primary service */
|
||||
MICO_ATTRIBUTE_TYPE_INCLUDE, /**< Included Service */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC, /**< Characteristic */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_VALUE, /**< Characteristic Value */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_EXTENDED_PROPERTIES, /**< Characteristic Descriptor: Extended Properties */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_USER_DESCRIPTION, /**< Characteristic Descriptor: User Description */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_CLIENT_CONFIGURATION, /**< Characteristic Descriptor: Client Configuration */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_SERVER_CONFIGURATION, /**< Characteristic Descriptor: Server Configuration */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_PRESENTATION_FORMAT, /**< Characteristic Descriptor: Presentation Format */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_AGGREGATE_FORMAT /**< Characteristic Descriptor: Aggregate Format */
|
||||
} mico_bt_smart_attribute_type_t;
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
#pragma pack(1)
|
||||
/* @note: The following Attribute Values follow the Bluetooth Core Spec v4.0
|
||||
* Volume 3 Part G Section 3 closely. This allows for direct memcpy from
|
||||
* the ATT response PDU to the Attribute Value structure. Also note that
|
||||
* any additional fields follow the fields in the specification.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 3.1 Attribute Value of Service Definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_handle; /**< Starting handle */
|
||||
uint16_t end_handle; /**< Ending handle */
|
||||
mico_bt_uuid_t uuid; /**< UUID */
|
||||
} attr_val_service_t;
|
||||
|
||||
/**
|
||||
* 3.2 Attribute Value of Include Definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t included_service_handle; /**< Included service handle */
|
||||
uint16_t end_group_handle; /**< End group handle */
|
||||
mico_bt_uuid_t uuid; /**< UUID */
|
||||
} attr_val_include_t;
|
||||
|
||||
/**
|
||||
* 3.3.1 Attribute Value of Characteristic Declaration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t properties; /**< Properties */
|
||||
uint16_t value_handle; /**< Value handle */
|
||||
mico_bt_uuid_t uuid; /**< UUID */
|
||||
|
||||
uint16_t descriptor_start_handle; /**< Descriptor start handle. Additional field. Not in spec */
|
||||
uint16_t descriptor_end_handle; /**< Descriptor end handle. Additional field. Not in spec */
|
||||
} attr_val_characteristic_t;
|
||||
|
||||
/**
|
||||
* 3.3.2 Attribute Value of Characteristic Value Declaration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t value[1]; /**< Start of value */
|
||||
} attr_val_characteristic_value_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.1 Attribute Value of Characteristic Extended Properties
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t properties; /**< Properties */
|
||||
} attr_val_extended_properties_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.2 Attribute Value of Characteristic User Description
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char string[1]; /**< User description string */
|
||||
} attr_val_user_description_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.3 Attribute Value of Client Characteristic Configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t config_bits; /**< Configuration bits */
|
||||
} attr_val_client_config_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.4 Attribute Value of Server Characteristic Configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t config_bits; /**< Configuration bits */
|
||||
} attr_val_server_config_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.5 Attribute Value of Characteristic Presentation Format
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t format; /**< Format */
|
||||
uint8_t exponent; /**< Exponent */
|
||||
uint16_t unit; /**< Unit */
|
||||
uint8_t name_space; /**< Namespace */
|
||||
uint16_t description; /**< Description */
|
||||
} attr_val_presentation_format_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.6 Attribute Value of Characteristic Aggregate Format
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle_list[1]; /**< Handle list */
|
||||
} attr_val_aggregate_format_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.1 Attribute Value of Device Name Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char device_name[1]; /**< Maximum length is 248 bytes */
|
||||
} attr_val_device_name_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.2 Attribute Value of Appearance Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t appearance; /**< Enumerated value defined in "Assigned Numbers" */
|
||||
} attr_val_appearance_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.3 Attribute Value of Peripheral Privacy Flag Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t periph_privacy_flag; /**< Peripheral privacy flag: 0 if disabled; 1 if enabled */
|
||||
} attr_val_periph_privacy_flag_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.4 Attribute Value of Reconnection Address Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t reconn_address[6]; /**< Network-order reconnection address */
|
||||
} attr_val_reconnection_address_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.5 Attribute Value of Peripheral Preferred Connection Parameters Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t min_conn_interval; /**< Minimum connection interval */
|
||||
uint16_t max_conn_interval; /**< Maximum connection interval */
|
||||
uint16_t slave_latency; /**< Slave latency */
|
||||
uint16_t conn_supervision_timeout_multiplier; /**< Connection supervision timeout multiplier */
|
||||
} attr_val_periph_preferred_conn_params_t;
|
||||
|
||||
/**
|
||||
* Attribute Structure
|
||||
*/
|
||||
typedef struct mico_bt_attribute
|
||||
{
|
||||
struct mico_bt_attribute* next; /**< Pointer to the next attribute in the list. NULL if not a list */
|
||||
uint16_t handle; /**< Attribute Handle */
|
||||
mico_bt_uuid_t type; /**< Attribute Type (UUID) */
|
||||
uint8_t permission; /**< Attribute Permission(s). Unused in GATT client */
|
||||
uint32_t value_length; /**< Length of the Attribute Value. If no value, this equals 0 */
|
||||
uint32_t value_struct_size; /**< Size of the value structure */
|
||||
|
||||
/* Union of Attribute Values. Use the right format based on Attribute Type */
|
||||
union
|
||||
{
|
||||
uint8_t value[MAX_CHARACTERISTIC_VALUE_LENGTH]; /**< Long Value */
|
||||
attr_val_service_t service; /**< Attribute Value for Service */
|
||||
attr_val_include_t include; /**< Attribute Value for Include */
|
||||
attr_val_characteristic_t characteristic; /**< Attribute Value for Characteristic */
|
||||
attr_val_characteristic_value_t characteristic_value; /**< Attribute Value for Characteristic Value */
|
||||
attr_val_extended_properties_t extended_properties; /**< Attribute Value for Descriptor: Characteristic Extended Properties */
|
||||
attr_val_user_description_t user_description; /**< Attribute Value for Descriptor: Characteristic User_Description */
|
||||
attr_val_client_config_t client_config; /**< Attribute Value for Descriptor: Client Characteristic Configuration */
|
||||
attr_val_server_config_t server_config; /**< Attribute Value for Descriptor: Server Characteristic Configuration */
|
||||
attr_val_presentation_format_t presentation_format; /**< Attribute Value for Descriptor: Characteristic Presentation Format */
|
||||
attr_val_aggregate_format_t aggregate_format; /**< Attribute Value for Descriptor: Characteristic Aggregate Format */
|
||||
attr_val_device_name_t device_name; /**< Attribute Value for Characteristic Type: Device Name */
|
||||
attr_val_appearance_t appearance; /**< Attribute Value for Characteristic Type: Appearance */
|
||||
attr_val_periph_privacy_flag_t periph_privacy_flag; /**< Attribute Value for Characteristic Type: Peripheral Privacy Flag */
|
||||
attr_val_reconnection_address_t reconn_address; /**< Attribute Value for Characteristic Type: Reconnection Address */
|
||||
attr_val_periph_preferred_conn_params_t periph_preferred_conn_params; /**< Attribute Value for Characteristic Type: Peripheral Preferred Connection Parameters */
|
||||
} value; /**< Union of Attribute Values. Use the right format based on Attribute Type */
|
||||
|
||||
} mico_bt_smart_attribute_t;
|
||||
|
||||
/**
|
||||
* Attribute List Structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t count; /**< Attribute count */
|
||||
mico_bt_smart_attribute_t* list; /**< Pointer to attribute linked-list */
|
||||
} mico_bt_smart_attribute_list_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btattr Attribute
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Smart Attribute Abstraction
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Create a Bluetooth Smart Attribute structure
|
||||
*
|
||||
* @param[out] attribute : pointer that will receive the attribute structure
|
||||
* @param[in] type : attribute type
|
||||
* @param[in] variable_length : length of the variable part of the attribute.
|
||||
* For some attribute types, this argument is not
|
||||
* used.
|
||||
*
|
||||
* @return MICO_BT_SUCCESS:success,MICO_BT_BADARG:input argument error
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_create( mico_bt_smart_attribute_t** attribute, mico_bt_smart_attribute_type_t type, uint16_t variable_length );
|
||||
|
||||
/** Delete a Bluetooth Smart Attribute structure
|
||||
*
|
||||
* @param[in,out] attribute : attribute structure to delete
|
||||
*
|
||||
* @return MICO_BT_SUCCESS:success,MICO_BT_BADARG:input argument error
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_delete( mico_bt_smart_attribute_t* attribute );
|
||||
|
||||
/** Initialise a list of Bluetooth Smart Attributes
|
||||
*
|
||||
* @param[out] list : list to initialise
|
||||
*
|
||||
* @return MICO_BT_SUCCESS:success,MICO_BT_BADARG:input argument error
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_create_list( mico_bt_smart_attribute_list_t* list );
|
||||
|
||||
/** Deinitialise a list of Bluetooth Smart Attributes
|
||||
*
|
||||
* @param[out] list : list to deinitialise
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_delete_list( mico_bt_smart_attribute_list_t* list );
|
||||
|
||||
/** Add a Bluetooth Smart Attribute to a list
|
||||
*
|
||||
* @param[in,out] list : list to add attribute to
|
||||
* @param[in] attribute : attribute to add to the list
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_add_to_list( mico_bt_smart_attribute_list_t* list, mico_bt_smart_attribute_t* attribute );
|
||||
|
||||
/** Remove a Bluetooth Smart Attribute with the given handle from a list
|
||||
*
|
||||
* @param[in,out] list : list to remote attribute from
|
||||
* @param[in] handle : handle of the attribute to remove
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_remove_from_list( mico_bt_smart_attribute_list_t* list, uint16_t handle );
|
||||
|
||||
/** Find a Bluetooth Smart Attribute with the given handle from a list
|
||||
*
|
||||
* @param[in,out] list : list to find attribute in
|
||||
* @param[in] handle : handle of the attribute to find
|
||||
* @param[out] attribute : pointer that will receive the attribute
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_search_list_by_handle( const mico_bt_smart_attribute_list_t* list, uint16_t handle, mico_bt_smart_attribute_t** attribute );
|
||||
|
||||
/** Find a Bluetooth Smart Attribute with the given handle from a list
|
||||
*
|
||||
* @param[in,out] list : list to find attribute in
|
||||
* @param[in] uuid : UUID of the attribute to find
|
||||
* @param[in] starting_handle : handle to start the search
|
||||
* @param[in] ending_handle : handle to end the search
|
||||
* @param[out] attribute : pointer that will receive the attribute
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_search_list_by_uuid( const mico_bt_smart_attribute_list_t* list, const mico_bt_uuid_t* uuid, uint16_t starting_handle, uint16_t ending_handle, mico_bt_smart_attribute_t** attribute );
|
||||
|
||||
/** Merge two Bluetooth Smart Attribute lists
|
||||
*
|
||||
* @param[in,out] trunk_list : list that will receive all of the attributes from the branch list
|
||||
* @param[in,out] branch_list : list whose attributes will be removed and inserted into the trunk list
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_merge_lists( mico_bt_smart_attribute_list_t* trunk_list, mico_bt_smart_attribute_list_t* branch_list );
|
||||
|
||||
/** Print attribute contents
|
||||
*
|
||||
* @param[in] attribute : attribute to print
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_print( const mico_bt_smart_attribute_t* attribute );
|
||||
|
||||
/** Print the contents of all attributes in a list
|
||||
*
|
||||
* @param[in] list : list whose attributes to print
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_print_list( const mico_bt_smart_attribute_list_t* list );
|
||||
|
||||
/** Get attribute list head
|
||||
*
|
||||
* @param[in] list : attribute list
|
||||
* @param[out] head : pointer that will receive the list head
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_get_list_head( const mico_bt_smart_attribute_list_t* list, mico_bt_smart_attribute_t** head );
|
||||
|
||||
|
||||
/** Get attribute list count
|
||||
*
|
||||
* @param[in] list : attribute list
|
||||
* @param[out] count : variable that will receive the count
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_get_list_count( const mico_bt_smart_attribute_list_t* list, uint32_t* count );
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Defines structures and functions for Bluetooth Smart Attribute abstraction
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico.h"
|
||||
#include "mico_bt_smartbridge_constants.h"
|
||||
#include "mico_bt_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/** @cond !ADDTHIS*/
|
||||
/* Attribute structure fixed length */
|
||||
#define ATTR_COMMON_FIELDS_SIZE ( sizeof(mico_bt_smart_attribute_t*) + sizeof(uint16_t) + sizeof(mico_bt_uuid_t) + sizeof(uint8_t) + sizeof(uint32_t) + + sizeof(uint32_t))
|
||||
|
||||
#define ATTR_NO_VALUE_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(uint8_t) )
|
||||
#define ATTR_LONG_VALUE_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(uint8_t) * MAX_CHARACTERISTIC_VALUE_LENGTH )
|
||||
#define ATTR_SERVICE_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_service_t) )
|
||||
#define ATTR_INCLUDE_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_include_t) )
|
||||
#define ATTR_CHARACTERISTIC_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_characteristic_t) )
|
||||
#define ATTR_CHARACTERISTIC_VALUE_SIZE( value_length ) ( ATTR_COMMON_FIELDS_SIZE + (sizeof(uint8_t) * value_length) )
|
||||
#define ATTR_EXTENDED_PROPERTIES_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_extended_properties_t) )
|
||||
#define ATTR_USER_DESCRIPTION_SIZE( string_length ) ( ATTR_COMMON_FIELDS_SIZE + (sizeof(char) * string_length) )
|
||||
#define ATTR_CLIENT_CONFIG_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_client_config_t) )
|
||||
#define ATTR_SERVER_CONFIG_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_server_config_t) )
|
||||
#define ATTR_PRESENTATION_FORMAT_SIZE ( ATTR_COMMON_FIELDS_SIZE + sizeof(attr_val_presentation_format_t) )
|
||||
#define ATTR_AGGREGATE_FORMAT_SIZE( handle_count ) ( ATTR_COMMON_FIELDS_SIZE + (sizeof(uint16_t) * handle_count) )
|
||||
|
||||
/* Maximum characteristic value length */
|
||||
#define MAX_CHARACTERISTIC_VALUE_LENGTH 512
|
||||
/** @endcond */
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Attribute type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MICO_ATTRIBUTE_TYPE_NO_VALUE, /**< Attribute with no value */
|
||||
MICO_ATTRIBUTE_TYPE_LONG_VALUE, /**< Attribute with long value */
|
||||
MICO_ATTRIBUTE_TYPE_PRIMARY_SERVICE, /**< Primary service */
|
||||
MICO_ATTRIBUTE_TYPE_INCLUDE, /**< Included Service */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC, /**< Characteristic */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_VALUE, /**< Characteristic Value */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_EXTENDED_PROPERTIES, /**< Characteristic Descriptor: Extended Properties */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_USER_DESCRIPTION, /**< Characteristic Descriptor: User Description */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_CLIENT_CONFIGURATION, /**< Characteristic Descriptor: Client Configuration */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_SERVER_CONFIGURATION, /**< Characteristic Descriptor: Server Configuration */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_PRESENTATION_FORMAT, /**< Characteristic Descriptor: Presentation Format */
|
||||
MICO_ATTRIBUTE_TYPE_CHARACTERISTIC_DESCRIPTOR_AGGREGATE_FORMAT /**< Characteristic Descriptor: Aggregate Format */
|
||||
} mico_bt_smart_attribute_type_t;
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
#pragma pack(1)
|
||||
/* @note: The following Attribute Values follow the Bluetooth Core Spec v4.0
|
||||
* Volume 3 Part G Section 3 closely. This allows for direct memcpy from
|
||||
* the ATT response PDU to the Attribute Value structure. Also note that
|
||||
* any additional fields follow the fields in the specification.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 3.1 Attribute Value of Service Definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_handle; /**< Starting handle */
|
||||
uint16_t end_handle; /**< Ending handle */
|
||||
mico_bt_uuid_t uuid; /**< UUID */
|
||||
} attr_val_service_t;
|
||||
|
||||
/**
|
||||
* 3.2 Attribute Value of Include Definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t included_service_handle; /**< Included service handle */
|
||||
uint16_t end_group_handle; /**< End group handle */
|
||||
mico_bt_uuid_t uuid; /**< UUID */
|
||||
} attr_val_include_t;
|
||||
|
||||
/**
|
||||
* 3.3.1 Attribute Value of Characteristic Declaration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t properties; /**< Properties */
|
||||
uint16_t value_handle; /**< Value handle */
|
||||
mico_bt_uuid_t uuid; /**< UUID */
|
||||
|
||||
uint16_t descriptor_start_handle; /**< Descriptor start handle. Additional field. Not in spec */
|
||||
uint16_t descriptor_end_handle; /**< Descriptor end handle. Additional field. Not in spec */
|
||||
} attr_val_characteristic_t;
|
||||
|
||||
/**
|
||||
* 3.3.2 Attribute Value of Characteristic Value Declaration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t value[1]; /**< Start of value */
|
||||
} attr_val_characteristic_value_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.1 Attribute Value of Characteristic Extended Properties
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t properties; /**< Properties */
|
||||
} attr_val_extended_properties_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.2 Attribute Value of Characteristic User Description
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char string[1]; /**< User description string */
|
||||
} attr_val_user_description_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.3 Attribute Value of Client Characteristic Configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t config_bits; /**< Configuration bits */
|
||||
} attr_val_client_config_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.4 Attribute Value of Server Characteristic Configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t config_bits; /**< Configuration bits */
|
||||
} attr_val_server_config_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.5 Attribute Value of Characteristic Presentation Format
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t format; /**< Format */
|
||||
uint8_t exponent; /**< Exponent */
|
||||
uint16_t unit; /**< Unit */
|
||||
uint8_t name_space; /**< Namespace */
|
||||
uint16_t description; /**< Description */
|
||||
} attr_val_presentation_format_t;
|
||||
|
||||
/**
|
||||
* 3.3.3.6 Attribute Value of Characteristic Aggregate Format
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle_list[1]; /**< Handle list */
|
||||
} attr_val_aggregate_format_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.1 Attribute Value of Device Name Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char device_name[1]; /**< Maximum length is 248 bytes */
|
||||
} attr_val_device_name_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.2 Attribute Value of Appearance Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t appearance; /**< Enumerated value defined in "Assigned Numbers" */
|
||||
} attr_val_appearance_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.3 Attribute Value of Peripheral Privacy Flag Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t periph_privacy_flag; /**< Peripheral privacy flag: 0 if disabled; 1 if enabled */
|
||||
} attr_val_periph_privacy_flag_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.4 Attribute Value of Reconnection Address Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t reconn_address[6]; /**< Network-order reconnection address */
|
||||
} attr_val_reconnection_address_t;
|
||||
|
||||
/**
|
||||
* Vol 3 Part C 12.5 Attribute Value of Peripheral Preferred Connection Parameters Characteristic
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t min_conn_interval; /**< Minimum connection interval */
|
||||
uint16_t max_conn_interval; /**< Maximum connection interval */
|
||||
uint16_t slave_latency; /**< Slave latency */
|
||||
uint16_t conn_supervision_timeout_multiplier; /**< Connection supervision timeout multiplier */
|
||||
} attr_val_periph_preferred_conn_params_t;
|
||||
|
||||
/**
|
||||
* Attribute Structure
|
||||
*/
|
||||
typedef struct mico_bt_attribute
|
||||
{
|
||||
struct mico_bt_attribute* next; /**< Pointer to the next attribute in the list. NULL if not a list */
|
||||
uint16_t handle; /**< Attribute Handle */
|
||||
mico_bt_uuid_t type; /**< Attribute Type (UUID) */
|
||||
uint8_t permission; /**< Attribute Permission(s). Unused in GATT client */
|
||||
uint32_t value_length; /**< Length of the Attribute Value. If no value, this equals 0 */
|
||||
uint32_t value_struct_size; /**< Size of the value structure */
|
||||
|
||||
/* Union of Attribute Values. Use the right format based on Attribute Type */
|
||||
union
|
||||
{
|
||||
uint8_t value[MAX_CHARACTERISTIC_VALUE_LENGTH]; /**< Long Value */
|
||||
attr_val_service_t service; /**< Attribute Value for Service */
|
||||
attr_val_include_t include; /**< Attribute Value for Include */
|
||||
attr_val_characteristic_t characteristic; /**< Attribute Value for Characteristic */
|
||||
attr_val_characteristic_value_t characteristic_value; /**< Attribute Value for Characteristic Value */
|
||||
attr_val_extended_properties_t extended_properties; /**< Attribute Value for Descriptor: Characteristic Extended Properties */
|
||||
attr_val_user_description_t user_description; /**< Attribute Value for Descriptor: Characteristic User_Description */
|
||||
attr_val_client_config_t client_config; /**< Attribute Value for Descriptor: Client Characteristic Configuration */
|
||||
attr_val_server_config_t server_config; /**< Attribute Value for Descriptor: Server Characteristic Configuration */
|
||||
attr_val_presentation_format_t presentation_format; /**< Attribute Value for Descriptor: Characteristic Presentation Format */
|
||||
attr_val_aggregate_format_t aggregate_format; /**< Attribute Value for Descriptor: Characteristic Aggregate Format */
|
||||
attr_val_device_name_t device_name; /**< Attribute Value for Characteristic Type: Device Name */
|
||||
attr_val_appearance_t appearance; /**< Attribute Value for Characteristic Type: Appearance */
|
||||
attr_val_periph_privacy_flag_t periph_privacy_flag; /**< Attribute Value for Characteristic Type: Peripheral Privacy Flag */
|
||||
attr_val_reconnection_address_t reconn_address; /**< Attribute Value for Characteristic Type: Reconnection Address */
|
||||
attr_val_periph_preferred_conn_params_t periph_preferred_conn_params; /**< Attribute Value for Characteristic Type: Peripheral Preferred Connection Parameters */
|
||||
} value; /**< Union of Attribute Values. Use the right format based on Attribute Type */
|
||||
|
||||
} mico_bt_smart_attribute_t;
|
||||
|
||||
/**
|
||||
* Attribute List Structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t count; /**< Attribute count */
|
||||
mico_bt_smart_attribute_t* list; /**< Pointer to attribute linked-list */
|
||||
} mico_bt_smart_attribute_list_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup btattr Attribute
|
||||
* @ingroup micobt
|
||||
*
|
||||
* Bluetooth Smart Attribute Abstraction
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Create a Bluetooth Smart Attribute structure
|
||||
*
|
||||
* @param[out] attribute : pointer that will receive the attribute structure
|
||||
* @param[in] type : attribute type
|
||||
* @param[in] variable_length : length of the variable part of the attribute.
|
||||
* For some attribute types, this argument is not
|
||||
* used.
|
||||
*
|
||||
* @return MICO_BT_SUCCESS:success,MICO_BT_BADARG:input argument error
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_create( mico_bt_smart_attribute_t** attribute, mico_bt_smart_attribute_type_t type, uint16_t variable_length );
|
||||
|
||||
/** Delete a Bluetooth Smart Attribute structure
|
||||
*
|
||||
* @param[in,out] attribute : attribute structure to delete
|
||||
*
|
||||
* @return MICO_BT_SUCCESS:success,MICO_BT_BADARG:input argument error
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_delete( mico_bt_smart_attribute_t* attribute );
|
||||
|
||||
/** Initialise a list of Bluetooth Smart Attributes
|
||||
*
|
||||
* @param[out] list : list to initialise
|
||||
*
|
||||
* @return MICO_BT_SUCCESS:success,MICO_BT_BADARG:input argument error
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_create_list( mico_bt_smart_attribute_list_t* list );
|
||||
|
||||
/** Deinitialise a list of Bluetooth Smart Attributes
|
||||
*
|
||||
* @param[out] list : list to deinitialise
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_delete_list( mico_bt_smart_attribute_list_t* list );
|
||||
|
||||
/** Add a Bluetooth Smart Attribute to a list
|
||||
*
|
||||
* @param[in,out] list : list to add attribute to
|
||||
* @param[in] attribute : attribute to add to the list
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_add_to_list( mico_bt_smart_attribute_list_t* list, mico_bt_smart_attribute_t* attribute );
|
||||
|
||||
/** Remove a Bluetooth Smart Attribute with the given handle from a list
|
||||
*
|
||||
* @param[in,out] list : list to remote attribute from
|
||||
* @param[in] handle : handle of the attribute to remove
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_remove_from_list( mico_bt_smart_attribute_list_t* list, uint16_t handle );
|
||||
|
||||
/** Find a Bluetooth Smart Attribute with the given handle from a list
|
||||
*
|
||||
* @param[in,out] list : list to find attribute in
|
||||
* @param[in] handle : handle of the attribute to find
|
||||
* @param[out] attribute : pointer that will receive the attribute
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_search_list_by_handle( const mico_bt_smart_attribute_list_t* list, uint16_t handle, mico_bt_smart_attribute_t** attribute );
|
||||
|
||||
/** Find a Bluetooth Smart Attribute with the given handle from a list
|
||||
*
|
||||
* @param[in,out] list : list to find attribute in
|
||||
* @param[in] uuid : UUID of the attribute to find
|
||||
* @param[in] starting_handle : handle to start the search
|
||||
* @param[in] ending_handle : handle to end the search
|
||||
* @param[out] attribute : pointer that will receive the attribute
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_search_list_by_uuid( const mico_bt_smart_attribute_list_t* list, const mico_bt_uuid_t* uuid, uint16_t starting_handle, uint16_t ending_handle, mico_bt_smart_attribute_t** attribute );
|
||||
|
||||
/** Merge two Bluetooth Smart Attribute lists
|
||||
*
|
||||
* @param[in,out] trunk_list : list that will receive all of the attributes from the branch list
|
||||
* @param[in,out] branch_list : list whose attributes will be removed and inserted into the trunk list
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_merge_lists( mico_bt_smart_attribute_list_t* trunk_list, mico_bt_smart_attribute_list_t* branch_list );
|
||||
|
||||
/** Print attribute contents
|
||||
*
|
||||
* @param[in] attribute : attribute to print
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_print( const mico_bt_smart_attribute_t* attribute );
|
||||
|
||||
/** Print the contents of all attributes in a list
|
||||
*
|
||||
* @param[in] list : list whose attributes to print
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_print_list( const mico_bt_smart_attribute_list_t* list );
|
||||
|
||||
/** Get attribute list head
|
||||
*
|
||||
* @param[in] list : attribute list
|
||||
* @param[out] head : pointer that will receive the list head
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_get_list_head( const mico_bt_smart_attribute_list_t* list, mico_bt_smart_attribute_t** head );
|
||||
|
||||
|
||||
/** Get attribute list count
|
||||
*
|
||||
* @param[in] list : attribute list
|
||||
* @param[out] count : variable that will receive the count
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smart_attribute_get_list_count( const mico_bt_smart_attribute_list_t* list, uint32_t* count );
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -1,438 +1,438 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Defines common constants and types for MiCO support for Bluetooth Smart
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico_bt_smartbridge_constants.h"
|
||||
#include "mico_bt_smart_attribute.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/** @cond !ADDTHIS*/
|
||||
/* Limits and Default Value for Scan Interval */
|
||||
#define DEFAULT_SCAN_INTERVAL 0x0010
|
||||
#define MIN_SCAN_INTERVAL 0x0004
|
||||
#define MAX_SCAN_INTERVAL 0x4000
|
||||
|
||||
/* Limits and Default Value for Scan Window */
|
||||
#define DEFAULT_SCAN_WINDOW 0x0010
|
||||
#define MIN_SCAN_WINDOW 0x0004
|
||||
#define MAX_SCAN_WINDOW 0x4000
|
||||
|
||||
#define BONDING_DISABLED 0x00
|
||||
#define BONDING_ENABLED 0x01
|
||||
#define PASSKEY_ENTRY_ENABLED 0x04
|
||||
#define SECURE_CONNECTION_ENABLE 0x08
|
||||
|
||||
#define DISTRIBUTE_ENCRYPTION_KEY 0x01
|
||||
#define DISTRIBUTE_ID_KEY 0x02
|
||||
#define DISTRIBUTE_SIGN_KEY 0x04
|
||||
/** @endcond */
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* Bluetooth Smart filter policy
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FILTER_POLICY_NONE = 0x00, /**< No filter policy */
|
||||
FILTER_POLICY_WHITE_LIST = 0x01, /**< White list filter policy */
|
||||
} mico_bt_smart_filter_policy_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan duplicates filter
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DUPLICATES_FILTER_DISABLED = 0x00, /**< Duplicates filter is disabled */
|
||||
DUPLICATES_FILTER_ENABLED = 0x01, /**< Duplicates filter is enabled */
|
||||
} mico_bt_smart_filter_duplicated_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart address type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_ADDR_TYPE_PUBLIC = 0x00, /**< Public address */
|
||||
BT_SMART_ADDR_TYPE_RANDOM = 0x01 /**< Random address */
|
||||
} mico_bt_smart_address_type_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart link role
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_LINK_ROLE_MASTER = 0x00, /**< Public address */
|
||||
BT_SMART_LINK_ROLE_SLAVE = 0x01 /**< Random address */
|
||||
} mico_bt_smart_link_role_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_PASSIVE_SCAN = 0x00, /**< Passive scan. Controller does not send SCAN_REQ and listens for Advertising from remote devices */
|
||||
BT_SMART_ACTIVE_SCAN = 0x01, /**< Active scan. Controller sends SCAN_REQ. Controller listens for Advertising from remote devices and may receive SCAN_RSP from remote devices */
|
||||
} mico_bt_smart_scan_type_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising event
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_CONNECTABLE_UNDIRECTED_ADVERTISING_EVENT = 0x00, /**< ADV_IND : Connectable undirected advertising event */
|
||||
BT_SMART_CONNECTABLE_DIRECTED_ADVERTISING_EVENT = 0x01, /**< ADV_DIRECT_IND : Connectable directed advertising event */
|
||||
BT_SMART_SCANNABLE_UNDIRECTED_ADVERTISING_EVENT = 0x02, /**< ADV_SCAN_IND : Scannable undirected advertising event */
|
||||
BT_SMART_NON_CONNECTABLE_UNDIRECTED_ADVERTISING_EVENT = 0x03, /**< ADV_NONCONN_IND : Non-connectable undirected advertising event */
|
||||
BT_SMART_SCAN_RESPONSE_EVENT = 0x04, /**< SCAN_RSP : Scan response event */
|
||||
} mico_bt_smart_advertising_event_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising event
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_UNDIRECTED_ADVERTISING = 0x00, /**< General undirected advertising */
|
||||
BT_SMART_DISCOVERABLE_ADVERTISING = 0x01, /**< Discoverable advertising */
|
||||
BT_SMART_DIRECTED_ADVERTISING = 0x02, /**< Directed advertising */
|
||||
BT_SMART_NON_CONNECTABLE_UNDIRECTED_ADVERTISING = 0x03, /**< Non-connectable undirected advertising */
|
||||
} mico_bt_smart_advertising_type_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device input/output (IO) capabilities
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_IO_DISPLAY_ONLY = 0x00,
|
||||
BT_SMART_IO_DISPLAY_YES_NO_BUTTONS = 0x01,
|
||||
BT_SMART_IO_KEYBOARD_ONLY = 0x02,
|
||||
BT_SMART_IO_NO_INPUT_NO_OUTPUT = 0x03,
|
||||
BT_SMART_IO_KEYBOARD_DISPLAY = 0x04,
|
||||
} mico_bt_io_capabilities_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device Authentication Requirements (AuthReq)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_AUTH_REQ_NONE = 0,
|
||||
BT_SMART_AUTH_REQ_BONDING = ( BONDING_ENABLED ),
|
||||
BT_SMART_AUTH_REQ_PASSKEY_ENTRY = ( PASSKEY_ENTRY_ENABLED ),
|
||||
BT_SMART_AUTH_REQ_BONDING_AND_PASSKEY_ENTRY = ( BONDING_ENABLED | PASSKEY_ENTRY_ENABLED ),
|
||||
} mico_bt_smart_auth_req_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device bonding request type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* Bonding event -- user should reply it with #mico_bt_smart_bond_reply() */
|
||||
MICO_BT_SMART_BOND_PASS_KEY_REQ = 0x01,
|
||||
/* Bonding event -- user should reply it with #mico_bt_smart_bond_reply() */
|
||||
MICO_BT_SMART_BOND_USR_CONFIRM_REQ = 0x02,
|
||||
/* Bonding event -- user should reply it with #mico_bt_smart_bond_reply() */
|
||||
MICO_BT_SMART_BOND_OOB_DATA_REQ = 0x03,
|
||||
/* Bonding event -- user should not reply it */
|
||||
MICO_BT_SMART_BOND_PASS_KEY_NOTIFY = 0x04,
|
||||
} mico_bt_smart_bond_request_type_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device key distribution types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_DISTRIBUTE_NONE = 0,
|
||||
BT_SMART_DISTRIBUTE_ENCRYPTION_KEY = ( DISTRIBUTE_ENCRYPTION_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ID_KEY = ( DISTRIBUTE_ID_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ENCRYPTION_AND_ID_KEYS = ( DISTRIBUTE_ID_KEY | DISTRIBUTE_ENCRYPTION_KEY ),
|
||||
BT_SMART_DISTRIBUTE_SIGN_KEY = ( DISTRIBUTE_SIGN_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ENCRYPTION_AND_SIGN_KEYS = ( DISTRIBUTE_SIGN_KEY | DISTRIBUTE_ENCRYPTION_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ID_AND_SIGN_KEYS = ( DISTRIBUTE_SIGN_KEY | DISTRIBUTE_ID_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ALL_KEYS = ( DISTRIBUTE_SIGN_KEY | DISTRIBUTE_ID_KEY | DISTRIBUTE_ENCRYPTION_KEY ),
|
||||
} mico_bt_smart_key_distribution_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Out-of-Band (OOB) authentication data
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_OOB_AUTH_NONE, /**< OOB authentication data is not available */
|
||||
BT_SMART_OOB_AUTH_AVAILABLE, /**< OOB authentication data is available */
|
||||
} mico_bt_smart_oob_auth_t;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_device_address_t address; /**< Bluetooth device address */
|
||||
mico_bt_smart_address_type_t address_type; /**< Address Type */
|
||||
char name[31]; /**< User-friendly name */
|
||||
} mico_bt_smart_device_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan settings
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_smart_scan_type_t type; /**< Scan type */
|
||||
mico_bt_smart_filter_policy_t filter_policy; /**< Scan filter policy */
|
||||
mico_bt_smart_filter_duplicated_t filter_duplicates; /**< Scan duplicates filter */
|
||||
uint16_t interval; /**< Interval between scans. Unit: 0.625ms. Range: 0x0004 - 0x4000 (2.5ms - 10.24s) */
|
||||
uint16_t window; /**< Scan window. Must be <= scan interval. Unit: 0.625ms. Range: 0x0004 - 0x4000 (2.5ms - 10.24s) */
|
||||
uint16_t duration_second; /**< Scan duration in seconds */
|
||||
} mico_bt_smart_scan_settings_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising report
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_smart_device_t remote_device; /**< Remote device */
|
||||
int8_t signal_strength; /**< RSSI in dBm */
|
||||
mico_bt_smart_advertising_event_t event; /**< Advertising event received */
|
||||
uint8_t eir_data_length; /**< Length of EIR data received with advertising event */
|
||||
uint8_t eir_data[31]; /**< EIR data of advertising event */
|
||||
} mico_bt_smart_advertising_report_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan result
|
||||
*/
|
||||
typedef struct mico_bt_smart_scan_result
|
||||
{
|
||||
mico_bt_smart_device_t remote_device; /**< Remote device */
|
||||
int8_t signal_strength; /**< RSSI in dBm */
|
||||
mico_bt_smart_advertising_report_t last_scan_response_received; /**< Last scan response event received */
|
||||
mico_bt_smart_advertising_report_t last_advertising_event_received; /**< Last advertising event received */
|
||||
struct mico_bt_smart_scan_result* next; /**< Pointer to the next scan result */
|
||||
|
||||
/* Additional flag to help application filter scan results */
|
||||
mico_bool_t filter_display; /**< Set to MICO_TRUE if filter display */
|
||||
|
||||
} mico_bt_smart_scan_result_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertise settings
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_smart_advertising_type_t type; /**< Advertising type */
|
||||
mico_bool_t use_high_duty; /**< Start advertising use high duty cycle interval */
|
||||
uint16_t high_duty_interval; /**< High duty advertising interval */
|
||||
uint16_t high_duty_duration; /**< High duty advertising duration in seconds (0 for infinite) */
|
||||
uint16_t low_duty_interval; /**< Low duty advertising interval */
|
||||
uint16_t low_duty_duration; /**< Low duty advertising duration in seconds (0 for infinite) */
|
||||
mico_bt_smart_address_type_t directed_advertisement_addr_type; /**< Target device address type for directed advertising */
|
||||
mico_bt_device_address_t directed_advertisement_addr; /**< Target device address for directed advertising */
|
||||
} mico_bt_smart_advertising_settings_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart connection settings
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t timeout_second; /**< Connection timeout in seconds */
|
||||
mico_bt_smart_filter_policy_t filter_policy; /**< Connection initiator filter policy: No filter or using white list */
|
||||
uint16_t interval_min; /**< Connection Interval Min. Unit: 1.25ms. Range: 0x000A - 0x0C80 (7.5ms - 4s) */
|
||||
uint16_t interval_max; /**< Connection Interval Max. Unit: 1.25ms. Range: 0x000A - 0x0C80 (7.5ms - 4s) */
|
||||
uint16_t latency; /**< Connection Latency. Unit: Connection Events. Range: 0x0000 - 0x01F4 */
|
||||
uint16_t supervision_timeout; /**< Supervision Timeout. Unit: 10ms. Range: 0x000A - 0x0C80 (100ms - 32s)*/
|
||||
uint16_t ce_length_min; /**< Connection Event Length Min. Unit: Connection Events. Range: 0x0000 - 0xFFFF */
|
||||
uint16_t ce_length_max; /**< Connection Event Length Max. Unit: Connection Events. Range: 0x0000 - 0xFFFF */
|
||||
uint32_t attribute_protocol_timeout_ms; /**< Attribute protocol timeout in milliseconds */
|
||||
} mico_bt_smart_connection_settings_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Extended Inquiry Response (EIR) data structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t length; /**< Length */
|
||||
uint8_t type; /**< Type */
|
||||
uint8_t data[1]; /**< Start of data */
|
||||
} mico_bt_smart_eir_data_structure_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart security settings
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t timeout_second; /**< Timeout in second. Default is 30 seconds */
|
||||
mico_bt_io_capabilities_t io_capabilities; /**< Device I/O capability */
|
||||
mico_bt_smart_auth_req_t authentication_requirements; /**< Authentication requirements */
|
||||
mico_bt_smart_oob_auth_t oob_authentication; /**< OOB authentication data */
|
||||
uint8_t max_encryption_key_size; /**< Encryption key size (7 to 16 bytes) */
|
||||
mico_bt_smart_key_distribution_t master_key_distribution; /**< Bit mask of master/initiator key distribution */
|
||||
mico_bt_smart_key_distribution_t slave_key_distribution; /**< Bit mask of slave/responder key distribution */
|
||||
} mico_bt_smart_security_settings_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Peer Device Bond Info
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_device_address_t peer_address; /**< Bonded peer device address */
|
||||
mico_bt_smart_address_type_t address_type; /**< Peer device's address type */
|
||||
uint8_t irk [16]; /**< Peer device's Identity Resolving Key (IRK). Used for random address generation and resolution */
|
||||
uint8_t csrk[16]; /**< Peer device's Connection Signature Resolving Key (CSRK). Used for signing data and verifying messages */
|
||||
uint8_t ltk [16]; /**< Peer device's Long Term Key (LTK). Used for encryption */
|
||||
uint8_t rand[8]; /**< Peer device's Random Number (Rand). Used for identifying LTK */
|
||||
uint16_t ediv; /**< Peer device's Encrypted Diversifier (EDIV). Used for identifying LTK */
|
||||
} mico_bt_smart_bond_info_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Device Bond Request Event Parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* Type of the request */
|
||||
mico_bt_smart_bond_request_type_t type;
|
||||
|
||||
union
|
||||
{
|
||||
/* MICO_BT_SMART_BOND_PASS_KEY_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
} passkey;
|
||||
|
||||
/* MICO_BT_SMART_BOND_USR_CONFIRM_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
/* An up to six-digit number (from 0 to 999999) to display or
|
||||
* request remote entry
|
||||
*/
|
||||
uint32_t passkey;
|
||||
} confirm;
|
||||
|
||||
/* MICO_BT_SMART_BOND_OOB_DATA_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
} oob_data;
|
||||
|
||||
/* MICO_BT_SMART_BOND_PASS_KEY_NOTIFY */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
uint32_t passkey;
|
||||
} notify;
|
||||
} u;
|
||||
} mico_bt_smart_bond_request_t;
|
||||
|
||||
/*
|
||||
* Bluetooth Smart Device Bond Replay information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* Type of the request */
|
||||
mico_bt_smart_bond_request_type_t type;
|
||||
|
||||
/* reply status */
|
||||
mico_bt_result_t res;
|
||||
|
||||
/* reply data -- only valid when 'res' is MICO_BT_SUCCESS */
|
||||
union
|
||||
{
|
||||
/* Used for MICO_BT_SMART_BOND_USER_CONFIRM */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
} confirm;
|
||||
|
||||
/* Used for MICO_BT_SMART_BOND_PASS_KEY_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
uint32_t passkey;
|
||||
} passkey;
|
||||
|
||||
/* Used for MICO_BT_SMART_BOND_OOB_DATA_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
uint8_t *data;
|
||||
uint8_t len;
|
||||
} oob_data;
|
||||
} u;
|
||||
} mico_bt_smart_bond_reply_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan complete callback
|
||||
*/
|
||||
typedef event_handler_t mico_bt_smart_scan_complete_callback_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising report callback
|
||||
*/
|
||||
typedef OSStatus (*mico_bt_smart_advertising_report_callback_t) ( const mico_bt_smart_advertising_report_t* result );
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Device Bond Callback.
|
||||
*/
|
||||
typedef OSStatus (*mico_bt_smart_bonding_callback_t)(const mico_bt_smart_bond_request_t *request);
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising complete callback
|
||||
*/
|
||||
typedef event_handler_t mico_bt_smart_advertising_complete_callback_t;
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/** mico_bt_smart_bond_reply
|
||||
*
|
||||
* This function is called to reply BLE Bond Event posted by #mico_bt_smart_bonding_callback_t.
|
||||
* You should fill a strcutre #mico_bt_smart_bond_reply_t to complete this bonding procedure.
|
||||
*
|
||||
* @param[in] response the response to current bonding event.
|
||||
*
|
||||
* @return OSStatus
|
||||
*/
|
||||
extern OSStatus mico_bt_smart_bond_reply(const mico_bt_smart_bond_reply_t *response);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Defines common constants and types for MiCO support for Bluetooth Smart
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico_bt_smartbridge_constants.h"
|
||||
#include "mico_bt_smart_attribute.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/** @cond !ADDTHIS*/
|
||||
/* Limits and Default Value for Scan Interval */
|
||||
#define DEFAULT_SCAN_INTERVAL 0x0010
|
||||
#define MIN_SCAN_INTERVAL 0x0004
|
||||
#define MAX_SCAN_INTERVAL 0x4000
|
||||
|
||||
/* Limits and Default Value for Scan Window */
|
||||
#define DEFAULT_SCAN_WINDOW 0x0010
|
||||
#define MIN_SCAN_WINDOW 0x0004
|
||||
#define MAX_SCAN_WINDOW 0x4000
|
||||
|
||||
#define BONDING_DISABLED 0x00
|
||||
#define BONDING_ENABLED 0x01
|
||||
#define PASSKEY_ENTRY_ENABLED 0x04
|
||||
#define SECURE_CONNECTION_ENABLE 0x08
|
||||
|
||||
#define DISTRIBUTE_ENCRYPTION_KEY 0x01
|
||||
#define DISTRIBUTE_ID_KEY 0x02
|
||||
#define DISTRIBUTE_SIGN_KEY 0x04
|
||||
/** @endcond */
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* Bluetooth Smart filter policy
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FILTER_POLICY_NONE = 0x00, /**< No filter policy */
|
||||
FILTER_POLICY_WHITE_LIST = 0x01, /**< White list filter policy */
|
||||
} mico_bt_smart_filter_policy_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan duplicates filter
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DUPLICATES_FILTER_DISABLED = 0x00, /**< Duplicates filter is disabled */
|
||||
DUPLICATES_FILTER_ENABLED = 0x01, /**< Duplicates filter is enabled */
|
||||
} mico_bt_smart_filter_duplicated_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart address type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_ADDR_TYPE_PUBLIC = 0x00, /**< Public address */
|
||||
BT_SMART_ADDR_TYPE_RANDOM = 0x01 /**< Random address */
|
||||
} mico_bt_smart_address_type_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart link role
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_LINK_ROLE_MASTER = 0x00, /**< Public address */
|
||||
BT_SMART_LINK_ROLE_SLAVE = 0x01 /**< Random address */
|
||||
} mico_bt_smart_link_role_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_PASSIVE_SCAN = 0x00, /**< Passive scan. Controller does not send SCAN_REQ and listens for Advertising from remote devices */
|
||||
BT_SMART_ACTIVE_SCAN = 0x01, /**< Active scan. Controller sends SCAN_REQ. Controller listens for Advertising from remote devices and may receive SCAN_RSP from remote devices */
|
||||
} mico_bt_smart_scan_type_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising event
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_CONNECTABLE_UNDIRECTED_ADVERTISING_EVENT = 0x00, /**< ADV_IND : Connectable undirected advertising event */
|
||||
BT_SMART_CONNECTABLE_DIRECTED_ADVERTISING_EVENT = 0x01, /**< ADV_DIRECT_IND : Connectable directed advertising event */
|
||||
BT_SMART_SCANNABLE_UNDIRECTED_ADVERTISING_EVENT = 0x02, /**< ADV_SCAN_IND : Scannable undirected advertising event */
|
||||
BT_SMART_NON_CONNECTABLE_UNDIRECTED_ADVERTISING_EVENT = 0x03, /**< ADV_NONCONN_IND : Non-connectable undirected advertising event */
|
||||
BT_SMART_SCAN_RESPONSE_EVENT = 0x04, /**< SCAN_RSP : Scan response event */
|
||||
} mico_bt_smart_advertising_event_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising event
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_UNDIRECTED_ADVERTISING = 0x00, /**< General undirected advertising */
|
||||
BT_SMART_DISCOVERABLE_ADVERTISING = 0x01, /**< Discoverable advertising */
|
||||
BT_SMART_DIRECTED_ADVERTISING = 0x02, /**< Directed advertising */
|
||||
BT_SMART_NON_CONNECTABLE_UNDIRECTED_ADVERTISING = 0x03, /**< Non-connectable undirected advertising */
|
||||
} mico_bt_smart_advertising_type_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device input/output (IO) capabilities
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_IO_DISPLAY_ONLY = 0x00,
|
||||
BT_SMART_IO_DISPLAY_YES_NO_BUTTONS = 0x01,
|
||||
BT_SMART_IO_KEYBOARD_ONLY = 0x02,
|
||||
BT_SMART_IO_NO_INPUT_NO_OUTPUT = 0x03,
|
||||
BT_SMART_IO_KEYBOARD_DISPLAY = 0x04,
|
||||
} mico_bt_io_capabilities_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device Authentication Requirements (AuthReq)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_AUTH_REQ_NONE = 0,
|
||||
BT_SMART_AUTH_REQ_BONDING = ( BONDING_ENABLED ),
|
||||
BT_SMART_AUTH_REQ_PASSKEY_ENTRY = ( PASSKEY_ENTRY_ENABLED ),
|
||||
BT_SMART_AUTH_REQ_BONDING_AND_PASSKEY_ENTRY = ( BONDING_ENABLED | PASSKEY_ENTRY_ENABLED ),
|
||||
} mico_bt_smart_auth_req_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device bonding request type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* Bonding event -- user should reply it with #mico_bt_smart_bond_reply() */
|
||||
MICO_BT_SMART_BOND_PASS_KEY_REQ = 0x01,
|
||||
/* Bonding event -- user should reply it with #mico_bt_smart_bond_reply() */
|
||||
MICO_BT_SMART_BOND_USR_CONFIRM_REQ = 0x02,
|
||||
/* Bonding event -- user should reply it with #mico_bt_smart_bond_reply() */
|
||||
MICO_BT_SMART_BOND_OOB_DATA_REQ = 0x03,
|
||||
/* Bonding event -- user should not reply it */
|
||||
MICO_BT_SMART_BOND_PASS_KEY_NOTIFY = 0x04,
|
||||
} mico_bt_smart_bond_request_type_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device key distribution types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_DISTRIBUTE_NONE = 0,
|
||||
BT_SMART_DISTRIBUTE_ENCRYPTION_KEY = ( DISTRIBUTE_ENCRYPTION_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ID_KEY = ( DISTRIBUTE_ID_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ENCRYPTION_AND_ID_KEYS = ( DISTRIBUTE_ID_KEY | DISTRIBUTE_ENCRYPTION_KEY ),
|
||||
BT_SMART_DISTRIBUTE_SIGN_KEY = ( DISTRIBUTE_SIGN_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ENCRYPTION_AND_SIGN_KEYS = ( DISTRIBUTE_SIGN_KEY | DISTRIBUTE_ENCRYPTION_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ID_AND_SIGN_KEYS = ( DISTRIBUTE_SIGN_KEY | DISTRIBUTE_ID_KEY ),
|
||||
BT_SMART_DISTRIBUTE_ALL_KEYS = ( DISTRIBUTE_SIGN_KEY | DISTRIBUTE_ID_KEY | DISTRIBUTE_ENCRYPTION_KEY ),
|
||||
} mico_bt_smart_key_distribution_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Out-of-Band (OOB) authentication data
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BT_SMART_OOB_AUTH_NONE, /**< OOB authentication data is not available */
|
||||
BT_SMART_OOB_AUTH_AVAILABLE, /**< OOB authentication data is available */
|
||||
} mico_bt_smart_oob_auth_t;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/**
|
||||
* Bluetooth Smart device
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_device_address_t address; /**< Bluetooth device address */
|
||||
mico_bt_smart_address_type_t address_type; /**< Address Type */
|
||||
char name[31]; /**< User-friendly name */
|
||||
} mico_bt_smart_device_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan settings
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_smart_scan_type_t type; /**< Scan type */
|
||||
mico_bt_smart_filter_policy_t filter_policy; /**< Scan filter policy */
|
||||
mico_bt_smart_filter_duplicated_t filter_duplicates; /**< Scan duplicates filter */
|
||||
uint16_t interval; /**< Interval between scans. Unit: 0.625ms. Range: 0x0004 - 0x4000 (2.5ms - 10.24s) */
|
||||
uint16_t window; /**< Scan window. Must be <= scan interval. Unit: 0.625ms. Range: 0x0004 - 0x4000 (2.5ms - 10.24s) */
|
||||
uint16_t duration_second; /**< Scan duration in seconds */
|
||||
} mico_bt_smart_scan_settings_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising report
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_smart_device_t remote_device; /**< Remote device */
|
||||
int8_t signal_strength; /**< RSSI in dBm */
|
||||
mico_bt_smart_advertising_event_t event; /**< Advertising event received */
|
||||
uint8_t eir_data_length; /**< Length of EIR data received with advertising event */
|
||||
uint8_t eir_data[31]; /**< EIR data of advertising event */
|
||||
} mico_bt_smart_advertising_report_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan result
|
||||
*/
|
||||
typedef struct mico_bt_smart_scan_result
|
||||
{
|
||||
mico_bt_smart_device_t remote_device; /**< Remote device */
|
||||
int8_t signal_strength; /**< RSSI in dBm */
|
||||
mico_bt_smart_advertising_report_t last_scan_response_received; /**< Last scan response event received */
|
||||
mico_bt_smart_advertising_report_t last_advertising_event_received; /**< Last advertising event received */
|
||||
struct mico_bt_smart_scan_result* next; /**< Pointer to the next scan result */
|
||||
|
||||
/* Additional flag to help application filter scan results */
|
||||
mico_bool_t filter_display; /**< Set to MICO_TRUE if filter display */
|
||||
|
||||
} mico_bt_smart_scan_result_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertise settings
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_smart_advertising_type_t type; /**< Advertising type */
|
||||
mico_bool_t use_high_duty; /**< Start advertising use high duty cycle interval */
|
||||
uint16_t high_duty_interval; /**< High duty advertising interval */
|
||||
uint16_t high_duty_duration; /**< High duty advertising duration in seconds (0 for infinite) */
|
||||
uint16_t low_duty_interval; /**< Low duty advertising interval */
|
||||
uint16_t low_duty_duration; /**< Low duty advertising duration in seconds (0 for infinite) */
|
||||
mico_bt_smart_address_type_t directed_advertisement_addr_type; /**< Target device address type for directed advertising */
|
||||
mico_bt_device_address_t directed_advertisement_addr; /**< Target device address for directed advertising */
|
||||
} mico_bt_smart_advertising_settings_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart connection settings
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t timeout_second; /**< Connection timeout in seconds */
|
||||
mico_bt_smart_filter_policy_t filter_policy; /**< Connection initiator filter policy: No filter or using white list */
|
||||
uint16_t interval_min; /**< Connection Interval Min. Unit: 1.25ms. Range: 0x000A - 0x0C80 (7.5ms - 4s) */
|
||||
uint16_t interval_max; /**< Connection Interval Max. Unit: 1.25ms. Range: 0x000A - 0x0C80 (7.5ms - 4s) */
|
||||
uint16_t latency; /**< Connection Latency. Unit: Connection Events. Range: 0x0000 - 0x01F4 */
|
||||
uint16_t supervision_timeout; /**< Supervision Timeout. Unit: 10ms. Range: 0x000A - 0x0C80 (100ms - 32s)*/
|
||||
uint16_t ce_length_min; /**< Connection Event Length Min. Unit: Connection Events. Range: 0x0000 - 0xFFFF */
|
||||
uint16_t ce_length_max; /**< Connection Event Length Max. Unit: Connection Events. Range: 0x0000 - 0xFFFF */
|
||||
uint32_t attribute_protocol_timeout_ms; /**< Attribute protocol timeout in milliseconds */
|
||||
} mico_bt_smart_connection_settings_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Extended Inquiry Response (EIR) data structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t length; /**< Length */
|
||||
uint8_t type; /**< Type */
|
||||
uint8_t data[1]; /**< Start of data */
|
||||
} mico_bt_smart_eir_data_structure_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart security settings
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t timeout_second; /**< Timeout in second. Default is 30 seconds */
|
||||
mico_bt_io_capabilities_t io_capabilities; /**< Device I/O capability */
|
||||
mico_bt_smart_auth_req_t authentication_requirements; /**< Authentication requirements */
|
||||
mico_bt_smart_oob_auth_t oob_authentication; /**< OOB authentication data */
|
||||
uint8_t max_encryption_key_size; /**< Encryption key size (7 to 16 bytes) */
|
||||
mico_bt_smart_key_distribution_t master_key_distribution; /**< Bit mask of master/initiator key distribution */
|
||||
mico_bt_smart_key_distribution_t slave_key_distribution; /**< Bit mask of slave/responder key distribution */
|
||||
} mico_bt_smart_security_settings_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Peer Device Bond Info
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
mico_bt_device_address_t peer_address; /**< Bonded peer device address */
|
||||
mico_bt_smart_address_type_t address_type; /**< Peer device's address type */
|
||||
uint8_t irk [16]; /**< Peer device's Identity Resolving Key (IRK). Used for random address generation and resolution */
|
||||
uint8_t csrk[16]; /**< Peer device's Connection Signature Resolving Key (CSRK). Used for signing data and verifying messages */
|
||||
uint8_t ltk [16]; /**< Peer device's Long Term Key (LTK). Used for encryption */
|
||||
uint8_t rand[8]; /**< Peer device's Random Number (Rand). Used for identifying LTK */
|
||||
uint16_t ediv; /**< Peer device's Encrypted Diversifier (EDIV). Used for identifying LTK */
|
||||
} mico_bt_smart_bond_info_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Device Bond Request Event Parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* Type of the request */
|
||||
mico_bt_smart_bond_request_type_t type;
|
||||
|
||||
union
|
||||
{
|
||||
/* MICO_BT_SMART_BOND_PASS_KEY_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
} passkey;
|
||||
|
||||
/* MICO_BT_SMART_BOND_USR_CONFIRM_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
/* An up to six-digit number (from 0 to 999999) to display or
|
||||
* request remote entry
|
||||
*/
|
||||
uint32_t passkey;
|
||||
} confirm;
|
||||
|
||||
/* MICO_BT_SMART_BOND_OOB_DATA_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
} oob_data;
|
||||
|
||||
/* MICO_BT_SMART_BOND_PASS_KEY_NOTIFY */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
uint32_t passkey;
|
||||
} notify;
|
||||
} u;
|
||||
} mico_bt_smart_bond_request_t;
|
||||
|
||||
/*
|
||||
* Bluetooth Smart Device Bond Replay information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* Type of the request */
|
||||
mico_bt_smart_bond_request_type_t type;
|
||||
|
||||
/* reply status */
|
||||
mico_bt_result_t res;
|
||||
|
||||
/* reply data -- only valid when 'res' is MICO_BT_SUCCESS */
|
||||
union
|
||||
{
|
||||
/* Used for MICO_BT_SMART_BOND_USER_CONFIRM */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
} confirm;
|
||||
|
||||
/* Used for MICO_BT_SMART_BOND_PASS_KEY_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
uint32_t passkey;
|
||||
} passkey;
|
||||
|
||||
/* Used for MICO_BT_SMART_BOND_OOB_DATA_REQ */
|
||||
struct
|
||||
{
|
||||
mico_bt_device_address_t addr;
|
||||
uint8_t *data;
|
||||
uint8_t len;
|
||||
} oob_data;
|
||||
} u;
|
||||
} mico_bt_smart_bond_reply_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* Bluetooth Smart scan complete callback
|
||||
*/
|
||||
typedef event_handler_t mico_bt_smart_scan_complete_callback_t;
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising report callback
|
||||
*/
|
||||
typedef OSStatus (*mico_bt_smart_advertising_report_callback_t) ( const mico_bt_smart_advertising_report_t* result );
|
||||
|
||||
/**
|
||||
* Bluetooth Smart Device Bond Callback.
|
||||
*/
|
||||
typedef OSStatus (*mico_bt_smart_bonding_callback_t)(const mico_bt_smart_bond_request_t *request);
|
||||
|
||||
/**
|
||||
* Bluetooth Smart advertising complete callback
|
||||
*/
|
||||
typedef event_handler_t mico_bt_smart_advertising_complete_callback_t;
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/** mico_bt_smart_bond_reply
|
||||
*
|
||||
* This function is called to reply BLE Bond Event posted by #mico_bt_smart_bonding_callback_t.
|
||||
* You should fill a strcutre #mico_bt_smart_bond_reply_t to complete this bonding procedure.
|
||||
*
|
||||
* @param[in] response the response to current bonding event.
|
||||
*
|
||||
* @return OSStatus
|
||||
*/
|
||||
extern OSStatus mico_bt_smart_bond_reply(const mico_bt_smart_bond_reply_t *response);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,97 +1,97 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Defines common constants and types for the MICO Bluetooth Framework
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico_bt_constants.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/** @cond !ADDTHIS*/
|
||||
#define MICO_BT_ADDRESS_BYTE_SIZE 6
|
||||
/** @endcond */
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* UUID size
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
UUID_16BIT = 0x02, /**< 16-bit */
|
||||
UUID_32BIT = 0x04, /**< 32-bit */
|
||||
UUID_128BIT = 0x10 /**< 128-bit */
|
||||
} mico_bt_uuid_size_t;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Bluetooth Device Address (BD_ADDR)
|
||||
* A 48-bit address that uniquely identifies a Bluetooth device
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t address[MICO_BT_ADDRESS_BYTE_SIZE]; /**< Address. 48-bit Bluetooth device address in a little-endian format */
|
||||
} mico_bt_device_address_t;
|
||||
|
||||
|
||||
/**
|
||||
* Universally Unique Identifier (UUID)
|
||||
* A standardised format of string ID that uniquely identifies a Bluetooth service
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
uint16_t value_16_bit; /**< 16-bit UUID value. */
|
||||
uint16_t value_128_bit[UUID_128BIT/2]; /**< 128-bit UUID value. */
|
||||
} value; /**< A union of UUID values */
|
||||
|
||||
mico_bt_uuid_size_t size; /**< UUID size */
|
||||
|
||||
} mico_bt_uuid_t;
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Defines common constants and types for the MICO Bluetooth Framework
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico_bt_constants.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/** @cond !ADDTHIS*/
|
||||
#define MICO_BT_ADDRESS_BYTE_SIZE 6
|
||||
/** @endcond */
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* UUID size
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
UUID_16BIT = 0x02, /**< 16-bit */
|
||||
UUID_32BIT = 0x04, /**< 32-bit */
|
||||
UUID_128BIT = 0x10 /**< 128-bit */
|
||||
} mico_bt_uuid_size_t;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Bluetooth Device Address (BD_ADDR)
|
||||
* A 48-bit address that uniquely identifies a Bluetooth device
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t address[MICO_BT_ADDRESS_BYTE_SIZE]; /**< Address. 48-bit Bluetooth device address in a little-endian format */
|
||||
} mico_bt_device_address_t;
|
||||
|
||||
|
||||
/**
|
||||
* Universally Unique Identifier (UUID)
|
||||
* A standardised format of string ID that uniquely identifies a Bluetooth service
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
uint16_t value_16_bit; /**< 16-bit UUID value. */
|
||||
uint16_t value_128_bit[UUID_128BIT/2]; /**< 128-bit UUID value. */
|
||||
} value; /**< A union of UUID values */
|
||||
|
||||
mico_bt_uuid_size_t size; /**< UUID size */
|
||||
|
||||
} mico_bt_uuid_t;
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -1,264 +1,264 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @file
|
||||
* Defines SmartBridge Generic Attribute Profile (GATT) Functions
|
||||
*/
|
||||
|
||||
#include "mico_bt_smartbridge.h"
|
||||
#include "mico_bt_smart_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbgatt SmartBridge GATT Procedures
|
||||
* @ingroup smartbridge
|
||||
*
|
||||
* SmartBridge Raw GATT Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/** Discover All Primary Services
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Primary Services from
|
||||
* @param[out] service_list : pointer that will receive the list of Primary Services
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_all_primary_services( const mico_bt_smartbridge_socket_t* socket, mico_bt_smart_attribute_list_t* service_list );
|
||||
|
||||
|
||||
/** Discover Primary Services by the given UUID
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Primary Services from
|
||||
* @param[in] uuid : unique identifier of the Primary Services to discover
|
||||
* @param[out] service_list : pointer that will receive the list of Primary Services
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_primary_services_by_uuid( const mico_bt_smartbridge_socket_t* socket, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_list_t* service_list );
|
||||
|
||||
|
||||
/** Find Included Services
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Included Services from
|
||||
* @param[in] start_handle : starting Attribute handle of the Primary Service to
|
||||
* find the Included Services from
|
||||
* @param[in] end_handle : ending Attribute handle of the Primary Service to
|
||||
* find the Included Services from
|
||||
* @param[out] include_list : pointer that will receive the list of Included Services
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_find_included_services( const mico_bt_smartbridge_socket_t* socket, uint16_t start_handle, uint16_t end_handle, mico_bt_smart_attribute_list_t* include_list );
|
||||
|
||||
|
||||
/** Discover All Characterisitics in a Service
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Characteristics from
|
||||
* @param[in] start_handle : starting Attribute handle of the Primary Service to
|
||||
* discover Characteristics from
|
||||
* @param[in] end_handle : ending Attribute handle of the Primary Service to
|
||||
* discover Characteristics from
|
||||
* @param[out] characteristic_list : pointer that will receive the list of Characteristics
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_all_characteristics_in_a_service( const mico_bt_smartbridge_socket_t* socket, uint16_t start_handle, uint16_t end_handle, mico_bt_smart_attribute_list_t* characteristic_list );
|
||||
|
||||
|
||||
/** Discover Characterisitics by the given UUID
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Characteristics from
|
||||
* @param[in] uuid : unique identifier of the Characteristics to discover
|
||||
* @param[in] start_handle : starting Attribute handle of the Primary Service to
|
||||
* discover Characteristics from
|
||||
* @param[in] end_handle : ending Attribute handle of the Primary Service to
|
||||
* discover Characteristics from
|
||||
* @param[out] characteristic_list : pointer that will receive the list of Characteristics
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_characteristic_by_uuid( const mico_bt_smartbridge_socket_t* socket, const mico_bt_uuid_t* uuid, uint16_t start_handle, uint16_t end_handle, mico_bt_smart_attribute_list_t* characteristic_list );
|
||||
|
||||
|
||||
/** Discover Attribute Handle and Type of all Characteristic Descriptors
|
||||
*
|
||||
* @note
|
||||
* Additional information of the Descriptors can be read using @ref mico_bt_smartbridge_gatt_read_characteristic_descriptor()
|
||||
* and @ref mico_bt_smartbridge_gatt_read_long_characteristic_descriptor()
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Characteristic Descriptors from
|
||||
* @param[in] start_handle : starting Attribute handle of the Characteristic to
|
||||
* discover Characteristic Descriptors from
|
||||
* @param[in] end_handle : ending Attribute handle of the Characteristic to
|
||||
* discover Characteristic Descriptors from
|
||||
* @param[out] descriptor_list : pointer that will receive the list of Descriptors
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_handle_and_type_of_all_characteristic_descriptors( const mico_bt_smartbridge_socket_t* socket, uint16_t start_handle, uint16_t end_handle, mico_bt_smart_attribute_list_t* descriptor_list );
|
||||
|
||||
|
||||
/** Read Characteristic Descriptor
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Descriptor from
|
||||
* @param[in] handle : Attribute handle of the Characteristic Descriptor to read
|
||||
* @param[in] uuid : unique identifier of the Characteristic Descriptor to read
|
||||
* @param[out] descriptor : pointer that will receive the Descriptors
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_characteristic_descriptor( const mico_bt_smartbridge_socket_t* socket, uint16_t handle, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_t** descriptor );
|
||||
|
||||
|
||||
/** Read Long Characteristic Descriptor
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Descriptor from
|
||||
* @param[in] handle : Attribute handle of the Characteristic Descriptor to read
|
||||
* @param[in] uuid : unique identifier of the Characteristic Descriptor to read
|
||||
* @param[out] descriptor : pointer that will receive the Descriptors
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_long_characteristic_descriptor( const mico_bt_smartbridge_socket_t* socket, uint16_t handle, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_t** descriptor );
|
||||
|
||||
|
||||
/** Write Characteristic Descriptor
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to write
|
||||
* Characteristic Descriptor to
|
||||
* @param[in] descriptor : Characteristic Descriptor to write
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_write_characteristic_descriptor( const mico_bt_smartbridge_socket_t* socket, const mico_bt_smart_attribute_t* descriptor );
|
||||
|
||||
|
||||
/** Write Long Characteristic Descriptor
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to write
|
||||
* Characteristic Descriptor to
|
||||
* @param[in] descriptor : Characteristic Descriptor to write
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_write_long_characteristic_descriptor( const mico_bt_smartbridge_socket_t* socket, const mico_bt_smart_attribute_t* descriptor );
|
||||
|
||||
|
||||
/** Read Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Value from
|
||||
* @param[in] handle : Attribute handle of the Characteristic Value to read
|
||||
* @param[in] uuid : unique identifier of the Characteristic Value to read
|
||||
* @param[out] characteristic_value : pointer that will receive the Characteristic Value
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_characteristic_value( const mico_bt_smartbridge_socket_t* socket, uint16_t handle, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_t** characteristic_value );
|
||||
|
||||
|
||||
/** Read Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Value from
|
||||
* @param[in] uuid : unique identifier of the Characteristic Values to read
|
||||
* @param[out] characteristic_value_list : pointer that will receive the Characteristic Value list
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_characteristic_values_using_uuid( const mico_bt_smartbridge_socket_t* socket, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_list_t* characteristic_value_list );
|
||||
|
||||
|
||||
/** Read Long Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Value from
|
||||
* @param[in] handle : Attribute handle of the Characteristic Value to read
|
||||
* @param[in] uuid : unique identifier of the Characteristic Value to read
|
||||
* @param[out] characteristic_value : pointer that will receive the Characteristic Value
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_long_characteristic_value( const mico_bt_smartbridge_socket_t* socket, uint16_t handle, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_t** characteristic_value );
|
||||
|
||||
|
||||
/** Write Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to write
|
||||
* Characteristic Value to
|
||||
* @param[in] characteristic_value : Characteristic Value to write
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_write_characteristic_value( const mico_bt_smartbridge_socket_t* socket, const mico_bt_smart_attribute_t* characteristic_value );
|
||||
|
||||
|
||||
/** Write Long Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to write
|
||||
* Characteristic Value to
|
||||
* @param[in] characteristic_value : Characteristic Value to write
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_write_long_characteristic_value( const mico_bt_smartbridge_socket_t* socket, const mico_bt_smart_attribute_t* characteristic_value );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @file
|
||||
* Defines SmartBridge Generic Attribute Profile (GATT) Functions
|
||||
*/
|
||||
|
||||
#include "mico_bt_smartbridge.h"
|
||||
#include "mico_bt_smart_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @addtogroup sbgatt SmartBridge GATT Procedures
|
||||
* @ingroup smartbridge
|
||||
*
|
||||
* SmartBridge Raw GATT Functions
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/** Discover All Primary Services
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Primary Services from
|
||||
* @param[out] service_list : pointer that will receive the list of Primary Services
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_all_primary_services( const mico_bt_smartbridge_socket_t* socket, mico_bt_smart_attribute_list_t* service_list );
|
||||
|
||||
|
||||
/** Discover Primary Services by the given UUID
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Primary Services from
|
||||
* @param[in] uuid : unique identifier of the Primary Services to discover
|
||||
* @param[out] service_list : pointer that will receive the list of Primary Services
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_primary_services_by_uuid( const mico_bt_smartbridge_socket_t* socket, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_list_t* service_list );
|
||||
|
||||
|
||||
/** Find Included Services
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Included Services from
|
||||
* @param[in] start_handle : starting Attribute handle of the Primary Service to
|
||||
* find the Included Services from
|
||||
* @param[in] end_handle : ending Attribute handle of the Primary Service to
|
||||
* find the Included Services from
|
||||
* @param[out] include_list : pointer that will receive the list of Included Services
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_find_included_services( const mico_bt_smartbridge_socket_t* socket, uint16_t start_handle, uint16_t end_handle, mico_bt_smart_attribute_list_t* include_list );
|
||||
|
||||
|
||||
/** Discover All Characterisitics in a Service
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Characteristics from
|
||||
* @param[in] start_handle : starting Attribute handle of the Primary Service to
|
||||
* discover Characteristics from
|
||||
* @param[in] end_handle : ending Attribute handle of the Primary Service to
|
||||
* discover Characteristics from
|
||||
* @param[out] characteristic_list : pointer that will receive the list of Characteristics
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_all_characteristics_in_a_service( const mico_bt_smartbridge_socket_t* socket, uint16_t start_handle, uint16_t end_handle, mico_bt_smart_attribute_list_t* characteristic_list );
|
||||
|
||||
|
||||
/** Discover Characterisitics by the given UUID
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Characteristics from
|
||||
* @param[in] uuid : unique identifier of the Characteristics to discover
|
||||
* @param[in] start_handle : starting Attribute handle of the Primary Service to
|
||||
* discover Characteristics from
|
||||
* @param[in] end_handle : ending Attribute handle of the Primary Service to
|
||||
* discover Characteristics from
|
||||
* @param[out] characteristic_list : pointer that will receive the list of Characteristics
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_characteristic_by_uuid( const mico_bt_smartbridge_socket_t* socket, const mico_bt_uuid_t* uuid, uint16_t start_handle, uint16_t end_handle, mico_bt_smart_attribute_list_t* characteristic_list );
|
||||
|
||||
|
||||
/** Discover Attribute Handle and Type of all Characteristic Descriptors
|
||||
*
|
||||
* @note
|
||||
* Additional information of the Descriptors can be read using @ref mico_bt_smartbridge_gatt_read_characteristic_descriptor()
|
||||
* and @ref mico_bt_smartbridge_gatt_read_long_characteristic_descriptor()
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to discover
|
||||
* Characteristic Descriptors from
|
||||
* @param[in] start_handle : starting Attribute handle of the Characteristic to
|
||||
* discover Characteristic Descriptors from
|
||||
* @param[in] end_handle : ending Attribute handle of the Characteristic to
|
||||
* discover Characteristic Descriptors from
|
||||
* @param[out] descriptor_list : pointer that will receive the list of Descriptors
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_discover_handle_and_type_of_all_characteristic_descriptors( const mico_bt_smartbridge_socket_t* socket, uint16_t start_handle, uint16_t end_handle, mico_bt_smart_attribute_list_t* descriptor_list );
|
||||
|
||||
|
||||
/** Read Characteristic Descriptor
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Descriptor from
|
||||
* @param[in] handle : Attribute handle of the Characteristic Descriptor to read
|
||||
* @param[in] uuid : unique identifier of the Characteristic Descriptor to read
|
||||
* @param[out] descriptor : pointer that will receive the Descriptors
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_characteristic_descriptor( const mico_bt_smartbridge_socket_t* socket, uint16_t handle, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_t** descriptor );
|
||||
|
||||
|
||||
/** Read Long Characteristic Descriptor
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Descriptor from
|
||||
* @param[in] handle : Attribute handle of the Characteristic Descriptor to read
|
||||
* @param[in] uuid : unique identifier of the Characteristic Descriptor to read
|
||||
* @param[out] descriptor : pointer that will receive the Descriptors
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_long_characteristic_descriptor( const mico_bt_smartbridge_socket_t* socket, uint16_t handle, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_t** descriptor );
|
||||
|
||||
|
||||
/** Write Characteristic Descriptor
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to write
|
||||
* Characteristic Descriptor to
|
||||
* @param[in] descriptor : Characteristic Descriptor to write
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_write_characteristic_descriptor( const mico_bt_smartbridge_socket_t* socket, const mico_bt_smart_attribute_t* descriptor );
|
||||
|
||||
|
||||
/** Write Long Characteristic Descriptor
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to write
|
||||
* Characteristic Descriptor to
|
||||
* @param[in] descriptor : Characteristic Descriptor to write
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_write_long_characteristic_descriptor( const mico_bt_smartbridge_socket_t* socket, const mico_bt_smart_attribute_t* descriptor );
|
||||
|
||||
|
||||
/** Read Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Value from
|
||||
* @param[in] handle : Attribute handle of the Characteristic Value to read
|
||||
* @param[in] uuid : unique identifier of the Characteristic Value to read
|
||||
* @param[out] characteristic_value : pointer that will receive the Characteristic Value
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_characteristic_value( const mico_bt_smartbridge_socket_t* socket, uint16_t handle, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_t** characteristic_value );
|
||||
|
||||
|
||||
/** Read Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Value from
|
||||
* @param[in] uuid : unique identifier of the Characteristic Values to read
|
||||
* @param[out] characteristic_value_list : pointer that will receive the Characteristic Value list
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_characteristic_values_using_uuid( const mico_bt_smartbridge_socket_t* socket, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_list_t* characteristic_value_list );
|
||||
|
||||
|
||||
/** Read Long Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to read
|
||||
* Characteristic Value from
|
||||
* @param[in] handle : Attribute handle of the Characteristic Value to read
|
||||
* @param[in] uuid : unique identifier of the Characteristic Value to read
|
||||
* @param[out] characteristic_value : pointer that will receive the Characteristic Value
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_read_long_characteristic_value( const mico_bt_smartbridge_socket_t* socket, uint16_t handle, const mico_bt_uuid_t* uuid, mico_bt_smart_attribute_t** characteristic_value );
|
||||
|
||||
|
||||
/** Write Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to write
|
||||
* Characteristic Value to
|
||||
* @param[in] characteristic_value : Characteristic Value to write
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_write_characteristic_value( const mico_bt_smartbridge_socket_t* socket, const mico_bt_smart_attribute_t* characteristic_value );
|
||||
|
||||
|
||||
/** Write Long Characteristic Value
|
||||
*
|
||||
* @param[in] socket : socket that is connected to the server to write
|
||||
* Characteristic Value to
|
||||
* @param[in] characteristic_value : Characteristic Value to write
|
||||
*
|
||||
* @return @ref OSStatus
|
||||
*/
|
||||
OSStatus mico_bt_smartbridge_gatt_write_long_characteristic_value( const mico_bt_smartbridge_socket_t* socket, const mico_bt_smart_attribute_t* characteristic_value );
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user