component/bt: add readme doc for BLE demos

- Closes:https://github.com/espressif/esp-idf/issues/3341
This commit is contained in:
zhiweijian 2019-04-26 17:24:34 +08:00 committed by bot
parent 483e82caf8
commit 4d8a46b376
10 changed files with 229 additions and 200 deletions

View file

@ -50,11 +50,16 @@ extern "C" {
#define ESP_GATT_UUID_HID_SVC 0x1812 /* HID Service*/
#define ESP_GATT_UUID_SCAN_PARAMETERS_SVC 0x1813 /* Scan Parameters Service*/
#define ESP_GATT_UUID_RUNNING_SPEED_CADENCE_SVC 0x1814 /* Running Speed and Cadence Service*/
#define ESP_GATT_UUID_Automation_IO_SVC 0x1815 /* Automation IO Service*/
#define ESP_GATT_UUID_CYCLING_SPEED_CADENCE_SVC 0x1816 /* Cycling Speed and Cadence Service*/
#define ESP_GATT_UUID_CYCLING_POWER_SVC 0x1818 /* Cycling Power Service*/
#define ESP_GATT_UUID_LOCATION_AND_NAVIGATION_SVC 0x1819 /* Location and Navigation Service*/
#define ESP_GATT_UUID_ENVIRONMENTAL_SENSING_SVC OX181A /* Environmental Sensing Service*/
#define ESP_GATT_UUID_BODY_COMPOSITION 0x181B /* Body Composition Service*/
#define ESP_GATT_UUID_USER_DATA_SVC 0x181C /* User Data Service*/
#define ESP_GATT_UUID_WEIGHT_SCALE_SVC 0x181D /* Weight Scale Service*/
#define ESP_GATT_UUID_BOND_MANAGEMENT_SVC 0x181E /* Bond Management Service*/
#define ESP_GATT_UUID_CONT_GLUCOSE_MONITOR_SVC 0x181F /* Continuous Glucose Monitoring Service*/
#define ESP_GATT_UUID_PRI_SERVICE 0x2800
#define ESP_GATT_UUID_SEC_SERVICE 0x2801

View file

@ -1654,6 +1654,10 @@ tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p
osi_mutex_lock(&adv_data_lock, OSI_MUTEX_MAX_TIMEOUT);
memset(rsp_data, 0, BTM_BLE_AD_DATA_LEN);
btm_ble_build_adv_data(&data_mask, &p, p_data);
if (data_mask != 0) {
//data length should not exceed 31 bytes
BTM_TRACE_WARNING("%s, Partial data write into ADV", __func__);
}
if (btsnd_hcic_ble_set_scan_rsp_data((UINT8)(p - rsp_data), rsp_data)) {
osi_sem_take(&adv_data_sem, OSI_SEM_MAX_TIMEOUT);
@ -1798,7 +1802,8 @@ tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p
p_cb_data->p_pad = p;
if (mask != 0) {
BTM_TRACE_DEBUG("Partial data write into ADV");
//data length should not exceed 31 bytes
BTM_TRACE_WARNING("%s, Partial data write into ADV", __func__);
}
p_cb_data->data_mask &= ~mask;

View file

@ -160,6 +160,7 @@ BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data)
if (p_data != NULL && data_len > 0) {
if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA) {
data_len = HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA;
HCI_TRACE_WARNING("Data length exceeds 31 bytes, only the first 31 bytes are used.\n");
}
UINT8_TO_STREAM (pp, data_len);
@ -193,6 +194,7 @@ BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp)
if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP ) {
data_len = HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP;
HCI_TRACE_WARNING("Data length exceeds 31 bytes, only the first 31 bytes are used.\n");
}
UINT8_TO_STREAM (pp, data_len);

View file

@ -304,7 +304,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
* @brief De-initialize BT controller to free resource and delete task.
*
* This function should be called only once, after any other BT functions are called.
* This function is not whole completed, esp_bt_controller_init cannot called after this function.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_deinit(void);

View file

@ -145,15 +145,15 @@ The format of Ack Frame8 bit
* The data frame supports to be encrypted and verified.
**1.1 Control Frame (0x0b00)**
**1.1 Control Frame (0x0 b00)**
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| Control Frame / 0x0b00 | Implication | Explanation | Note |
| Control Frame (Binary) | Implication | Explanation | Note |
+=========================+==============================================================+===============================================================+===============================================================+
| 0x0b000000 | Ack | The data field of the Ack frame uses the same | The data field consumes a byte and its value is |
| 0x0 (b000000) | Ack | The data field of the Ack frame uses the same | The data field consumes a byte and its value is |
| | | sequence value of the frame to reply to. | the same as the sequence field of the frame to reply to. |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x1b000001 | Set ESP32 to the security mode. | To inform ESP32 of the security mode to use | The data field consumes a byte. |
| 0x1 (b000001) | Set ESP32 to the security mode. | To inform ESP32 of the security mode to use | The data field consumes a byte. |
| | | when sending data, which is allowed to be reset | The higher 4 bits are for the security mode setting |
| | | multiple times during the process. | of the control frame, and the lower 4 bits are for |
| | | Each setting affects the subsequent security mode used. | the security mode setting of the data frame. |
@ -166,7 +166,7 @@ The format of Ack Frame8 bit
+ + + +---------------------------------------------------------------+
| | | | b0011: with both checksum and encryption. |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x2b000010 | Set the opmode of Wi-Fi. | The frame contains opmode settings for | data[0] is for opmode settings, including: |
| 0x2 (b000010) | Set the opmode of Wi-Fi. | The frame contains opmode settings for | data[0] is for opmode settings, including: |
+ + + configuring for the Wi-Fi mode of ESP32. +---------------------------------------------------------------+
| | | | 0x00: NULL |
+ + + +---------------------------------------------------------------+
@ -179,12 +179,12 @@ The format of Ack Frame8 bit
| | | | Please set the SSID/Password/Max Connection Number of |
| | | | the AP mode in the first place if an AP gets involved. |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x3b000011 | Connect ESP32 to the AP. | To notify ESP32 that the essential information has been sent | No data field is contained. |
| 0x3 (b000011) | Connect ESP32 to the AP. | To notify ESP32 that the essential information has been sent | No data field is contained. |
| | | and it is allowed to connect to the AP. | |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x4b000100 | Disconnect ESP32 from the AP. | | No data field is contained. |
| 0x4 (b000100) | Disconnect ESP32 from the AP. | | No data field is contained. |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x5b000101 | To get the information of ESP32s Wi-Fi mode and its status. | | No data field is contained. |
| 0x5 (b000101) | To get the information of ESP32s Wi-Fi mode and its status. | | No data field is contained. |
| | | | When receiving this control frame, ESP32 will send back |
| | | | a follow-up frame of Wi-Fi connection state report to |
| | | | the mobile phone with the information of the current opmode, |
@ -192,142 +192,142 @@ The format of Ack Frame8 bit
| | | | The types of information sent to the mobile phone is |
| | | | defined by the application installed on the phone. |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x6b000110 | Disconnect the STA device from the SoftAP (in SoftAP mode). | | Date[0~5] is taken as the MAC address for the STA device. |
| 0x6 (b000110) | Disconnect the STA device from the SoftAP (in SoftAP mode). | | Date[0~5] is taken as the MAC address for the STA device. |
| | | | If there is a second STA device, then it uses data[6-11] |
| | | | and the rest can be done in the same manner. |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x7b'000111 | Get the version information. | | |
| 0x7 (b'000111) | Get the version information. | | |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x8b001000 | Disconnect the BLE GATT link. | | ESP32 will disconnect the BLE GATT link |
| 0x8 (b001000) | Disconnect the BLE GATT link. | | ESP32 will disconnect the BLE GATT link |
| | | | after receives this command. |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
| 0x9b001001 | Get the Wi-Fi list. | To get ESP32 to scan the Wi-Fi access points around. | No data field is contained. |
| 0x9 (b001001) | Get the Wi-Fi list. | To get ESP32 to scan the Wi-Fi access points around. | No data field is contained. |
| | | | When receiving this control frame, |
| | | | ESP32 will send back a follow-up frame of Wi-Fi list |
| | | | report to the mobile phone. |
+-------------------------+--------------------------------------------------------------+---------------------------------------------------------------+---------------------------------------------------------------+
**1.2 Data Frame (0x1b01)**
**1.2 Data Frame (0x1 b01)**
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| Data Frame | Implication | Explanation | Note |
+==============+====================================================+===============================================================+=======================================================================+
| 0x0b000000 | Send the negotiation data. | The negotiation data will be sent to the callback | The length of the data depends on the length field. |
| | | function registered in the application layer. | |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x1b000001 | Send the BSSID for STA mode. | To send the BSSID of the AP for the STA device to | The length of the data depends on the length field. |
| | | connect under the condition that the SSID is hidden. | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x2b000010 | Send the SSID for STA mode. | To send the SSID of the AP for the STA device to connect. | The length of the data depends on the length field. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x3b000011 | Send the password for STA mode. | To send the password of the AP for the STA device to connect. | The length of the data depends on the length field. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x4b000100 | Send the SSID for SoftAP mode. | | The length of the data depends on the length field. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x5b000101 | Send the password for SoftAPmode. | | The length of the data depends on the length field. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x6b000110 | Set the maximum connection number for SoftAP mode. | | data[0] represents the value of the connection number, |
| | | | ranging from 1 to 4. When the transmission direction is ESP32 |
| | | | to the mobile phone, it means to provide the mobile phone with |
| | | | the needed information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x7b000111 | Set the authentication mode for the SoftAP. | | data[0] |
+ + + +-----------------------------------------------------------------------+
| | | | 0x00: OPEN |
+ + + +-----------------------------------------------------------------------+
| | | | 0x01: WEP |
+ + + +-----------------------------------------------------------------------+
| | | | 0x02: WPA_PSK |
+ + + +-----------------------------------------------------------------------+
| | | | 0x03: WPA2_PSK |
+ + + +-----------------------------------------------------------------------+
| | | | 0x04: WPA_WPA2_PSK |
+ + + +-----------------------------------------------------------------------+
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x8b001000 | Set the channel amount for SoftAP mode. | | data[0] represents the quantity of the supported channels, |
| | | | ranging from 1 to 14. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x9b001001 | Username | It provides the username of the GATT client when using | The length of the data depends on the length field. |
| | | encryption of enterprise level. | |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xab001010 | CA Certification | It provides the CA Certification when using encryption | The length of the data depends on the length field. |
| | | of enterprise level. | The frame supports to be fragmented if the data length is not enough. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xbb001011 | Client Certification | It provides the client certification when | The length of the data depends on the length field. |
| | | using encryption of enterprise level. | The frame supports to be fragmented if the data length is not enough. |
| | | Whether the private key is contained or not | |
| | | depends on the content of the certification. | |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xcb001100 | Server Certification | It provides the sever certification when using | The length of the data depends on the length field. |
| | | encryption of enterprise level. Whether the private key is | The frame supports to be fragmented if the data length is not enough. |
| | | contained or not depends on the content of the certification. | |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xdb001101 | ClientPrivate Key | It provides the private key of the client when | The length of the data depends on the length field. |
| | | using encryption of enterprise level. | The frame supports to be fragmented if the data length is not enough. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xeb001110 | ServerPrivate Key | It provides the private key of the sever when | The length of the data depends on the length field. |
| | | using encryption of enterprise level. | The frame supports to be fragmented if the data length is not enough. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xfb001111 | Wi-Fi Connection State Report | To notify the phone of the ESP32's Wi-Fi status, | data[0] represents opmode, including: |
+ + + including STA status and SoftAP status. +-----------------------------------------------------------------------+
| | | It is for the STA device to connect to the | 0x00: NULL |
+ + + mobile phone or the SoftAP. +-----------------------------------------------------------------------+
| | | However, when the mobile phone receives the Wi-Fi status, | 0x01: STA |
+ + + it can reply to other frames in addition to this frame. +-----------------------------------------------------------------------+
| | | | 0x02: SoftAP |
+ + + +-----------------------------------------------------------------------+
| | | | 0x03: SoftAP&STA |
+ + + +-----------------------------------------------------------------------+
| | | | data[1]the connection state of the STA device, |
| | | | 0x0 indicates a connection state, |
| | | | and others represent a disconnected state; |
+ + + +-----------------------------------------------------------------------+
| | | | data[2]the connection state of the SoftAP, |
| | | | that is, how many STA devices have been connected. |
+ + + +-----------------------------------------------------------------------+
| | | | data[3] and the subsequent is in accordance with the |
| | | | format of SSID/BSSID information. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x10b010000 | Version | | data[0]= great versiondata[1]= sub version |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x11B010001 | Wi-Fi List | To send the Wi-Fi list to ESP32. | The format of the data frame is length + RSSI + SSID |
| | | | and it supports to be sent into fragments |
| | | | if the data length is too long. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x12B010010 | Report Error | To notify the mobile phone that there is an error with BluFi. | 0x00: sequence error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x01: checksum error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x02: decrypt error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x03: encrypt error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x04: init security error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x05: dh malloc error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x06: dh param error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x07: read param error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x08: make public error |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x13B010011 | Custom Data | To send or receive custom data. | The data frame supports to be sent into |
| | | | fragments if the data length is too long. |
+--------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
|Data Frame(Binary)| Implication | Explanation | Note |
+==================+====================================================+===============================================================+=======================================================================+
| 0x0 (b000000) | Send the negotiation data. | The negotiation data will be sent to the callback | The length of the data depends on the length field. |
| | | function registered in the application layer. | |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x1 (b000001) | Send the BSSID for STA mode. | To send the BSSID of the AP for the STA device to | The length of the data depends on the length field. |
| | | connect under the condition that the SSID is hidden. | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x2 (b000010) | Send the SSID for STA mode. | To send the SSID of the AP for the STA device to connect. | The length of the data depends on the length field. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x3 (b000011) | Send the password for STA mode. | To send the password of the AP for the STA device to connect. | The length of the data depends on the length field. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x4 (b000100) | Send the SSID for SoftAP mode. | | The length of the data depends on the length field. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x5 (b000101) | Send the password for SoftAPmode. | | The length of the data depends on the length field. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x6 (b000110) | Set the maximum connection number for SoftAP mode. | | data[0] represents the value of the connection number, |
| | | | ranging from 1 to 4. When the transmission direction is ESP32 |
| | | | to the mobile phone, it means to provide the mobile phone with |
| | | | the needed information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x7 (b000111) | Set the authentication mode for the SoftAP. | | data[0] |
+ + + +-----------------------------------------------------------------------+
| | | | 0x00: OPEN |
+ + + +-----------------------------------------------------------------------+
| | | | 0x01: WEP |
+ + + +-----------------------------------------------------------------------+
| | | | 0x02: WPA_PSK |
+ + + +-----------------------------------------------------------------------+
| | | | 0x03: WPA2_PSK |
+ + + +-----------------------------------------------------------------------+
| | | | 0x04: WPA_WPA2_PSK |
+ + + +-----------------------------------------------------------------------+
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x8 (b001000) | Set the channel amount for SoftAP mode. | | data[0] represents the quantity of the supported channels, |
| | | | ranging from 1 to 14. |
| | | | When the transmission direction is ESP32 to the mobile phone, |
| | | | it means to provide the mobile phone with the needed information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x9 (b001001) | Username | It provides the username of the GATT client when using | The length of the data depends on the length field. |
| | | encryption of enterprise level. | |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xa (b001010) | CA Certification | It provides the CA Certification when using encryption | The length of the data depends on the length field. |
| | | of enterprise level. | The frame supports to be fragmented if the data length is not enough. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xb (b001011) | Client Certification | It provides the client certification when | The length of the data depends on the length field. |
| | | using encryption of enterprise level. | The frame supports to be fragmented if the data length is not enough. |
| | | Whether the private key is contained or not | |
| | | depends on the content of the certification. | |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xc (b001100) | Server Certification | It provides the sever certification when using | The length of the data depends on the length field. |
| | | encryption of enterprise level. Whether the private key is | The frame supports to be fragmented if the data length is not enough. |
| | | contained or not depends on the content of the certification. | |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xd (b001101) | ClientPrivate Key | It provides the private key of the client when | The length of the data depends on the length field. |
| | | using encryption of enterprise level. | The frame supports to be fragmented if the data length is not enough. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xe (b001110) | ServerPrivate Key | It provides the private key of the sever when | The length of the data depends on the length field. |
| | | using encryption of enterprise level. | The frame supports to be fragmented if the data length is not enough. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0xf (b001111) | Wi-Fi Connection State Report | To notify the phone of the ESP32's Wi-Fi status, | data[0] represents opmode, including: |
+ + + including STA status and SoftAP status. +-----------------------------------------------------------------------+
| | | It is for the STA device to connect to the | 0x00: NULL |
+ + + mobile phone or the SoftAP. +-----------------------------------------------------------------------+
| | | However, when the mobile phone receives the Wi-Fi status, | 0x01: STA |
+ + + it can reply to other frames in addition to this frame. +-----------------------------------------------------------------------+
| | | | 0x02: SoftAP |
+ + + +-----------------------------------------------------------------------+
| | | | 0x03: SoftAP&STA |
+ + + +-----------------------------------------------------------------------+
| | | | data[1]the connection state of the STA device, |
| | | | 0x0 indicates a connection state, |
| | | | and others represent a disconnected state; |
+ + + +-----------------------------------------------------------------------+
| | | | data[2]the connection state of the SoftAP, |
| | | | that is, how many STA devices have been connected. |
+ + + +-----------------------------------------------------------------------+
| | | | data[3] and the subsequent is in accordance with the |
| | | | format of SSID/BSSID information. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x10 (b010000) | Version | | data[0]= great versiondata[1]= sub version |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x11 (b010001) | Wi-Fi List | To send the Wi-Fi list to ESP32. | The format of the data frame is length + RSSI + SSID |
| | | | and it supports to be sent into fragments |
| | | | if the data length is too long. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x12 (b010010) | Report Error | To notify the mobile phone that there is an error with BluFi. | 0x00: sequence error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x01: checksum error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x02: decrypt error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x03: encrypt error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x04: init security error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x05: dh malloc error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x06: dh param error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x07: read param error |
+ + + +-----------------------------------------------------------------------+
| | | | 0x08: make public error |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
| 0x13 (b010011) | Custom Data | To send or receive custom data. | The data frame supports to be sent into |
| | | | fragments if the data length is too long. |
+------------------+----------------------------------------------------+---------------------------------------------------------------+-----------------------------------------------------------------------+
2. Frame Control
@ -453,9 +453,3 @@ BluFi Service UUID: 0xFFFF16 bit
BluFi (the mobile -> ESP32): 0xFF01, writable
Blufi (ESP32 -> the mobile phone): 0xFF02, readable and callable
.. note::
1. The Ack mechanism is already defined in the profile, but there is no implementation based on the code for the time being.
2. Other parts have been implemented.

View file

@ -149,15 +149,15 @@ Ack 帧格式8 bit
* 数据帧,可加密,可校验。
**1.1 控制帧 (0x0b00)**
**1.1 控制帧 (0x0 b00)**
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 控制帧 / 0x0b00 | 含义 | 解释 | 备注 |
| 控制帧 (二进制) | 含义 | 解释 | 备注 |
+==================+===================================+================================================================+======================================================================+
| 0x0b000000 | Ack | 用来回复对方发的帧, | Data 域使用1 byte Sequence 值, |
| 0x0 (b000000) | Ack | 用来回复对方发的帧, | Data 域使用1 byte Sequence 值, |
| | | Ack 帧的 Data 域使用回复对象帧的 Sequence 值。 | 与恢复对象帧的Sequence 值相同。 |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x1b000001 | Set ESP32 to the security mode. | 通知 ESP32 发送数据时使用的安全模式, | Data 域占用 1 byte。 |
| 0x1 (b000001) | Set ESP32 to the security mode. | 通知 ESP32 发送数据时使用的安全模式, | Data 域占用 1 byte。 |
| | | 在该过程中可设置多次,每次设置后影响后续安全模式。 | 高 4 bit 为控制帧的安全模式,低 4bit 为数据帧的安全模式。 |
+ + + 在不设置的情况下ESP32 默认控制帧和数据帧均为无校验、无加密。 +----------------------------------------------------------------------+
| | | 手机到 ESP32 方向依赖于帧 Control 域。 | b0000无校验、无加密 |
@ -168,7 +168,7 @@ Ack 帧格式8 bit
+ + + +----------------------------------------------------------------------+
| | | | b0011有校验、有加密。 |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x2b000010 | Set the Wi-Fi opmode of ESP32. | 设置 ESP32 的 Wi-Fi 模式,帧包含 opmode 信息。 | data[0] 用于表示 opmode 类型,包括: |
| 0x2 (b000010) | Set the Wi-Fi opmode of ESP32. | 设置 ESP32 的 Wi-Fi 模式,帧包含 opmode 信息。 | data[0] 用于表示 opmode 类型,包括: |
+ + + +----------------------------------------------------------------------+
| | | | 0x00: NULL; |
+ + + +----------------------------------------------------------------------+
@ -181,67 +181,67 @@ Ack 帧格式8 bit
| | | | 如果设置有包含 AP请尽量优先 |
| | | | 设置 AP 模式的SSID/Password/Max Conn Number 等。 |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x3b000011 | Connect ESP32 to the AP. | 通知 ESP32必要的信息已经发送完毕可以连接 AP。 | 不包含 Data 域。 |
| 0x3 (b000011) | Connect ESP32 to the AP. | 通知 ESP32必要的信息已经发送完毕可以连接 AP。 | 不包含 Data 域。 |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x4b000100 | Disconnect ESP32 from the AP. | 通知 ESP32 断开与 AP 的连接 | 不包含 Data 域。 |
| 0x4 (b000100) | Disconnect ESP32 from the AP. | 通知 ESP32 断开与 AP 的连接 | 不包含 Data 域。 |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x5b000101 | Get the status of Wi-Fi. | 获取 ESP32 的 Wi-Fi 模式和状态等信息。 | 不包含 Data 域。 |
| 0x5 (b000101) | Get the status of Wi-Fi. | 获取 ESP32 的 Wi-Fi 模式和状态等信息。 | 不包含 Data 域。 |
| | | | ESP32 收到此控制帧后,后续会通过 Wi-Fi 连接状态 |
| | | | 报告 (Wi-Fi Connection State Report) 数据帧来回复手机端当前 |
| | | | 所处的 opmode、连接状态、SSID 等信息。提供给手机端的信息由应用决定。 |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x6b000110 | Disconnect the STA device | 处于 SoftAP 模式时,踢掉某个 STA 设备。 | data[0~5] 为 STA 设备的 MAC 地址, |
| 0x6 (b000110) | Disconnect the STA device | 处于 SoftAP 模式时,踢掉某个 STA 设备。 | data[0~5] 为 STA 设备的 MAC 地址, |
| | from the SoftAP in SoftAP mode. | | 如有多个 STA则 [6-11] 为第二个,依次类推。 |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x7b'000111 | Get the version. | | |
| 0x7 (b'000111) | Get the version. | | |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x8b001000 | Tell ESP32 to disconnect | 通知 ESP32 断开蓝牙连接。 | ESP32 收到该指令后主动断开蓝牙连接。 |
| 0x8 (b001000) | Tell ESP32 to disconnect | 通知 ESP32 断开蓝牙连接。 | ESP32 收到该指令后主动断开蓝牙连接。 |
| | the BLE GATT link. | | |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
| 0x9b001001 | Tell ESP32 to get the Wi-Fi list. | 通知 ESP32 扫描周围的 Wi-Fi 热点 | 不包含 Data 域。 |
| 0x9 (b001001) | Tell ESP32 to get the Wi-Fi list. | 通知 ESP32 扫描周围的 Wi-Fi 热点 | 不包含 Data 域。 |
| | | | ESP32 收到此控制帧后,会发送包含 Wi-Fi 热点 |
| | | | 报告 (Wi-Fi List Report) 的数据帧回复 |
| | | | 手机端 ESP32 周围的 Wi-Fi 热点。 |
+------------------+-----------------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+
**1.2 数据帧 (0x1b01)**
**1.2 数据帧 (0x1 b01)**
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 数据帧 | 含义 | 解释 | 备注 |
|数据帧 (二进制)| 含义 | 解释 | 备注 |
+===============+========================================+================================================+======================================================+
| 0x0 b000000 | Negotiation data. | 用来发送协商数据,传输到应用层注册的回调函数。 | 数据长度与 Length 域有关。 |
| 0x0 (b000000)| Negotiation data. | 用来发送协商数据,传输到应用层注册的回调函数。 | 数据长度与 Length 域有关。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x1 b000001 | BSSID for STA mode. | STA 将要连接的 AP 的 BSSID用于隐藏SSID。 | 数据长度与 Length 域有关。 |
| 0x1 (b000001)| BSSID for STA mode. | STA 将要连接的 AP 的 BSSID用于隐藏SSID。 | 数据长度与 Length 域有关。 |
+ + + +------------------------------------------------------+
| | | | 当传输方向为 ESP32 到手机时, |
| | | | 表示向手机端提供信息。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x2 b000010 | SSID for STA mode. | STA 将要连接的 AP 的 SSID。 | 数据长度与 Length 域有关。 |
| 0x2 (b000010)| SSID for STA mode. | STA 将要连接的 AP 的 SSID。 | 数据长度与 Length 域有关。 |
+ + + +------------------------------------------------------+
| | | | 当传输方向为 ESP32 到手机时, |
| | | | 表示向手机端提供信息。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x3 b000011 | Password for STA mode. | STA 将要连接的 AP 的密码。 | 数据长度与 Length 域有关。 |
| 0x3 (b000011)| Password for STA mode. | STA 将要连接的 AP 的密码。 | 数据长度与 Length 域有关。 |
+ + + +------------------------------------------------------+
| | | | 当传输方向为 ESP32 到手机时, |
| | | | 表示向手机端提供信息。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x4 b000100 | SSID for SoftAP mode. | SoftAP 模式使用的 SSID。 | 数据长度与 Length 域有关。 |
| 0x4 (b000100)| SSID for SoftAP mode. | SoftAP 模式使用的 SSID。 | 数据长度与 Length 域有关。 |
+ + + +------------------------------------------------------+
| | | | 当传输方向为 ESP32 到手机时, |
| | | | 表示向手机端提供信息。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x5 b000101 | Password for SoftAPmode. | SoftAP 模式使用的密码。 | 数据长度与 Length 域有关。 |
| 0x5 (b000101)| Password for SoftAPmode. | SoftAP 模式使用的密码。 | 数据长度与 Length 域有关。 |
+ + + +------------------------------------------------------+
| | | | 当传输方向为 ESP32 到手机时, |
| | | | 表示向手机端提供信息。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x6 b000110 | Max connection number for SoftAP mode. | AP 模式的最大连接数。 | data[0] 表示连接数的值,范围 1~4。 |
| 0x6 (b000110)| Max connection number for SoftAP mode. | AP 模式的最大连接数。 | data[0] 表示连接数的值,范围 1~4。 |
+ + + +------------------------------------------------------+
| | | | 当传输方向为 ESP32 到手机时, |
| | | | 表示向手机端提供信息。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x7b000111 | Authentication mode for SoftAP mode. | AP 模式的认证模式。 | data[0] |
| 0x7 (b000111)| Authentication mode for SoftAP mode. | AP 模式的认证模式。 | data[0] |
+ + + +------------------------------------------------------+
| | | | 0x00: OPEN; |
+ + + +------------------------------------------------------+
@ -256,31 +256,31 @@ Ack 帧格式8 bit
| | | | 当传输方向为 ESP32 到手机时, |
| | | | 表示向手机端提供信息。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x8b001000 | Channel for SoftAP mode. | SoftAP 模式的通道数量。 | data[0] 表示通道的数量,范围 1~14。 |
| 0x8 (b001000)| Channel for SoftAP mode. | SoftAP 模式的通道数量。 | data[0] 表示通道的数量,范围 1~14。 |
+ + + +------------------------------------------------------+
| | | | 当传输方向为 ESP32 到手机时, |
| | | | 表示向手机端提供信息。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x9b001001 | Username. | 使用企业级加密时Client 端的用户名。 | 数据长度与 Length 域有关。 |
| 0x9 (b001001)| Username. | 使用企业级加密时Client 端的用户名。 | 数据长度与 Length 域有关。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0xab001010 | CA certification. | 进行企业级加密时使用的 CA 证书。 | 数据长度与 Length 域有关, |
| 0xa (b001010)| CA certification. | 进行企业级加密时使用的 CA 证书。 | 数据长度与 Length 域有关, |
| | | | 长度不够,可用分片。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0xbb001011 | Client certification. | 进行企业级加密时Client 端的证书。 | 数据长度与 Length 域有关, |
| 0xb (b001011)| Client certification. | 进行企业级加密时Client 端的证书。 | 数据长度与 Length 域有关, |
+ + +------------------------------------------------+ 长度不够,可用分片。 +
| | | 可包含或不包含私钥,由证书内容决定。 | |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0xcb001100 | Server certification. | 进行企业级加密时Server 端的证书。 | 数据长度与 Length 域有关, |
| 0xc (b001100)| Server certification. | 进行企业级加密时Server 端的证书。 | 数据长度与 Length 域有关, |
+ + +------------------------------------------------+ 长度不够,可用分片。 +
| | | 可包含或不包含私钥,由证书内容决定。 | |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0xdb001101 | Client private key. | 进行企业级加密时Client 端的私钥。 | 数据长度与 Length 域有关, |
| 0xd (b001101)| Client private key. | 进行企业级加密时Client 端的私钥。 | 数据长度与 Length 域有关, |
| | | | 长度不够,可用分片。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0xeb001110 | Server private key. | 进行企业级加密时Server 端的私钥。 | 数据长度与 Length 域有关, |
| 0xe (b001110)| Server private key. | 进行企业级加密时Server 端的私钥。 | 数据长度与 Length 域有关, |
| | | | 长度不够,可用分片。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0xf b001111 | Wi-Fi connection state report. | 通知手机 ESP32 的 Wi-Fi 状态, | data[0] 表示 opmode包括 |
| 0xf (b001111)| Wi-Fi connection state report. | 通知手机 ESP32 的 Wi-Fi 状态, | data[0] 表示 opmode包括 |
| | | 包括 STA状态和 SoftAP 状态, | |
| | | 用于手机配置 STA 连接时的通知, | |
| | | 或有 STA 连接上 SoftAP 时的通知。 | |
@ -306,10 +306,10 @@ Ack 帧格式8 bit
+ + + +------------------------------------------------------+
| | | | data[1]=sub version |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x11 B010001 | Wi-Fi list. | 通知手机 ESP32 周围的 Wi-Fi 热点列表。 | 数据帧数据格式为 Length + RSSI + SSID, |
|0x11 (b010001)| Wi-Fi list. | 通知手机 ESP32 周围的 Wi-Fi 热点列表。 | 数据帧数据格式为 Length + RSSI + SSID, |
| | | | 数据较长时可分片发送。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x12 B010010 | Report error. | 通知手机 BluFi 过程出现异常错误。 | 0x00: sequence error; |
|0x12 (b010010)| Report error. | 通知手机 BluFi 过程出现异常错误。 | 0x00: sequence error; |
+ + + +------------------------------------------------------+
| | | | 0x01: checksum error; |
+ + + +------------------------------------------------------+
@ -327,7 +327,7 @@ Ack 帧格式8 bit
+ + + +------------------------------------------------------+
| | | | 0x08: make public error. |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
| 0x13 B010011 | Custom data. | 用户发送或者接收自定义数据。 | 数据较长时可分片发送。 |
|0x13 (b010011)| Custom data. | 用户发送或者接收自定义数据。 | 数据较长时可分片发送。 |
+---------------+----------------------------------------+------------------------------------------------+------------------------------------------------------+
2. Frame Control
@ -448,10 +448,4 @@ BluFi Service UUID 0xFFFF16 bit
BluFi (手机 -> ESP32 特性0xFF01主要权限可写
BluFi ESP32 -> 手机) 特性0xFF02主要权限可读可通知
.. note::
1. 目前 Ack 机制已经在该 Profile 协议中定义,但是还没有代码实现。
2. 其他部分均已实现。
BluFi ESP32 -> 手机) 特性0xFF02主要权限可读可通知

View file

@ -0,0 +1,16 @@
ESP-IDF BLE Compatibility Test Example
=======================================
This demo is to test the compatibility of Bluetooth and mobile phones.
* ESP32 Module: ESP-WROOM-32
* IDF version: 7c29a39d6f9f2dfbefc49d34d34e9267afc7200d
* [Test case](https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/ble_compatibility_test/ble_compatibility_test_case.md)
* Test APK: LightBlue V1.1.3
* [Test report](https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/ble_compatibility_test/esp_ble_compatibility_test_report.md)

View file

@ -129,6 +129,10 @@ static void notify_event_handler(esp_ble_gattc_cb_param_t * p_data)
ESP_LOGI(GATTC_TAG,"+INDICATE:handle = %d,length = %d ", p_data->notify.handle, p_data->notify.value_len);
}
handle = p_data->notify.handle;
if(db == NULL) {
ESP_LOGE(GATTC_TAG, " %s db is NULL\n", __func__);
return;
}
if(handle == db[SPP_IDX_SPP_DATA_NTY_VAL].attribute_handle){
#ifdef SPP_DEBUG_MODE
esp_log_buffer_char(GATTC_TAG, (char *)p_data->notify.value, p_data->notify.value_len);
@ -464,19 +468,21 @@ void spp_client_reg_task(void* arg)
for(;;) {
vTaskDelay(100 / portTICK_PERIOD_MS);
if(xQueueReceive(cmd_reg_queue, &cmd_id, portMAX_DELAY)) {
if(cmd_id == SPP_IDX_SPP_DATA_NTY_VAL){
ESP_LOGI(GATTC_TAG,"Index = %d,UUID = 0x%04x, handle = %d \n", cmd_id, (db+SPP_IDX_SPP_DATA_NTY_VAL)->uuid.uuid.uuid16, (db+SPP_IDX_SPP_DATA_NTY_VAL)->attribute_handle);
esp_ble_gattc_register_for_notify(spp_gattc_if, gl_profile_tab[PROFILE_APP_ID].remote_bda, (db+SPP_IDX_SPP_DATA_NTY_VAL)->attribute_handle);
}else if(cmd_id == SPP_IDX_SPP_STATUS_VAL){
ESP_LOGI(GATTC_TAG,"Index = %d,UUID = 0x%04x, handle = %d \n", cmd_id, (db+SPP_IDX_SPP_STATUS_VAL)->uuid.uuid.uuid16, (db+SPP_IDX_SPP_STATUS_VAL)->attribute_handle);
esp_ble_gattc_register_for_notify(spp_gattc_if, gl_profile_tab[PROFILE_APP_ID].remote_bda, (db+SPP_IDX_SPP_STATUS_VAL)->attribute_handle);
}
if(db != NULL) {
if(cmd_id == SPP_IDX_SPP_DATA_NTY_VAL){
ESP_LOGI(GATTC_TAG,"Index = %d,UUID = 0x%04x, handle = %d \n", cmd_id, (db+SPP_IDX_SPP_DATA_NTY_VAL)->uuid.uuid.uuid16, (db+SPP_IDX_SPP_DATA_NTY_VAL)->attribute_handle);
esp_ble_gattc_register_for_notify(spp_gattc_if, gl_profile_tab[PROFILE_APP_ID].remote_bda, (db+SPP_IDX_SPP_DATA_NTY_VAL)->attribute_handle);
}else if(cmd_id == SPP_IDX_SPP_STATUS_VAL){
ESP_LOGI(GATTC_TAG,"Index = %d,UUID = 0x%04x, handle = %d \n", cmd_id, (db+SPP_IDX_SPP_STATUS_VAL)->uuid.uuid.uuid16, (db+SPP_IDX_SPP_STATUS_VAL)->attribute_handle);
esp_ble_gattc_register_for_notify(spp_gattc_if, gl_profile_tab[PROFILE_APP_ID].remote_bda, (db+SPP_IDX_SPP_STATUS_VAL)->attribute_handle);
}
#ifdef SUPPORT_HEARTBEAT
else if(cmd_id == SPP_IDX_SPP_HEARTBEAT_VAL){
ESP_LOGI(GATTC_TAG,"Index = %d,UUID = 0x%04x, handle = %d \n", cmd_id, (db+SPP_IDX_SPP_HEARTBEAT_VAL)->uuid.uuid.uuid16, (db+SPP_IDX_SPP_HEARTBEAT_VAL)->attribute_handle);
esp_ble_gattc_register_for_notify(spp_gattc_if, gl_profile_tab[PROFILE_APP_ID].remote_bda, (db+SPP_IDX_SPP_HEARTBEAT_VAL)->attribute_handle);
}
else if(cmd_id == SPP_IDX_SPP_HEARTBEAT_VAL){
ESP_LOGI(GATTC_TAG,"Index = %d,UUID = 0x%04x, handle = %d \n", cmd_id, (db+SPP_IDX_SPP_HEARTBEAT_VAL)->uuid.uuid.uuid16, (db+SPP_IDX_SPP_HEARTBEAT_VAL)->attribute_handle);
esp_ble_gattc_register_for_notify(spp_gattc_if, gl_profile_tab[PROFILE_APP_ID].remote_bda, (db+SPP_IDX_SPP_HEARTBEAT_VAL)->attribute_handle);
}
#endif
}
}
}
}
@ -490,7 +496,7 @@ void spp_heart_beat_task(void * arg)
vTaskDelay(50 / portTICK_PERIOD_MS);
if(xQueueReceive(cmd_heartbeat_queue, &cmd_id, portMAX_DELAY)) {
while(1){
if((is_connect == true)&&((db+SPP_IDX_SPP_HEARTBEAT_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))){
if((is_connect == true) && (db != NULL) && ((db+SPP_IDX_SPP_HEARTBEAT_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))){
esp_ble_gattc_write_char( spp_gattc_if,
spp_conn_id,
(db+SPP_IDX_SPP_HEARTBEAT_VAL)->attribute_handle,
@ -551,7 +557,7 @@ void uart_task(void *pvParameters)
switch (event.type) {
//Event of UART receving data
case UART_DATA:
if (event.size && (is_connect == true) && ((db+SPP_IDX_SPP_DATA_RECV_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))) {
if (event.size && (is_connect == true) && (db != NULL) && ((db+SPP_IDX_SPP_DATA_RECV_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))) {
uint8_t * temp = NULL;
temp = (uint8_t *)malloc(sizeof(uint8_t)*event.size);
if(temp == NULL){

View file

@ -3,8 +3,16 @@ ESP-IDF Blufi demo
This is the demo for bluetooth config wifi connection to ap.
attentions:
1. Please use the BLEDEMO APK
2. As the GATTServer start a litte slowly, so Please Wait for a period, then use apk scan the apk util find a random address devices named Espressif_008
3. Just a unstable version..
To test this demo, you need to prepare a mobile phone with blufi application installed. You can download the blufi application from [Android version](https://github.com/EspressifApp/EspBlufi) and [iOS version](https://itunes.apple.com/cn/app/espblufi/id1450614082?mt=8).
Blufi is completely open source, here is the download link:
* [blufi source code](https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/blufi)
* [BluFi protocol](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/blufi.html?highlight=blufi#the-frame-formats-defined-in-blufi)
* [iOS source code](https://github.com/EspressifApp/EspBlufiForiOS)
* [Android source code](https://github.com/EspressifApp/EspBlufi)
* [Bluetooth Network User Guide CN](https://www.espressif.com/sites/default/files/documentation/esp32_bluetooth_networking_user_guide_cn.pdf)

View file

@ -98,7 +98,7 @@ static uint8_t adv_service_uuid128[32] = {
static esp_ble_adv_data_t adv_data = {
.set_scan_rsp = false,
.include_name = true,
.include_txpower = true,
.include_txpower = false,
.min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
.max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
.appearance = 0x00,
@ -115,8 +115,8 @@ static esp_ble_adv_data_t scan_rsp_data = {
.set_scan_rsp = true,
.include_name = true,
.include_txpower = true,
.min_interval = 0x0006,
.max_interval = 0x0010,
//.min_interval = 0x0006,
//.max_interval = 0x0010,
.appearance = 0x00,
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
.p_manufacturer_data = NULL, //&test_manufacturer[0],