Commit 2429b9a8 authored by 时昊's avatar 时昊

11

parent 79378b94
...@@ -326,9 +326,11 @@ void Uart_Send_Id12_Pro(void )//收到底板回复的0x20后,发送蓝牙类型 ...@@ -326,9 +326,11 @@ void Uart_Send_Id12_Pro(void )//收到底板回复的0x20后,发送蓝牙类型
Protocol_Send(0x12, ID12, 3); Protocol_Send(0x12, ID12, 3);
} }
extern uint8_t ID01[64];
extern uint8_t ID01_Len;
void Uart_Send_Id01_Pro(void) void Uart_Send_Id01_Pro(void)
{ {
uint8_t ID01[7] = {0x00,0x00,0x00,0x00,0x00,0x00}; uint8_t i = 0;
//if(Ble_User.Tpms_Updat) //if(Ble_User.Tpms_Updat)
{ {
// ID01[0] = Ble_Tpms_Data.Tpms_Sts; // ID01[0] = Ble_Tpms_Data.Tpms_Sts;
...@@ -337,17 +339,25 @@ void Uart_Send_Id01_Pro(void) ...@@ -337,17 +339,25 @@ void Uart_Send_Id01_Pro(void)
// ID01[3] = Ble_Tpms_Data.Tpms_Dte[1]; // ID01[3] = Ble_Tpms_Data.Tpms_Dte[1];
// ID01[4] = Ble_Tpms_Data.Tpms_Dte[2]; // ID01[4] = Ble_Tpms_Data.Tpms_Dte[2];
// ID01[5] = Ble_Tpms_Data.Tpms_Dte[3]; // ID01[5] = Ble_Tpms_Data.Tpms_Dte[3];
ID01[0] = 0xFF;//胎压状态 // printf("ID01_Len = %d\r\n",ID01_Len);
ID01[1] = 1;//前轮高字节气压值 for(i = 0; i < ID01_Len; i++)
ID01[2] = 200;//前轮低字节气压值 {
ID01[3] = 0x28;//前轮胎压温度 //ID01[i] = scan_result->scan_rst.ble_adv[i];
ID01[4] = 1;//后轮高字节气压值 printf("胎压数据:%x \r\n",ID01[i]);
ID01[5] = 45;//后轮低字节气压值 }
ID01[6] = 0xAB;//后轮胎压温度 // printf("胎压标定:%x \r\n",ID01[11]);
//printf("转向编码:%d\r\n",Ble_Tpms_Data.Tpms_Turn); // ID01[0] = 0xFF;//胎压状态
// ID01[1] = 1;//前轮高字节气压值
// ID01[2] = 200;//前轮低字节气压值
// ID01[3] = 0x28;//前轮胎压温度
// ID01[4] = 1;//后轮高字节气压值
// ID01[5] = 45;//后轮低字节气压值
// ID01[6] = 0xAB;//后轮胎压温度
//
} }
Protocol_Send(0x01,ID01,7); Protocol_Send(0x01,ID01,ID01_Len);
} }
...@@ -370,7 +380,7 @@ void Prot_Send_Msg_Process(void ) ...@@ -370,7 +380,7 @@ void Prot_Send_Msg_Process(void )
// printf("send 0x10 \r\n"); // printf("send 0x10 \r\n");
} }
//printf("Prot_User.State = %d\r\n",Prot_User.State); // printf("Prot_User.State = %d\r\n",Prot_User.State);
if(Prot_User.State >= Prot_Start)//收到底板发送的0x20后,才执行 if(Prot_User.State >= Prot_Start)//收到底板发送的0x20后,才执行
{ {
if(Prot_User.TimeDelay == 0) if(Prot_User.TimeDelay == 0)
...@@ -384,7 +394,7 @@ void Prot_Send_Msg_Process(void ) ...@@ -384,7 +394,7 @@ void Prot_Send_Msg_Process(void )
Uart_Send_Id01_Pro(); Uart_Send_Id01_Pro();
Uart_Send_Id02_Pro(); Uart_Send_Id02_Pro();
Prot_User.TimeDelay = 0; Prot_User.TimeDelay = 0;
//printf("send 0x01 0x02 \r\n"); printf("send 0x01 0x02 \r\n");
} }
} }
} }
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#include "esp_console.h" #include "esp_console.h"
#include "argtable3/argtable3.h" #include "argtable3/argtable3.h"
uint8_t Iphone_Num[20] = {0xff};
const char *c_hf_evt_str[] = { const char *c_hf_evt_str[] = {
"CONNECTION_STATE_EVT", /*!< connection state changed event */ "CONNECTION_STATE_EVT", /*!< connection state changed event */
"AUDIO_STATE_EVT", /*!< audio connection state change event */ "AUDIO_STATE_EVT", /*!< audio connection state change event */
...@@ -403,8 +406,29 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ ...@@ -403,8 +406,29 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
case ESP_HF_CLIENT_CLIP_EVT: case ESP_HF_CLIENT_CLIP_EVT:
{ {
memset(Iphone_Num, 0xff, sizeof(Iphone_Num));
ESP_LOGI(BT_HF_TAG, "--clip number %s", ESP_LOGI(BT_HF_TAG, "--clip number %s",
(param->clip.number == NULL) ? "NULL" : (param->clip.number)); (param->clip.number == NULL) ? "NULL" : param->clip.number);
if (param->clip.number == NULL)
{
;
}
else
{
size_t number_length = strlen(param->clip.number);
if (number_length > 20) {
number_length = 20;
}
memcpy(Iphone_Num, param->clip.number, number_length);
for (int i = 0; i < sizeof(Iphone_Num); i++)
{
// 0xcf 为无效值不显示
ESP_LOGI(BT_HF_TAG, "--iphone number %x", Iphone_Num[i] - 0x30);
}
}
break; break;
} }
...@@ -605,6 +629,13 @@ HF_CMD_HANDLER(btrh) ...@@ -605,6 +629,13 @@ HF_CMD_HANDLER(btrh)
uint8_t *Get_IphoneNum(void)
{
return Iphone_Num;
}
...@@ -322,10 +322,13 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ ...@@ -322,10 +322,13 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
} }
//GAP层 这些事件可能包括设备扫描结果、连接状态变化、认证请求等。 //GAP层 这些事件可能包括设备扫描结果、连接状态变化、认证请求等。
uint8_t ID01[64] = {0};
uint8_t ID01_Len = 0;
static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{ {
uint8_t *adv_name = NULL; uint8_t *adv_name = NULL;
uint8_t adv_name_len = 0; uint8_t adv_name_len = 0;
uint8_t i = 0;
switch (event) { switch (event) {
case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: {//BLE 扫描参数设置操作已经完成 case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: {//BLE 扫描参数设置操作已经完成
//the unit of the duration is second //the unit of the duration is second
...@@ -347,15 +350,50 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par ...@@ -347,15 +350,50 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
switch (scan_result->scan_rst.search_evt) switch (scan_result->scan_rst.search_evt)
{ {
case ESP_GAP_SEARCH_INQ_RES_EVT://用于在设备执行蓝牙扫描时报告发现的结果。在扫描过程中发现一个或多个BLE设备时,会触发这个事件 case ESP_GAP_SEARCH_INQ_RES_EVT://用于在设备执行蓝牙扫描时报告发现的结果。在扫描过程中发现一个或多个BLE设备时,会触发这个事件
esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6);//尤其是当你需要查看设备地址、UUID ,Mac地址。 //esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6);//尤其是当你需要查看设备地址、UUID ,Mac地址。
if(scan_result->scan_rst.bda[4] == 0x22) if(scan_result->scan_rst.bda[4] == 0x22)
{ {
esp_log_buffer_hex("1111111111111111111111111111111111111",scan_result->scan_rst.ble_adv,scan_result->scan_rst.adv_data_len); esp_log_buffer_hex("1111111111111111111111111111111111111",scan_result->scan_rst.ble_adv,scan_result->scan_rst.adv_data_len);
ESP_LOGI(GATTC_TAG, "searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len); //ESP_LOGI(GATTC_TAG, "searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len);
adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv,ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len); //adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv,ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
ESP_LOGI(GATTC_TAG, "searched Device Name Len %d", adv_name_len); //ESP_LOGI(GATTC_TAG, "searched Device Name Len %d", adv_name_len);
esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len); //esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len);
//printf("scan_result->scan_rst.adv_data_len = %d\r\n",scan_result->scan_rst.adv_data_len);
//tpms名字
printf("222222222222222222222222222222222 = %x \r\n",scan_result->scan_rst.ble_adv[2]);
printf("333333333333333333333333333333333 = %x \r\n",scan_result->scan_rst.ble_adv[3]);
printf("444444444444444444444444444444444 = %x \r\n",scan_result->scan_rst.ble_adv[4]);
printf("555555555555555555555555555555555 = %x \r\n",scan_result->scan_rst.ble_adv[5]);
printf("666666666666666666666666666666666 = %x \r\n",scan_result->scan_rst.ble_adv[6]);
printf("777777777777777777777777777777777 = %x \r\n",scan_result->scan_rst.ble_adv[7]);
printf("888888888888888888888888888888888 = %x \r\n",scan_result->scan_rst.ble_adv[8]);
//mac
printf("16 = %x \r\n",scan_result->scan_rst.ble_adv[16]);
printf("17 = %x \r\n",scan_result->scan_rst.ble_adv[17]);
printf("18 = %x \r\n",scan_result->scan_rst.ble_adv[18]);
printf("19 = %x \r\n",scan_result->scan_rst.ble_adv[19]);
printf("20 = %x \r\n",scan_result->scan_rst.ble_adv[20]);
printf("21 = %x \r\n",scan_result->scan_rst.ble_adv[21]);
if((scan_result->scan_rst.ble_adv[2] == 0x54)&&
(scan_result->scan_rst.ble_adv[3] == 0x43)&&
(scan_result->scan_rst.ble_adv[4] == 0x2E)&&
(scan_result->scan_rst.ble_adv[5] == 0x54)&&
(scan_result->scan_rst.ble_adv[6] == 0x50)&&
(scan_result->scan_rst.ble_adv[7] == 0x4D)&&
(scan_result->scan_rst.ble_adv[8] == 0x53))
{
//printf("99999999999999999999999999 \r\n");
ID01_Len = scan_result->scan_rst.adv_data_len;
for(i = 0; i < scan_result->scan_rst.adv_data_len; i++)
{
ID01[i] = scan_result->scan_rst.ble_adv[i];
}
}
} }
#if CONFIG_EXAMPLE_DUMP_ADV_DATA_AND_SCAN_RESP #if CONFIG_EXAMPLE_DUMP_ADV_DATA_AND_SCAN_RESP
...@@ -368,7 +406,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par ...@@ -368,7 +406,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
esp_log_buffer_hex(GATTC_TAG, &scan_result->scan_rst.ble_adv[scan_result->scan_rst.adv_data_len], scan_result->scan_rst.scan_rsp_len); esp_log_buffer_hex(GATTC_TAG, &scan_result->scan_rst.ble_adv[scan_result->scan_rst.adv_data_len], scan_result->scan_rst.scan_rsp_len);
} }
#endif #endif
ESP_LOGI(GATTC_TAG, "\n"); //ESP_LOGI(GATTC_TAG, "\n");
if (adv_name != NULL) { if (adv_name != NULL) {
if (strlen(remote_device_name) == adv_name_len && strncmp((char *)adv_name, remote_device_name, adv_name_len) == 0) { if (strlen(remote_device_name) == adv_name_len && strncmp((char *)adv_name, remote_device_name, adv_name_len) == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment