Commit 00c58b72 authored by 薛小虎's avatar 薛小虎

feat: 添加电话状态

parent ac9f975a
#include "app_BT_User.h" #include "app_BT_User.h"
#include <stdio.h>
#define TAG "APP_BLE_USER" #define TAG "APP_BLE_USER"
...@@ -8,6 +9,26 @@ BT_User_Control_Struct BT_User; ...@@ -8,6 +9,26 @@ BT_User_Control_Struct BT_User;
void BT_Connect_Event_Pro(void )
{
BT_User.BT_Sts = BT_Conn;
BT_User.Call_Sts = Call_Idle;
printf("TB CONN\r\n");
}
void BT_DisConnect_Event_Pro(void )
{
BT_User.BT_Sts = BT_Idle;
BT_User.Call_Sts = Call_Idle;
printf("TB DISCONN\r\n");
}
......
...@@ -8,8 +8,6 @@ typedef enum ...@@ -8,8 +8,6 @@ typedef enum
{ {
BT_Idle = 0, BT_Idle = 0,
BT_Conn, BT_Conn,
BT_Pair,
BT_Authr,
}BT_Sts_Enum; }BT_Sts_Enum;
...@@ -18,13 +16,14 @@ typedef enum ...@@ -18,13 +16,14 @@ typedef enum
Call_Idle = 0, Call_Idle = 0,
Call_OutCalling, Call_OutCalling,
Call_IncomeCalling, Call_IncomeCalling,
Call_InProcess,
Call_Authr, Call_Authr,
}Call_Sts_Enum; }Call_Sts_Enum;
typedef struct typedef struct
{ {
uint8_t BT_Sts; uint8_t BT_Sts;
uint8_t Call_Sts;
}BT_User_Control_Struct; }BT_User_Control_Struct;
extern BT_User_Control_Struct BT_User; extern BT_User_Control_Struct BT_User;
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
#include "esp_log.h" #include "esp_log.h"
#include "bt_app_core.h" #include "bt_app_core.h"
#include "bt_app_hf.h" #include "bt_app_hf.h"
#include "esp_bt_main.h" #include "esp_bt_main.h"
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "sys/time.h" #include "sys/time.h"
#include "sdkconfig.h" #include "sdkconfig.h"
#include "app_BT_User.h"
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 */
...@@ -243,6 +245,15 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ ...@@ -243,6 +245,15 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
param->conn_stat.peer_feat, param->conn_stat.peer_feat,
param->conn_stat.chld_feat); param->conn_stat.chld_feat);
memcpy(peer_addr,param->conn_stat.remote_bda,ESP_BD_ADDR_LEN); memcpy(peer_addr,param->conn_stat.remote_bda,ESP_BD_ADDR_LEN);
if(param->conn_stat.state == 0)
{
BT_User.BT_Sts = BT_Conn;
}
else if(param->conn_stat.state == 2)
{
BT_User.BT_Sts = BT_Idle;
}
break; break;
} }
...@@ -309,6 +320,18 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ ...@@ -309,6 +320,18 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
{ {
ESP_LOGI(BT_HF_TAG, "--Call indicator %s", ESP_LOGI(BT_HF_TAG, "--Call indicator %s",
c_call_str[param->call.status]); c_call_str[param->call.status]);
if(param->call.status == 0)
{
BT_User.Call_Sts = Call_Idle;
printf("call over\r\n");
}
else if(param->call.status == 1)
{
BT_User.Call_Sts = Call_InProcess;
printf("call Call_InProcess\r\n");
}
break; break;
} }
...@@ -316,6 +339,41 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ ...@@ -316,6 +339,41 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
{ {
ESP_LOGI(BT_HF_TAG, "--Call setup indicator %s", ESP_LOGI(BT_HF_TAG, "--Call setup indicator %s",
c_call_setup_str[param->call_setup.status]); c_call_setup_str[param->call_setup.status]);
switch(param->call_setup.status)
{
case 0:
{
if(BT_User.Call_Sts == Call_IncomeCalling || BT_User.Call_Sts == Call_OutCalling)
{
BT_User.Call_Sts = Call_Idle;
printf("call idle\r\n");
}
break;
}
case 1:
{
BT_User.Call_Sts = Call_IncomeCalling;
printf("call income\r\n");
break;
}
case 2:
{
BT_User.Call_Sts = Call_OutCalling;
printf("call outcall\r\n");
break;
}
case 3:
{
BT_User.Call_Sts = Call_OutCalling;
printf("call outcall\r\n");
break;
}
}
if(param->call_setup.status == 0)
break; break;
} }
......
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