component/bt: format the API headers

This commit is contained in:
wangmengyang 2017-03-09 19:03:34 +08:00
parent 18814c03d4
commit 5b7b704365
6 changed files with 129 additions and 2069 deletions

View file

@ -44,15 +44,22 @@ esp_err_t esp_bt_gap_set_device_name(const char *name)
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (strlen(name) > ESP_BT_GAP_DEVICE_NAME_MAX) {
if (name != NULL) {
size_t len = strlen(name);
if (len > 0 || len <= ESP_BT_GAP_DEVICE_NAME_MAX) {
strcpy(arg.set_dev_name.device_name, name);
} else {
return ESP_ERR_INVALID_ARG;
}
} else {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_SET_DEV_NAME;
strcpy(arg.set_dev_name.device_name, name);
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -18,6 +18,10 @@
#include "esp_err.h"
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Media codec types supported by A2DP
#define ESP_A2D_MCT_SBC (0) /*!< SBC */
#define ESP_A2D_MCT_M12 (0x01) /*!< MPEG-1, 2 Audio */
@ -27,11 +31,7 @@
typedef uint8_t esp_a2d_mct_t;
/**
* @brief Codec specific information elements as defined in A2DP spec.
*/
/**
* @brief SBC codec specific information
* @brief SBC codec specific information as defined in A2DP spec
*/
typedef struct {
#define ESP_A2D_CIE_LEN_SBC (4)
@ -39,7 +39,7 @@ typedef struct {
} esp_a2d_cie_sbc_t;
/**
* @brief MPEG-1,2 Audio codec specific information
* @brief MPEG-1,2 Audio codec specific information as defined in A2DP spec
*/
typedef struct {
#define ESP_A2D_CIE_LEN_M12 (4)
@ -47,7 +47,7 @@ typedef struct {
} esp_a2d_cie_m12_t;
/**
* @brief MPEG-2,4 AAC codec specific information
* @brief MPEG-2,4 AAC codec specific information as defined in A2DP spec
*/
typedef struct {
#define ESP_A2D_CIE_LEN_M24 (6)
@ -55,7 +55,7 @@ typedef struct {
} esp_a2d_cie_m24_t;
/**
* @brief ATRAC family codec specific information
* @brief ATRAC family codec specific information as defined in A2DP spec
*/
typedef struct {
#define ESP_A2D_CIE_LEN_ATRAC (7)
@ -77,94 +77,99 @@ typedef struct {
/// Bluetooth A2DP connection states
typedef enum {
ESP_A2D_CONNECTION_STATE_DISCONNECTED = 0,
ESP_A2D_CONNECTION_STATE_CONNECTING,
ESP_A2D_CONNECTION_STATE_CONNECTED,
ESP_A2D_CONNECTION_STATE_DISCONNECTING
ESP_A2D_CONNECTION_STATE_DISCONNECTED = 0, /*!< connection released */
ESP_A2D_CONNECTION_STATE_CONNECTING, /*!< connecting remote device */
ESP_A2D_CONNECTION_STATE_CONNECTED, /*!< connection established */
ESP_A2D_CONNECTION_STATE_DISCONNECTING /*!< disconnecting remote device */
} esp_a2d_connection_state_t;
/// Bluetooth A2DP disconnection reason
typedef enum {
ESP_A2D_DISC_RSN_NORMAL = 0,
ESP_A2D_DISC_RSN_ABNORMAL
ESP_A2D_DISC_RSN_NORMAL = 0, /*!< Finished disconnection that is initiated by local or remote device */
ESP_A2D_DISC_RSN_ABNORMAL /*!< Abnormal disconnection caused by signal loss */
} esp_a2d_disc_rsn_t;
/// Bluetooth A2DP datapath states
typedef enum {
ESP_A2D_AUDIO_STATE_REMOTE_SUSPEND = 0,
ESP_A2D_AUDIO_STATE_STOPPED,
ESP_A2D_AUDIO_STATE_STARTED,
ESP_A2D_AUDIO_STATE_REMOTE_SUSPEND = 0, /*!< audio stream datapath suspended by remote device */
ESP_A2D_AUDIO_STATE_STOPPED, /*!< audio stream datapath stopped */
ESP_A2D_AUDIO_STATE_STARTED, /*!< audio stream datapath started */
} esp_a2d_audio_state_t;
/// A2DP callback events
typedef enum {
ESP_A2D_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
ESP_A2D_AUDIO_STATE_EVT = 1, /*!< audio stream transmission state changed event */
ESP_A2D_AUDIO_CFG_EVT = 2 /*!< audio codec configuration received */
ESP_A2D_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
ESP_A2D_AUDIO_STATE_EVT = 1, /*!< audio stream transmission state changed event */
ESP_A2D_AUDIO_CFG_EVT = 2 /*!< audio codec is configured */
} esp_a2d_cb_event_t;
/// A2DP state callback parameters
typedef union {
/*< ESP_A2D_CONNECTION_STATE_EVT */
struct a2d_conn_stat_param {
esp_a2d_connection_state_t state; /*!< one of values from esp_a2d_connection_state_t */
esp_bd_addr_t remote_bda;
esp_a2d_disc_rsn_t disc_rsn; /* disconnection reason */
esp_a2d_connection_state_t state; /*!< one of values from esp_a2d_connection_state_t */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
esp_a2d_disc_rsn_t disc_rsn; /*!< reason of disconnection for "DISCONNECTED" */
} conn_stat;
/*< ESP_A2D_AUDIO_STATE_EVT */
struct a2d_audio_stat_param {
esp_a2d_audio_state_t state; /*!< one of the values from esp_a2d_audio_state_t */
esp_bd_addr_t remote_bda;
esp_a2d_audio_state_t state; /*!< one of the values from esp_a2d_audio_state_t */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
} audio_stat;
/*< ESP_A2D_AUDIO_CFG_EVT */
struct a2d_audio_cfg_param {
esp_bd_addr_t remote_bda;
esp_a2d_mcc_t mcc; /*!< A2DP media codec capability information */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
esp_a2d_mcc_t mcc; /*!< A2DP media codec capability information */
} audio_cfg;
} esp_a2d_cb_param_t;
/**
* @brief A2DP profile callback function, data is ou
* @brief A2DP profile callback function type
* @param event : Event type
* @param param : Point to callback parameter
* @param param : Pointer to callback parameter
*/
typedef void (* esp_a2d_cb_t)(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param);
/**
* @brief A2DP profile data callback function, data is ou
*
* @param[in] buf: data received and decoded to PCM format, buf points to a static memory
* and can be overwritten in later times
* @param[in] len: size(in bytes) in buf
* @brief A2DP profile data callback function
*
* @param[in] buf : data received from A2DP source device and is PCM format decoder from SBC decoder;
* buf references to a static memory block and can be overwritten by upcoming data
*
* @param[in] len : size(in bytes) in buf
*
*/
typedef void (* esp_a2d_data_cb_t)(const uint8_t *buf, uint32_t len);
/**
* @brief This function is called to register application callbacks
* with A2DP module; callbacks will provide the upstream events
* (type esp_a2d_cb_event_t) and paramters(type esp_a2d_cb_param_t)
* @brief Register application callback function to A2DP module. This function should be called
* only after esp_bluedroid_enable() completes successfully
*
* @param[in] callback: A2DP sink event callback function
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: if callback is a NULL function pointer
*
*/
esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback);
/**
* @brief This function is called to register A2DP sink data output function
* for now only supports SBC codec, and the output is PCM data stream
* @brief Register A2DP sink data output function; For now the output is PCM data stream decoded
* from SBC format. This function should be called only after esp_bluedroid_enable()
* completes successfully
*
* @param[in] callback: A2DP data callback function
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: if callback is a NULL function pointer
*
*/
esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t cb);
@ -172,10 +177,12 @@ esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t cb);
/**
*
* @brief This function is called to initialize the bluetooth A2DP sink module
* @brief Initialize the bluetooth A2DP sink module. This function should be called
* after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK: success
* - ESP_OK: if the initialization request is sent successfully
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
@ -184,10 +191,12 @@ esp_err_t esp_a2d_sink_init(void);
/**
*
* @brief This function is called to deinit and free the resources for A2DP sink module
* @brief De-initialize for A2DP sink module. This function
* should be called only after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
@ -196,10 +205,13 @@ esp_err_t esp_a2d_sink_deinit(void);
/**
*
* @brief This function is called to connect with the remote bluetooth device
* @brief Connect the remote bluetooth device bluetooth, must after esp_a2d_sink_init()
*
* @param[in] remote_bda: remote bluetooth device address
*
* @return
* - ESP_OK: connect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
@ -208,13 +220,20 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda);
/**
*
* @brief This function is called to disconnect with the remote bluetooth device
* @brief Disconnect the remote bluetooth device
*
* @param[in] remote_bda: remote bluetooth device address
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_A2DP_API_H__ */

View file

@ -15,10 +15,14 @@
#ifndef __ESP_AVRC_API_H__
#define __ESP_AVRC_API_H__
#include "esp_err.h"
#include "esp_bt_defs.h"
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// AVRC feature bit mask
typedef enum {
@ -63,30 +67,31 @@ typedef union {
/*< ESP_AVRC_CT_PASSTHROUGH_RSP_EVT */
struct avrc_ct_psth_rsp_param {
uint8_t tl; /*!< transaction label, 0 to 15 */
uint8_t key_code;
uint8_t key_state; /*!< 0 for */
uint8_t tl; /*!< transaction label, 0 to 15 */
uint8_t key_code; /*!< passthrough command code */
uint8_t key_state; /*!< 0 for PRESSED, 1 for RELEASED */
} psth_rsp;
} esp_avrc_ct_cb_param_t;
/**
* @brief AVRCP controler callback function type
* @param event : Event type
* @param param : Point to callback parameter, currently is union type
* @brief AVRCP controller callback function type
* @param event : Event type
* @param param : Pointer to callback parameter union
*/
typedef void (* esp_avrc_ct_cb_t)(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param);
/**
* @brief This function is called to register application callbacks
* to AVRCP module; callbacks will provide the upstream events
* (type esp_avrc_ct_cb_event_t) and paramters(type esp_avrc_ct_cb_param_t)
* @brief Register application callbacks to AVRCP module; for now only AVRCP Controller
* role is supported. This function should be called after esp_bluedroid_enable()
* completes successfully
*
* @param[in] callback: A2DP sink event callback function
* @param[in] callback: AVRCP controller callback function
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
@ -95,10 +100,12 @@ esp_err_t esp_avrc_ct_register_callback(esp_avrc_ct_cb_t callback);
/**
*
* @brief This function is called to initialize the bluetooth AVRCP controller module
* @brief Initialize the bluetooth AVRCP controller module, This function should be called
* after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
@ -107,15 +114,36 @@ esp_err_t esp_avrc_ct_init(void);
/**
*
* @brief This function is called to deinit AVRCP controller module
* @brief De-initialize AVRCP controller module. This function should be called after
* after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_avrc_ct_deinit(void);
/**
* send pass through command to target
* @brief Send passthrough command to AVRCP target, This function should be called after
* ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established
*
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
* @param[in] key_code : passthrough command code, e.g. ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STOP, etc.
* @param[in] key_state : passthrough command key state, ESP_AVRC_PT_CMD_STATE_PRESSED or
* ESP_AVRC_PT_CMD_STATE_PRESSED
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code, uint8_t key_state);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_AVRC_API_H__ */

View file

@ -1,77 +0,0 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __ESP_BT_STACK_MANAGER_H__
#define __ESP_BT_STACK_MANAGER_H__
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
*
* @brief This function is called to initialize the bluetooth stack
*
* @return
* - ESP_OK: success
* - ESP_ERR_INVALID_STATE: if already initialized
* - ESP_FAIL: others
*
*/
esp_err_t esp_bt_init_stack(void);
/**
*
* @brief Deinit and free the resource for bluetooth
*
* @return
* - ESP_OK: success
* - ESP_ERR_INVALID_STATE: if not initailized yet
*
*/
esp_err_t esp_bt_deinit_stack(void);
/**
*
* @brief Enable bluetooth, must after esp_bt_init_stack()
*
* @return
* - ESP_OK: success
* - ESP_ERR_INVALID_STATE: if not initialized yet or already enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_bt_enable_stack(void);
/**
* @brief Disable bluetooth, must prior to esp_deinit_stack()
*
* @return
* - ESP_OK: success
* - ESP_ERR_INVALID_STATE: if not initialized yet or already enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_bt_disable_stack(void);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_BT_STACK_MANAGER_H__ */

View file

@ -23,6 +23,7 @@
extern "C" {
#endif
#define ESP_BT_GAP_DEVICE_NAME_MAX (32)
/// Discoverability and Connectability mode
@ -33,28 +34,35 @@ typedef enum {
} esp_bt_scan_mode_t;
/**
* @brief Set discoverability and connectability mode for legacy bluetooth
* @brief Set discoverability and connectability mode for legacy bluetooth. This function should
* be called after esp_bluedroid_enable() completes successfully
*
* @param[in] mode: one of the enums of bt_scan_mode_t
* @param[in] mode : one of the enums of bt_scan_mode_t
*
* @return
* - ESP_OK : Succeed
* - ESP_ERR_INVALID_ARG: if argument invalid
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);
/**
* @brief Set bluetooth device name
* @brief Set bluetooth device name. This function should be called after esp_bluedroid_enable()
* completes successfully
*
* @param[in] name: device name to be set, will be truncated if more than 32 characters
* @param[in] name : device name to be set, string length should not exceed ESP_BT_GAP_DEVICE_NAME_MAX
*
* @return
* - ESP_OK : Succeed
* - ESP_ERR_INVALID_ARG: if name is NULL pointer or empty string
* - ESP_ERR_INVALID_ARG : if name is NULL pointer or empty, or string length out of limit
* - ESP_INVALID_STATE : if bluetooth stack is not yet enabled
* - ESP_FAIL : others
*/
esp_err_t esp_bt_gap_set_device_name(const char *name);
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff