IDF:release/v4.3
协议:经典蓝牙,GAP+SPP
需求:蓝牙广播的时候传递信息
问题描述:没有找到这种需求的例程,发现GAP的API中esp_bt_gap_config_eir_data可以配置数据,广播时能收到。一开始include_uuid设置为false,发现电脑上接收到一个manufacturer数据包,数据比manufacturer_len配置的大小少2个字节,而且配置的长度大于50个字节后就无效了;include_uuid设置为true能收到两个manufacturer数据包,一个是26字节,一个是20字节,第一个的数据是缓冲区配置的,第二个的数据不知道哪里来的。完全不懂这个函数和这个结构体的使用,在例程和IDF的文档上也没有相关资料,请求帮助,或者有什么其它在广播时设备给电脑传递信息的方法也行。
Code: Select all
#define ESP_BT_EIR_MAX_LEN 240
/// EIR data content, according to "Supplement to the Bluetooth Core Specification"
typedef struct {
bool fec_required; /*!< FEC is required or not, true by default */
bool include_txpower; /*!< EIR data include TX power, false by default */
bool include_uuid; /*!< EIR data include UUID, false by default */
uint8_t flag; /*!< EIR flags, see ESP_BT_EIR_FLAG for details, EIR will not include flag if it is 0, 0 by default */
uint16_t manufacturer_len; /*!< Manufacturer data length, 0 by default */
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
uint16_t url_len; /*!< URL length, 0 by default */
uint8_t *p_url; /*!< URL point */
} esp_bt_eir_data_t;
/**
* @brief This function is called to config EIR data.
*
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_CONFIG_EIR_DATA_EVT after config EIR ends.
*
* @param[in] eir_data - pointer of EIR data content
* @return
* - ESP_OK : Succeed
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_ERR_INVALID_ARG: if param is invalid
* - ESP_FAIL: others
*/
esp_err_t esp_bt_gap_config_eir_data(esp_bt_eir_data_t *eir_data);