Commit 25df911a authored by wangxuhui's avatar wangxuhui

Merge branch 'chenpeng' into 'develop'

Chenpeng

See merge request !2
parents f1555e0a 991b9865
......@@ -350,7 +350,7 @@ void Uart_Send_Id01_Pro(void)
void Uart_Send_Id02_Pro(void)
{
uint8_t ID02[1] = {0x00};
ID02[0] = BT_User.Call_Sts;
ID02[0] = BT_User.Call_Fitter_sts;
Protocol_Send(0x02, ID02, 1);
}
......
......@@ -78,6 +78,22 @@ void BT_User_Process(void )
{
break;
}
// case Call_Miss:
// {
// if(BT_User.HF_Ctrl == HF_Reject)
// {
// hf_reject_handler();
// }
// break;
// }
// case Call_Hangup:
// {
// if(BT_User.HF_Ctrl == HF_Reject)
// {
// hf_reject_handler();
// }
// break;
// }
}
BT_User.HF_Ctrl = HF_Idle;
......
......@@ -17,6 +17,8 @@ typedef enum
Call_IncomeCalling,
Call_OutCalling,
Call_InProcess,
// Call_Miss,
// Call_Hangup,
}Call_Sts_Enum;
typedef enum
......@@ -32,6 +34,10 @@ typedef struct
uint8_t Call_Sts;
uint16_t ReconnTime;
uint8_t HF_Ctrl;
// char Number[11];
// char CCLC[11];
char Get_Call_Num;
char Call_Fitter_sts;
}BT_User_Control_Struct;
extern BT_User_Control_Struct BT_User;
......
......@@ -174,6 +174,7 @@ const char *c_inband_ring_state_str[] = {
};
extern esp_bd_addr_t peer_addr;
//static uint8_t call_timer;
// If you want to connect a specific device, add it's address here
// esp_bd_addr_t peer_addr = {0xac, 0x67, 0xb2, 0x53, 0x77, 0xbe};
......@@ -334,8 +335,8 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
if(param->call.status == 0)
{
BT_User.Call_Sts = Call_Idle;
// printf("call idle\r\n");
// call_timer = 0;
//printf("call Hangup\r\n");
}
else if(param->call.status == 1)
{
......@@ -357,16 +358,17 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
if(BT_User.Call_Sts == Call_IncomeCalling || BT_User.Call_Sts == Call_OutCalling)
{
BT_User.Call_Sts = Call_Idle;
// printf("call idle\r\n");
}
// BT_User.Call_Sts = Call_Idle;
// call_timer = 0;
// printf("call Miss\r\n");
break;
}
case 1:
{
BT_User.Call_Sts = Call_IncomeCalling;
// printf("call income\r\n");
//printf("call income\r\n");
break;
}
case 2:
......@@ -405,6 +407,18 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
{
ESP_LOGI(BT_HF_TAG, "--clip number %s",
(param->clip.number == NULL) ? "NULL" : (param->clip.number));
// if(param->clip.number != NULL)
// {
// for(int i = 0 ; i < 11 ; i++)
// {
// BT_User.Number[i] = param->clip.number[i];
// }
// }
// if(BT_User.Call_Sts != Call_InProcess)
// BT_User.Call_Sts = Call_IncomeCalling;
// printf("call income\r\n");
// printf("%s\n",param->clip.number);
// // printf("1\n");
break;
}
......@@ -423,7 +437,29 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
c_call_state_str[param->clcc.status],
c_call_mpty_type_str[param->clcc.mpty],
(param->clcc.number == NULL) ? "NULL" : (param->clcc.number));
break;
// if((strstr(param->clcc.number,"10000000") == NULL) && (BT_User.Call_Sts != Call_IncomeCalling) && (BT_User.Call_Sts != Call_InProcess))
// {
// if(call_timer == 7)
// {
// BT_User.Call_Sts = Call_OutCalling;
// printf("call outcall\r\n");
// printf("%s\n",param->clcc.number);
// }
// else
// {
// call_timer ++;
// }
// // call_timer ++;
// }
// else
// {
// call_timer = 0;
// }
// break;
if(strstr(param->clcc.number,"10000000") == NULL)
{
BT_User.Get_Call_Num = 1;
}
}
case ESP_HF_CLIENT_VOLUME_CONTROL_EVT:
......@@ -473,6 +509,26 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
}
}
void Get_Iphone_Fitter_callsts(void )
{
if(BT_User.Call_Sts == Call_Idle)
{
BT_User.Get_Call_Num = 0;
BT_User.Call_Fitter_sts = BT_User.Call_Sts;
}
else
{
if(BT_User.Get_Call_Num == 1)
{
BT_User.Call_Fitter_sts = BT_User.Call_Sts;
}
else
{
BT_User.Call_Fitter_sts = Call_Idle;
}
}
// printf("%d\n",BT_User.Call_Fitter_sts);
}
......
......@@ -18,7 +18,7 @@
*/
void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param);
void Get_Iphone_Fitter_callsts(void );
int hf_conn_handler(void );
int hf_disc_handler(void );
......@@ -32,6 +32,7 @@ int hf_redial_handler(void );
int hf_dial_mem_handler(void );
int hf_start_vr_handler(void );
int hf_stop_vr_handler(void );
//int hf_query_call_handler(void );
......
......@@ -138,7 +138,7 @@ void simple_ota_service(void)
uint8_t BT_Device_Name[14] = "QJ-Viva";
uint8_t BT_Device_Name[14] = "QJViva";
#define GATTS_TABLE_TAG "GATTS_TABLE_DEMO"
......@@ -182,7 +182,7 @@ static uint8_t raw_adv_data[] = {
0x02, 0x01, 0x02,
0x03, 0x03, 0x69, 0x67,
0x09, 0xff, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08, 0x09, 'Q', 'J', '-', 'V', 'i', 'v', 'a',
0x07, 0x09, 'Q', 'J', '-', 'V', 'i', 'v',
// 0x08, 0x16, 0x60, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00,
};
......@@ -240,7 +240,7 @@ static esp_ble_adv_params_t adv_params = {
.adv_int_min = 0x20,
.adv_int_max = 0x40,
.adv_type = ADV_TYPE_IND,
.own_addr_type = BLE_ADDR_TYPE_RANDOM,
.own_addr_type = BLE_ADDR_TYPE_PUBLIC,
.channel_map = ADV_CHNL_ALL,
.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};
......@@ -654,7 +654,7 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
{
switch (event) {
case ESP_GATTS_REG_EVT:{
esp_ble_gap_set_rand_addr(rand_addr);
// esp_ble_gap_set_rand_addr(rand_addr);
esp_err_t set_dev_name_ret = esp_ble_gap_set_device_name((const char *)BT_Device_Name);
if (set_dev_name_ret){
ESP_LOGE(GATTS_TABLE_TAG, "set device name failed, error code = %x", set_dev_name_ret);
......@@ -894,15 +894,55 @@ void Get_Mac_Init(void )
char temp[10] = {0};
char temp1[20] = {0};
esp_read_mac(ble_mac, ESP_MAC_BT);
// printf("%d\n",temp);
sprintf(temp, "%02X%02X", ble_mac[4], ble_mac[5]);
raw_adv_data[sizeof(raw_adv_data) - 4] = temp[0];
raw_adv_data[sizeof(raw_adv_data) - 3] = temp[1];
raw_adv_data[sizeof(raw_adv_data) - 2] = temp[2];
raw_adv_data[sizeof(raw_adv_data) - 1] = temp[3];
// sprintf(temp, "%02X%02X", ble_mac[4], ble_mac[5]);
int g;
for(g=0;g<6;g++)
{
srand ((int)ble_mac[g]);
if(g == 0)
{
temp[g] = (char)rand()%5;
}
else
{
temp[g] = (char)rand()%10;
temp[g] += 48;
}
// printf("%d ",temp[g]);
// printf("%d\n",);
//printf("%d ",ble_mac[g]);
}
// printf("\n");
if(temp[0] == 0)
{
temp[0] += 69;
}
else if(temp[0] == 1)
{
temp[0] = 70;
}
else if(temp[0] == 2)
{
temp[0] = 72;
}
else if(temp[0] == 3)
{
temp[0] = 73;
}
else if(temp[0] == 4)
{
temp[0] = 85;
}
// srand (ble_mac[0]);
raw_adv_data[sizeof(raw_adv_data) - 6] = temp[0];
raw_adv_data[sizeof(raw_adv_data) - 5] = temp[1];
raw_adv_data[sizeof(raw_adv_data) - 4] = temp[2];
raw_adv_data[sizeof(raw_adv_data) - 3] = temp[3];
raw_adv_data[sizeof(raw_adv_data) - 2] = temp[4];
raw_adv_data[sizeof(raw_adv_data) - 1] = temp[5];
// ESP_LOGW(GATTS_TABLE_TAG, "BLE_MAC IS %s : ",
// &raw_adv_data[11]);
// ESP_LOGW(GATTS_TABLE_TAG, "BLE_MAC IS %s : ",
......@@ -911,10 +951,12 @@ void Get_Mac_Init(void )
// printf("My MAC:\n");
esp_log_buffer_hex(GATTS_TABLE_TAG, ble_mac, 6);
BT_Device_Name[sizeof(BT_Device_Name) - 11] = temp[0];
BT_Device_Name[sizeof(BT_Device_Name) - 10] = temp[1];
BT_Device_Name[sizeof(BT_Device_Name) - 9] = temp[2];
BT_Device_Name[sizeof(BT_Device_Name) - 8] = temp[3];
BT_Device_Name[sizeof(BT_Device_Name) - 14] = temp[0];
BT_Device_Name[sizeof(BT_Device_Name) - 13] = temp[1];
BT_Device_Name[sizeof(BT_Device_Name) - 12] = temp[2];
BT_Device_Name[sizeof(BT_Device_Name) - 11] = temp[3];
BT_Device_Name[sizeof(BT_Device_Name) - 10] = temp[4];
BT_Device_Name[sizeof(BT_Device_Name) - 9] = temp[5];
raw_adv_data[11] = ble_mac[0];
raw_adv_data[12] = ble_mac[1];
......
......@@ -82,7 +82,9 @@ static void Sys_Run_Tasks(void *arg)
if(SYS_RUN_TASK_100MS)
{
Get_Iphone_Fitter_callsts();
Ble_MsgRec_Navi_Timeout();
esp_hf_client_query_current_calls();
}
if(SYS_RUN_TASK_1000MS)
......
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