Commit 8e8af9cf authored by 李俭双's avatar 李俭双

Merge branch 'revert-7b3c043b' into 'master'

Revert "🎉 init:上传工程"

See merge request !1
parents c101f340 9d933ccf
{
"idf.adapterTargetName": "esp32"
}
\ No newline at end of file
......@@ -7,4 +7,4 @@ cmake_minimum_required(VERSION 3.16)
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(tianying_ty100)
project(QJ500-7C)
# Embed the server root certificate into the final binary
idf_build_get_property(project_dir PROJECT_DIR)
idf_component_register(SRCS "gatts_table_creat_demo.c"
idf_component_register(SRCS "app_BT_User.c" "bt_app_main.c" "bt_app_hf.c" "bt_app_core.c" "gatts_table_creat_demo.c"
"simple_ota_example.c"
"Protocol_CRC16.c"
"Protocol_Lib.c"
......
......@@ -26,7 +26,7 @@
#include "MCU_Core_Protocol.h"
#include "Protocol_Lib.h"
#include "app_Ble_User.h"
// #include "app_BT_User.h"
#include "app_BT_User.h"
#include <stdint.h>
#include <string.h>
......@@ -234,10 +234,10 @@ static void Protocol_UartHandle(const Protocol_Data_t *pData)
{
// if(pData->DataLen == 33)
{
// if(BT_User.HF_Ctrl != pData->Data[0])
// {
// BT_User.HF_Ctrl = pData->Data[0];
// }
if(BT_User.HF_Ctrl != pData->Data[0])
{
BT_User.HF_Ctrl = pData->Data[0];
}
if(strncmp((const char *) ble_uerid, (const char *)&(pData->Data[1]), 32) != 0)
{
......@@ -249,7 +249,7 @@ static void Protocol_UartHandle(const Protocol_Data_t *pData)
if(Ble_User.UseridUpdate == 0)
{
// bsp_Ble_Init();
bsp_Ble_Init();
printf("get uuid and init ble!!! \r\n");
}
......@@ -318,10 +318,15 @@ void Uart_Send_Id10_Pro(void )
void Uart_Send_Id12_Pro(void )
{
uint8_t ID12[1] = {0};
// ID12[0] |= (uint8_t)(BT_User.BT_Sts << 4);
uint8_t ID12[15] = {0};
ID12[0] |= (uint8_t)(BT_User.BT_Sts << 4);
ID12[0] |= Ble_User.Ble_Sts;
Protocol_Send(0x12, ID12, 1);
unsigned int i = 0;
for(i = 0;i < 14;i++)
{
ID12[ i + 1 ] = BT_Device_Name[ i ];
}
Protocol_Send(0x12, ID12, 15);
}
void Uart_Send_Id01_Pro(void)
......@@ -345,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_Sts;
Protocol_Send(0x02, ID02, 1);
}
......
#include "app_BT_User.h"
#include <stdio.h>
#include "bt_app_hf.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "bt_app_main.h"
extern esp_bd_addr_t peer_addr;
#define TAG "APP_BLE_USER"
BT_User_Control_Struct BT_User;
#define BT_ReConn_T 3000
void BT_User_Init(void )
{
BT_User.BT_Sts = BT_Idle;
BT_User.Call_Sts = Call_Idle;
BT_User.ReconnTime = BT_ReConn_T - 500;
BT_User.HF_Ctrl = HF_Idle;
}
void BT_Connect_Event_Pro(void )
{
BT_User.BT_Sts = BT_Conn;
BT_User.Call_Sts = Call_Idle;
BT_User.ReconnTime = BT_ReConn_T - 500;
BT_User.HF_Ctrl = HF_Idle;
printf("TB CONN\r\n");
}
void BT_DisConnect_Event_Pro(void )
{
BT_User.BT_Sts = BT_Idle;
BT_User.Call_Sts = Call_Idle;
BT_User.ReconnTime = BT_ReConn_T - 500;
BT_User.HF_Ctrl = HF_Idle;
printf("TB DISCONN\r\n");
}
void BT_User_Process(void )
{
switch(BT_User.Call_Sts)
{
case Call_OutCalling:
{
if(BT_User.HF_Ctrl == HF_Reject)
{
hf_reject_handler();
}
break;
}
case Call_IncomeCalling:
{
if(BT_User.HF_Ctrl == HF_Reject)
{
hf_reject_handler();
}
else if(BT_User.HF_Ctrl == HF_Answer)
{
hf_answer_handler();
}
break;
}
case Call_InProcess:
{
if(BT_User.HF_Ctrl == HF_Reject)
{
hf_reject_handler();
}
break;
}
case Call_Idle:
{
break;
}
}
BT_User.HF_Ctrl = HF_Idle;
if(BT_User.BT_Sts == BT_Idle)
{
BT_User.ReconnTime++;
if(BT_User.ReconnTime >= BT_ReConn_T)
{
printf("Connect Start.................\n");
if(app_BT_Get_BondDev() == 1)
{
esp_hf_client_connect(peer_addr);
}
printf("Connect Over\n");
BT_User.ReconnTime = 0;
}
}
else
{
}
}
#ifndef _APP_BT_USER_H_
#define _APP_BT_USER_H_
#include <stdlib.h>
typedef enum
{
BT_Idle = 0,
BT_Conn,
}BT_Sts_Enum;
typedef enum
{
Call_Idle = 0,
Call_IncomeCalling,
Call_OutCalling,
Call_InProcess,
}Call_Sts_Enum;
typedef enum
{
HF_Idle = 0,
HF_Answer,
HF_Reject,
}Call_HF_Ctrl_Enum;
typedef struct
{
uint8_t BT_Sts;
uint8_t Call_Sts;
uint16_t ReconnTime;
uint8_t HF_Ctrl;
}BT_User_Control_Struct;
extern BT_User_Control_Struct BT_User;
void BT_Connect_Event_Pro(void );
void BT_DisConnect_Event_Pro(void );
void BT_User_Process(void );
void BT_User_Init(void );
#endif
\ No newline at end of file
......@@ -23,7 +23,7 @@ app_Ble_Rec_Data_Ctrl_Struct RecCtrl;
uint8_t Wifi_OTA_Request = 0;
uint8_t ble_key[32] = "1BJ7J8S";
uint8_t ble_uerid[33] = "tywtywtywtywtywtywtywtywtywtyw01";
uint8_t ble_uerid[32] = {0};
uint8_t ble_pwd[32] = {0};
uint8_t flavor[4] = {0x33, 0, 0, 0};
......@@ -392,7 +392,6 @@ void Ble_Msg_RequestNavi_RLY(void )
void Ble_MsgRec_Navi_Analysis(void )
{
uint32_t aaa = 0;
//Navi data
Ble_Navi_Data.Navi_Sts = BleRecData.Msg.Param[0];
Ble_Navi_Data.Navi_Turn = BleRecData.Msg.Param[1];
......@@ -402,20 +401,8 @@ void Ble_MsgRec_Navi_Analysis(void )
Ble_Navi_Data.Navi_Dte[3] = BleRecData.Msg.Param[5];
aaa = Ble_Navi_Data.Navi_Dte[3];
aaa <<= 8;
aaa |= Ble_Navi_Data.Navi_Dte[2];
aaa <<= 8;
aaa |= Ble_Navi_Data.Navi_Dte[1];
aaa <<= 8;
aaa |= Ble_Navi_Data.Navi_Dte[0];
// printf("navi sts = %x; navi turn = %d; navi dest = %ld\n", Ble_Navi_Data.Navi_Sts, Ble_Navi_Data.Navi_Turn, aaa);
// printf("Navi sts %d Navi_Turn %x Navi_Dte0 %x Navi_Dte1 %x Navi_Dte2 %x Navi_Dte3 %x\r\n",
// Ble_Navi_Data.Navi_Sts, Ble_Navi_Data.Navi_Turn, Ble_Navi_Data.Navi_Dte[0], Ble_Navi_Data.Navi_Dte[1], Ble_Navi_Data.Navi_Dte[2],Ble_Navi_Data.Navi_Dte[3]);
printf("Navi sts %d Navi_Turn %x Navi_Dte0 %x Navi_Dte1 %x Navi_Dte2 %x Navi_Dte3 %x\r\n", \
Ble_Navi_Data.Navi_Sts, Ble_Navi_Data.Navi_Turn, Ble_Navi_Data.Navi_Dte[0], Ble_Navi_Data.Navi_Dte[1], Ble_Navi_Data.Navi_Dte[2],Ble_Navi_Data.Navi_Dte[3]);
Ble_User.Navi_Updat = 1;
Ble_User.Navi_T = 0;
......
......@@ -3,7 +3,7 @@
#include <stdlib.h>
extern uint8_t ble_uerid[33];
extern uint8_t ble_uerid[32];
typedef enum
{
Ble_Idle = 0,
......
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include "freertos/xtensa_api.h"
#include "freertos/FreeRTOSConfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "bt_app_core.h"
static void bt_app_task_handler(void *arg);
static bool bt_app_send_msg(bt_app_msg_t *msg);
static void bt_app_work_dispatched(bt_app_msg_t *msg);
static QueueHandle_t bt_app_task_queue = NULL;
static TaskHandle_t bt_app_task_handle = NULL;
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback)
{
ESP_LOGD(BT_APP_CORE_TAG, "%s event 0x%x, param len %d", __func__, event, param_len);
bt_app_msg_t msg;
memset(&msg, 0, sizeof(bt_app_msg_t));
msg.sig = BT_APP_SIG_WORK_DISPATCH;
msg.event = event;
msg.cb = p_cback;
if (param_len == 0) {
return bt_app_send_msg(&msg);
} else if (p_params && param_len > 0) {
if ((msg.param = malloc(param_len)) != NULL) {
memcpy(msg.param, p_params, param_len);
/* check if caller has provided a copy callback to do the deep copy */
if (p_copy_cback) {
p_copy_cback(&msg, msg.param, p_params);
}
return bt_app_send_msg(&msg);
}
}
return false;
}
static bool bt_app_send_msg(bt_app_msg_t *msg)
{
if (msg == NULL) {
return false;
}
if (xQueueSend(bt_app_task_queue, msg, 10 / portTICK_PERIOD_MS) != pdTRUE) {
ESP_LOGE(BT_APP_CORE_TAG, "%s xQueue send failed", __func__);
return false;
}
return true;
}
static void bt_app_work_dispatched(bt_app_msg_t *msg)
{
if (msg->cb) {
msg->cb(msg->event, msg->param);
}
}
static void bt_app_task_handler(void *arg)
{
bt_app_msg_t msg;
for (;;) {
if (pdTRUE == xQueueReceive(bt_app_task_queue, &msg, (TickType_t)portMAX_DELAY)) {
ESP_LOGD(BT_APP_CORE_TAG, "%s, sig 0x%x, 0x%x", __func__, msg.sig, msg.event);
switch (msg.sig) {
case BT_APP_SIG_WORK_DISPATCH:
{
bt_app_work_dispatched(&msg);
break;
}
default:
ESP_LOGW(BT_APP_CORE_TAG, "%s, unhandled sig: %d", __func__, msg.sig);
break;
} // switch (msg.sig)
if (msg.param) {
free(msg.param);
}
}
}
}
void bt_app_task_start_up(void)
{
bt_app_task_queue = xQueueCreate(10, sizeof(bt_app_msg_t));
xTaskCreate(bt_app_task_handler, "BtAppT", 2048, NULL, configMAX_PRIORITIES - 3, &bt_app_task_handle);
return;
}
void bt_app_task_shut_down(void)
{
if (bt_app_task_handle) {
vTaskDelete(bt_app_task_handle);
bt_app_task_handle = NULL;
}
if (bt_app_task_queue) {
vQueueDelete(bt_app_task_queue);
bt_app_task_queue = NULL;
}
}
/*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#ifndef __BT_APP_CORE_H__
#define __BT_APP_CORE_H__
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#define BT_APP_CORE_TAG "BT_APP_CORE"
#define BT_APP_SIG_WORK_DISPATCH (0x01)
/**
* @brief handler for the dispatched work
*/
typedef void (* bt_app_cb_t) (uint16_t event, void *param);
/* message to be sent */
typedef struct {
uint16_t sig; /*!< signal to bt_app_task */
uint16_t event; /*!< message event id */
bt_app_cb_t cb; /*!< context switch callback */
void *param; /*!< parameter area needs to be the last */
} bt_app_msg_t;
/**
* @brief parameter deep-copy function to be customized
*/
typedef void (* bt_app_copy_cb_t) (bt_app_msg_t *msg, void *p_dest, void *p_src);
/**
* @brief work dispatcher for the application task
*/
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback);
void bt_app_task_start_up(void);
void bt_app_task_shut_down(void);
#endif /* __BT_APP_CORE_H__ */
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "esp_log.h"
#include "bt_app_core.h"
#include "bt_app_hf.h"
#include "esp_bt_main.h"
#include "esp_bt_device.h"
#include "esp_gap_bt_api.h"
#include "esp_hf_client_api.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "freertos/ringbuf.h"
#include "time.h"
#include "sys/time.h"
#include "sdkconfig.h"
#include "app_BT_User.h"
// #include "app_hf_msg_set.h"
#include "esp_console.h"
#include "argtable3/argtable3.h"
const char *c_hf_evt_str[] = {
"CONNECTION_STATE_EVT", /*!< connection state changed event */
"AUDIO_STATE_EVT", /*!< audio connection state change event */
"VR_STATE_CHANGE_EVT", /*!< voice recognition state changed */
"CALL_IND_EVT", /*!< call indication event */
"CALL_SETUP_IND_EVT", /*!< call setup indication event */
"CALL_HELD_IND_EVT", /*!< call held indicator event */
"NETWORK_STATE_EVT", /*!< network state change event */
"SIGNAL_STRENGTH_IND_EVT", /*!< signal strength indication event */
"ROAMING_STATUS_IND_EVT", /*!< roaming status indication event */
"BATTERY_LEVEL_IND_EVT", /*!< battery level indication event */
"CURRENT_OPERATOR_EVT", /*!< current operator name event */
"RESP_AND_HOLD_EVT", /*!< response and hold event */
"CLIP_EVT", /*!< Calling Line Identification notification event */
"CALL_WAITING_EVT", /*!< call waiting notification */
"CLCC_EVT", /*!< listing current calls event */
"VOLUME_CONTROL_EVT", /*!< audio volume control event */
"AT_RESPONSE", /*!< audio volume control event */
"SUBSCRIBER_INFO_EVT", /*!< subscriber information event */
"INBAND_RING_TONE_EVT", /*!< in-band ring tone settings */
"LAST_VOICE_TAG_NUMBER_EVT", /*!< requested number from AG event */
"RING_IND_EVT", /*!< ring indication event */
"PKT_STAT_EVT", /*!< requested number of packet status event */
};
// esp_hf_client_connection_state_t
const char *c_connection_state_str[] = {
"disconnected",
"connecting",
"connected",
"slc_connected",
"disconnecting",
};
// esp_hf_client_audio_state_t
const char *c_audio_state_str[] = {
"disconnected",
"connecting",
"connected",
"connected_msbc",
};
/// esp_hf_vr_state_t
const char *c_vr_state_str[] = {
"disabled",
"enabled",
};
// esp_hf_service_availability_status_t
const char *c_service_availability_status_str[] = {
"unavailable",
"available",
};
// esp_hf_roaming_status_t
const char *c_roaming_status_str[] = {
"inactive",
"active",
};
// esp_hf_client_call_state_t
const char *c_call_str[] = {
"NO call in progress",
"call in progress",
};
// esp_hf_client_callsetup_t
const char *c_call_setup_str[] = {
"NONE",
"INCOMING",
"OUTGOING_DIALING",
"OUTGOING_ALERTING"
};
// esp_hf_client_callheld_t
const char *c_call_held_str[] = {
"NONE held",
"Held and Active",
"Held",
};
// esp_hf_response_and_hold_status_t
const char *c_resp_and_hold_str[] = {
"HELD",
"HELD ACCEPTED",
"HELD REJECTED",
};
// esp_hf_client_call_direction_t
const char *c_call_dir_str[] = {
"outgoing",
"incoming",
};
// esp_hf_client_call_state_t
const char *c_call_state_str[] = {
"active",
"held",
"dialing",
"alerting",
"incoming",
"waiting",
"held_by_resp_hold",
};
// esp_hf_current_call_mpty_type_t
const char *c_call_mpty_type_str[] = {
"single",
"multi",
};
// esp_hf_volume_control_target_t
const char *c_volume_control_target_str[] = {
"SPEAKER",
"MICROPHONE"
};
// esp_hf_at_response_code_t
const char *c_at_response_code_str[] = {
"OK",
"ERROR"
"ERR_NO_CARRIER",
"ERR_BUSY",
"ERR_NO_ANSWER",
"ERR_DELAYED",
"ERR_BLACKLILSTED",
"ERR_CME",
};
// esp_hf_subscriber_service_type_t
const char *c_subscriber_service_type_str[] = {
"unknown",
"voice",
"fax",
};
// esp_hf_client_in_band_ring_state_t
const char *c_inband_ring_state_str[] = {
"NOT provided",
"Provided",
};
extern esp_bd_addr_t peer_addr;
// 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};
#if CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI
#define ESP_HFP_RINGBUF_SIZE 3600
static RingbufHandle_t m_rb = NULL;
static void bt_app_hf_client_audio_open(void)
{
m_rb = xRingbufferCreate(ESP_HFP_RINGBUF_SIZE, RINGBUF_TYPE_BYTEBUF);
}
static void bt_app_hf_client_audio_close(void)
{
if (!m_rb) {
return ;
}
vRingbufferDelete(m_rb);
}
static uint32_t bt_app_hf_client_outgoing_cb(uint8_t *p_buf, uint32_t sz)
{
if (!m_rb) {
return 0;
}
size_t item_size = 0;
uint8_t *data = xRingbufferReceiveUpTo(m_rb, &item_size, 0, sz);
if (item_size == sz) {
memcpy(p_buf, data, item_size);
vRingbufferReturnItem(m_rb, data);
return sz;
} else if (0 < item_size) {
vRingbufferReturnItem(m_rb, data);
return 0;
} else {
// data not enough, do not read
return 0;
}
}
static void bt_app_hf_client_incoming_cb(const uint8_t *buf, uint32_t sz)
{
if (! m_rb) {
return;
}
BaseType_t done = xRingbufferSend(m_rb, (uint8_t *)buf, sz, 0);
if (! done) {
ESP_LOGE(BT_HF_TAG, "rb send fail");
}
esp_hf_client_outgoing_data_ready();
}
#endif /* #if CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI */
/* callback for HF_CLIENT */
void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param)
{
if (event <= ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT) {
ESP_LOGI(BT_HF_TAG, "APP HFP event: %s", c_hf_evt_str[event]);
} else {
ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event);
}
switch (event) {
case ESP_HF_CLIENT_CONNECTION_STATE_EVT:
{
ESP_LOGI(BT_HF_TAG, "--connection state %s, peer feats 0x%"PRIx32", chld_feats 0x%"PRIx32,
c_connection_state_str[param->conn_stat.state],
param->conn_stat.peer_feat,
param->conn_stat.chld_feat);
memcpy(peer_addr,param->conn_stat.remote_bda,ESP_BD_ADDR_LEN);
if(param->conn_stat.state == 0)
{
BT_DisConnect_Event_Pro();
}
else if(param->conn_stat.state == 2)
{
BT_Connect_Event_Pro();
}
break;
}
case ESP_HF_CLIENT_AUDIO_STATE_EVT:
{
ESP_LOGI(BT_HF_TAG, "--audio state %s",
c_audio_state_str[param->audio_stat.state]);
#if CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI
if (param->audio_stat.state == ESP_HF_CLIENT_AUDIO_STATE_CONNECTED ||
param->audio_stat.state == ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC) {
esp_hf_client_register_data_callback(bt_app_hf_client_incoming_cb,
bt_app_hf_client_outgoing_cb);
bt_app_hf_client_audio_open();
} else if (param->audio_stat.state == ESP_HF_CLIENT_AUDIO_STATE_DISCONNECTED) {
bt_app_hf_client_audio_close();
}
#endif /* #if CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI */
if (param->audio_stat.state == ESP_HF_CLIENT_AUDIO_STATE_CONNECTED ||
param->audio_stat.state == ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC) {
hf_disc_audio_handler();
}
break;
}
case ESP_HF_CLIENT_BVRA_EVT:
{
ESP_LOGI(BT_HF_TAG, "--VR state %s",
c_vr_state_str[param->bvra.value]);
break;
}
case ESP_HF_CLIENT_CIND_SERVICE_AVAILABILITY_EVT:
{
ESP_LOGI(BT_HF_TAG, "--NETWORK STATE %s",
c_service_availability_status_str[param->service_availability.status]);
break;
}
case ESP_HF_CLIENT_CIND_ROAMING_STATUS_EVT:
{
ESP_LOGI(BT_HF_TAG, "--ROAMING: %s",
c_roaming_status_str[param->roaming.status]);
break;
}
case ESP_HF_CLIENT_CIND_SIGNAL_STRENGTH_EVT:
{
ESP_LOGI(BT_HF_TAG, "-- signal strength: %d",
param->signal_strength.value);
break;
}
case ESP_HF_CLIENT_CIND_BATTERY_LEVEL_EVT:
{
ESP_LOGI(BT_HF_TAG, "--battery level %d",
param->battery_level.value);
break;
}
case ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT:
{
ESP_LOGI(BT_HF_TAG, "--operator name: %s",
param->cops.name);
break;
}
case ESP_HF_CLIENT_CIND_CALL_EVT:
{
ESP_LOGI(BT_HF_TAG, "--Call indicator %s",
c_call_str[param->call.status]);
if(param->call.status == 0)
{
BT_User.Call_Sts = Call_Idle;
printf("call idle\r\n");
}
else if(param->call.status == 1)
{
BT_User.Call_Sts = Call_InProcess;
printf("call Call_InProcess\r\n");
}
break;
}
case ESP_HF_CLIENT_CIND_CALL_SETUP_EVT:
{
ESP_LOGI(BT_HF_TAG, "--Call setup indicator %s",
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;
}
case ESP_HF_CLIENT_CIND_CALL_HELD_EVT:
{
ESP_LOGI(BT_HF_TAG, "--Call held indicator %s",
c_call_held_str[param->call_held.status]);
break;
}
case ESP_HF_CLIENT_BTRH_EVT:
{
ESP_LOGI(BT_HF_TAG, "--response and hold %s",
c_resp_and_hold_str[param->btrh.status]);
break;
}
case ESP_HF_CLIENT_CLIP_EVT:
{
ESP_LOGI(BT_HF_TAG, "--clip number %s",
(param->clip.number == NULL) ? "NULL" : (param->clip.number));
break;
}
case ESP_HF_CLIENT_CCWA_EVT:
{
ESP_LOGI(BT_HF_TAG, "--call_waiting %s",
(param->ccwa.number == NULL) ? "NULL" : (param->ccwa.number));
break;
}
case ESP_HF_CLIENT_CLCC_EVT:
{
ESP_LOGI(BT_HF_TAG, "--Current call: idx %d, dir %s, state %s, mpty %s, number %s",
param->clcc.idx,
c_call_dir_str[param->clcc.dir],
c_call_state_str[param->clcc.status],
c_call_mpty_type_str[param->clcc.mpty],
(param->clcc.number == NULL) ? "NULL" : (param->clcc.number));
break;
}
case ESP_HF_CLIENT_VOLUME_CONTROL_EVT:
{
ESP_LOGI(BT_HF_TAG, "--volume_target: %s, volume %d",
c_volume_control_target_str[param->volume_control.type],
param->volume_control.volume);
break;
}
case ESP_HF_CLIENT_AT_RESPONSE_EVT:
{
ESP_LOGI(BT_HF_TAG, "--AT response event, code %d, cme %d",
param->at_response.code, param->at_response.cme);
break;
}
case ESP_HF_CLIENT_CNUM_EVT:
{
ESP_LOGI(BT_HF_TAG, "--subscriber type %s, number %s",
c_subscriber_service_type_str[param->cnum.type],
(param->cnum.number == NULL) ? "NULL" : param->cnum.number);
break;
}
case ESP_HF_CLIENT_BSIR_EVT:
{
ESP_LOGI(BT_HF_TAG, "--inband ring state %s",
c_inband_ring_state_str[param->bsir.state]);
break;
}
case ESP_HF_CLIENT_BINP_EVT:
{
ESP_LOGI(BT_HF_TAG, "--last voice tag number: %s",
(param->binp.number == NULL) ? "NULL" : param->binp.number);
break;
}
case ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT:
{
ESP_LOGE(BT_HF_TAG, "ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT: %d", event);
break;
}
default:
ESP_LOGE(BT_HF_TAG, "HF_CLIENT EVT: %d", event);
break;
}
}
#define HF_CMD_HANDLER(cmd) int hf_##cmd##_handler(void )
HF_CMD_HANDLER(conn)
{
printf("connect\n");
esp_hf_client_connect(peer_addr);
return 0;
}
HF_CMD_HANDLER(disc)
{
printf("disconnect\n");
esp_hf_client_disconnect(peer_addr);
return 0;
}
HF_CMD_HANDLER(conn_audio)
{
printf("connect audio\n");
esp_hf_client_connect_audio(peer_addr);
return 0;
}
HF_CMD_HANDLER(disc_audio)
{
printf("disconnect audio\n");
esp_hf_client_disconnect_audio(peer_addr);
return 0;
}
HF_CMD_HANDLER(query_op)
{
printf("Query operator\n");
esp_hf_client_query_current_operator_name();
return 0;
}
HF_CMD_HANDLER(answer)
{
printf("Answer call\n");
esp_hf_client_answer_call();
return 0;
}
HF_CMD_HANDLER(reject)
{
esp_err_t err;
err = esp_hf_client_reject_call();
printf("Reject call err %d\n",err);
return 0;
}
const char test_dial_num[] = "17800536969";
HF_CMD_HANDLER(dial)
{
printf("Dial number %s\n", test_dial_num);
esp_hf_client_dial(test_dial_num);
return 0;
}
HF_CMD_HANDLER(redial)
{
printf("Dial number\n");
esp_hf_client_dial(NULL);
return 0;
}
HF_CMD_HANDLER(dial_mem)
{
int index = 1;
esp_hf_client_dial_memory(index);
return 0;
}
HF_CMD_HANDLER(start_vr)
{
printf("Start voice recognition\n");
esp_hf_client_start_voice_recognition();
return 0;
}
HF_CMD_HANDLER(stop_vr)
{
printf("Stop voice recognition\n");
esp_hf_client_stop_voice_recognition();
return 0;
}
// HF_CMD_HANDLER(query_call)
// {
// printf("Query current call status\n");
// esp_hf_client_query_current_calls();
// return 0;
// }
// HF_CMD_HANDLER(retrieve_subscriber)
// {
// printf("Retrieve subscriber information\n");
// esp_hf_client_retrieve_subscriber_info();
// return 0;
// }
// HF_CMD_HANDLER(request_last_voice_tag)
// {
// printf("Request last voice tag\n");
// esp_hf_client_request_last_voice_tag_number();
// return 0;
// }
// typedef enum {
// ESP_HF_BTRH_CMD_HOLD = 0, /*!< put the incoming call on hold */
// ESP_HF_BTRH_CMD_ACCEPT = 1, /*!< accept a held incoming call */
// ESP_HF_BTRH_CMD_REJECT = 2, /*!< reject a held incoming call */
// } esp_hf_btrh_cmd_t;
HF_CMD_HANDLER(btrh)
{
int btrh = ESP_HF_BTRH_CMD_HOLD;
printf("respond and hold command: %d\n", btrh);
esp_hf_client_send_btrh_cmd(btrh);
return 0;
}
/*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#ifndef __BT_APP_HF_H__
#define __BT_APP_HF_H__
#include <stdint.h>
#include "esp_hf_client_api.h"
#define BT_HF_TAG "BT_HF"
/**
* @brief callback function for HF client
*/
void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param);
int hf_conn_handler(void );
int hf_disc_handler(void );
int hf_conn_audio_handler(void );
int hf_disc_audio_handler(void );
int hf_query_op_handler(void );
int hf_answer_handler(void );
int hf_reject_handler(void );
int hf_dial_handler(void );
int hf_redial_handler(void );
int hf_dial_mem_handler(void );
int hf_start_vr_handler(void );
int hf_stop_vr_handler(void );
#endif /* __BT_APP_HF_H__*/
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <inttypes.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "nvs.h"
#include "nvs_flash.h"
#include "esp_system.h"
#include "esp_log.h"
#include "esp_bt.h"
#include "bt_app_core.h"
#include "esp_bt_main.h"
#include "esp_bt_device.h"
#include "esp_gap_bt_api.h"
#include "esp_hf_client_api.h"
#include "bt_app_hf.h"
// #include "gpio_pcm_config.h"
#include "esp_console.h"
// #include "app_hf_msg_set.h"
#include "app_BT_User.h"
#include "gatts_table_creat_demo.h"
esp_bd_addr_t peer_addr = {0};
static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1];
static uint8_t peer_bdname_len;
int bond_dev_num;
int last_bond_dev_num = -1;
// esp_bt_gap_remove_bond_device
uint8_t app_BT_Get_BondDev(void )
{
uint8_t ret = 0;
bond_dev_num = esp_bt_gap_get_bond_device_num();
if(bond_dev_num)
{
esp_bd_addr_t *dev_list = (esp_bd_addr_t *)malloc(sizeof(esp_bd_addr_t) * bond_dev_num);
esp_bt_gap_get_bond_device_list(&bond_dev_num, dev_list);
memcpy(peer_addr, dev_list[0], 6);
if(bond_dev_num > 1)
{
for(int i=1; i<bond_dev_num; i++)
{
esp_bt_gap_remove_bond_device(dev_list[i]);
}
}
ret = 1;
}
else
{
memset(peer_addr, 0, 6);
ret = 0;
}
return ret;
}
void BT_Remove_Other_BondDev(void )
{
}
// static const char remote_device_name[] = "ESP_HFP_AG";
static bool get_name_from_eir(uint8_t *eir, char *bdname, uint8_t *bdname_len)
{
uint8_t *rmt_bdname = NULL;
uint8_t rmt_bdname_len = 0;
if (!eir) {
return false;
}
rmt_bdname = esp_bt_gap_resolve_eir_data(eir, ESP_BT_EIR_TYPE_CMPL_LOCAL_NAME, &rmt_bdname_len);
if (!rmt_bdname) {
rmt_bdname = esp_bt_gap_resolve_eir_data(eir, ESP_BT_EIR_TYPE_SHORT_LOCAL_NAME, &rmt_bdname_len);
}
if (rmt_bdname) {
if (rmt_bdname_len > ESP_BT_GAP_MAX_BDNAME_LEN) {
rmt_bdname_len = ESP_BT_GAP_MAX_BDNAME_LEN;
}
if (bdname) {
memcpy(bdname, rmt_bdname, rmt_bdname_len);
bdname[rmt_bdname_len] = '\0';
}
if (bdname_len) {
*bdname_len = rmt_bdname_len;
}
return true;
}
return false;
}
void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
{
switch (event) {
case ESP_BT_GAP_DISC_RES_EVT: {
// esp_hf_client_connect(peer_addr);
// esp_bt_gap_cancel_discovery();
// printf("event state %d\n", event);
break;
}
case ESP_BT_GAP_DISC_STATE_CHANGED_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_DISC_STATE_CHANGED_EVT");
case ESP_BT_GAP_RMT_SRVCS_EVT:
case ESP_BT_GAP_RMT_SRVC_REC_EVT:
// printf("event state %d\n", event);
break;
case ESP_BT_GAP_AUTH_CMPL_EVT: {
if (param->auth_cmpl.stat == ESP_BT_STATUS_SUCCESS) {
ESP_LOGI(BT_HF_TAG, "authentication success: %s", param->auth_cmpl.device_name);
esp_log_buffer_hex(BT_HF_TAG, param->auth_cmpl.bda, ESP_BD_ADDR_LEN);
} else {
ESP_LOGE(BT_HF_TAG, "authentication failed, status:%d", param->auth_cmpl.stat);
}
// printf("event state %d\n", event);
break;
}
case ESP_BT_GAP_PIN_REQ_EVT: {
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_PIN_REQ_EVT min_16_digit:%d", param->pin_req.min_16_digit);
if (param->pin_req.min_16_digit) {
ESP_LOGI(BT_HF_TAG, "Input pin code: 0000 0000 0000 0000");
esp_bt_pin_code_t pin_code = {0};
esp_bt_gap_pin_reply(param->pin_req.bda, true, 16, pin_code);
} else {
ESP_LOGI(BT_HF_TAG, "Input pin code: 1234");
esp_bt_pin_code_t pin_code;
pin_code[0] = '1';
pin_code[1] = '2';
pin_code[2] = '3';
pin_code[3] = '4';
esp_bt_gap_pin_reply(param->pin_req.bda, true, 4, pin_code);
}
// printf("event state %d\n", event);
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
// printf("event state %d\n", event);
break;
case ESP_BT_GAP_KEY_NOTIF_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_KEY_NOTIF_EVT passkey:%"PRIu32, param->key_notif.passkey);
// printf("event state %d\n", event);
break;
case ESP_BT_GAP_KEY_REQ_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_KEY_REQ_EVT Please enter passkey!");
// printf("event state %d\n", event);
break;
#endif
case ESP_BT_GAP_MODE_CHG_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_MODE_CHG_EVT mode:%d", param->mode_chg.mode);
// printf("event state %d\n", event);
break;
default: {
ESP_LOGI(BT_HF_TAG, "event: %d", event);
// printf("event state %d\n", event);
break;
}
}
return;
}
/* event for handler "bt_av_hdl_stack_up */
enum {
BT_APP_EVT_STACK_UP = 0,
};
/* handler for bluetooth stack enabled events */
static void bt_hf_client_hdl_stack_evt(uint16_t event, void *p_param);
void bsp_BT_Init(void)
{
/* Initialize NVS — it is used to store PHY calibration data */
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
// ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE));
esp_err_t err;
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
if ((err = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bt_controller_enable(ESP_BT_MODE_BTDM)) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bluedroid_init()) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bluedroid_enable()) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
return;
}
/* create application task */
bt_app_task_start_up();
/* Bluetooth device name, connection mode and profile set up */
bt_app_work_dispatch(bt_hf_client_hdl_stack_evt, BT_APP_EVT_STACK_UP, NULL, 0, NULL);
#if CONFIG_BT_HFP_AUDIO_DATA_PATH_PCM
/* configure the PCM interface and PINs used */
// app_gpio_pcm_io_cfg();
#endif
/* configure externel chip for acoustic echo cancellation */
#if ACOUSTIC_ECHO_CANCELLATION_ENABLE
// app_gpio_aec_io_cfg();
#endif /* ACOUSTIC_ECHO_CANCELLATION_ENABLE */
// esp_console_repl_t *repl = NULL;
// esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
// esp_console_dev_uart_config_t uart_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();
// repl_config.prompt = "hfp_hf>";
// // init console REPL environment
// ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl));
/* Register commands */
// register_hfp_hf();
// printf("\n ==================================================\n");
// printf(" | Steps to test hfp_hf |\n");
// printf(" | |\n");
// printf(" | 1. Print 'help' to gain overview of commands |\n");
// printf(" | 2. Setup a service level connection |\n");
// printf(" | 3. Run hfp_hf to test |\n");
// printf(" | |\n");
// printf(" =================================================\n\n");
// start console REPL
// ESP_ERROR_CHECK(esp_console_start_repl(repl));
}
static void bt_hf_client_hdl_stack_evt(uint16_t event, void *p_param)
{
ESP_LOGD(BT_HF_TAG, "%s evt %d", __func__, event);
switch (event) {
case BT_APP_EVT_STACK_UP: {
/* set up device name */
char *dev_name = "ESP_HFP_HF";
esp_bt_dev_set_device_name((char *)BT_Device_Name);
/* register GAP callback function */
esp_bt_gap_register_callback(esp_bt_gap_cb);
esp_hf_client_register_callback(bt_app_hf_client_cb);
esp_hf_client_init();
esp_bt_pin_type_t pin_type = ESP_BT_PIN_TYPE_FIXED;
esp_bt_pin_code_t pin_code;
pin_code[0] = '0';
pin_code[1] = '0';
pin_code[2] = '0';
pin_code[3] = '0';
esp_bt_gap_set_pin(pin_type, 4, pin_code);
/* set discoverable and connectable mode, wait to be connected */
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
/* start device discovery */
ESP_LOGI(BT_HF_TAG, "Starting device discovery...");
esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0);
break;
}
default:
ESP_LOGE(BT_HF_TAG, "%s unhandled evt %d", __func__, event);
break;
}
}
/*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#ifndef BT_APP_MAN_H
#define BT_APP_MAN_H
void bsp_BT_Init(void);
uint8_t app_BT_Get_BondDev(void );
#endif
\ No newline at end of file
......@@ -60,9 +60,9 @@ typedef struct
{
uint16_t Rxlen;
uint8_t Rxbuff[255];
} _TY_UART_Ctrl;
} _QJ_UART_Ctrl;
_TY_UART_Ctrl TY_UARTRX;
_QJ_UART_Ctrl QJ_UARTRX;
void init_Uart(void) {
const uart_config_t uart_config = {
......@@ -81,37 +81,6 @@ void init_Uart(void) {
int bsp_Uart_Send_Data(uint8_t * data , unsigned int len)
{
uint32_t aaa = 0;
if(data[4] == 0x01 && data[5] == 0x33)
{
printf("data[5] = %x ", data[5]);
printf("data[6] = %x ", data[6]);
printf("data[7] = %x ", data[7]);
printf("data[8] = %x ", data[8]);
printf("data[9] = %x ", data[9]);
printf("data[10] = %x ", data[10]);
printf("\n");
printf("navi sts data[5] = %x ", data[5]);
printf("navi turn data[6] = %d ", data[6]);
aaa = data[10];
aaa <<= 8;
aaa |= data[9];
aaa <<= 8;
aaa |= data[8];
aaa <<= 8;
aaa |= data[7];
printf("navi dest = %ld \n", aaa);
printf("\n");
printf("\n");
}
int txBytes = uart_write_bytes(UART_NUM_1, data, len);
uart_wait_tx_idle_polling(UART_NUM_1);
return txBytes;
......@@ -140,7 +109,7 @@ void bsp_Uart_Init(void )
{
init_Uart();
Protocol_KL30_Wakeup_Init();
xTaskCreatePinnedToCore(Uart_Rx_Task, "bsp_Uart", 4096, NULL, 4, NULL, 1);
xTaskCreatePinnedToCore(Uart_Rx_Task, "Ble_User", 4096, NULL, 4, NULL, 1);
}
......@@ -169,7 +138,7 @@ void simple_ota_service(void)
uint8_t BT_Device_Name[14] = "TianYingViva";
uint8_t BT_Device_Name[14] = "QJ-Viva";
#define GATTS_TABLE_TAG "GATTS_TABLE_DEMO"
......@@ -178,7 +147,7 @@ uint8_t BT_Device_Name[14] = "TianYingViva";
#define PROFILE_APP_IDX 0
#define ESP_APP_ID 0x55
#define SAMPLE_DEVICE_NAME "TianYingViva"
#define SAMPLE_DEVICE_NAME "QJ-Viva"
#define SVC_INST_ID 0
#define SVC_INST_ID1 1
......@@ -213,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,
0x0d, 0x09, 'T', 'I', 'A', 'N', 'Y', 'I', 'N', 'G', 'V', 'i', 'v', 'a',
0x08, 0x09, 'Q', 'J', '-', 'V', 'i', 'v', 'a',
// 0x08, 0x16, 0x60, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00,
};
......@@ -942,10 +911,10 @@ 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) - 5] = temp[0];
BT_Device_Name[sizeof(BT_Device_Name) - 4] = temp[1];
BT_Device_Name[sizeof(BT_Device_Name) - 3] = temp[2];
BT_Device_Name[sizeof(BT_Device_Name) - 2] = temp[3];
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];
raw_adv_data[11] = ble_mac[0];
raw_adv_data[12] = ble_mac[1];
......@@ -972,39 +941,39 @@ void bsp_Ble_Init(void)
/* Initialize NVS. */
ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
// ret = nvs_flash_init();
// if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// ESP_ERROR_CHECK(nvs_flash_erase());
// ret = nvs_flash_init();
// }
// ESP_ERROR_CHECK( ret );
// ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
ret = esp_bt_controller_init(&bt_cfg);
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
// esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
// ret = esp_bt_controller_init(&bt_cfg);
// if (ret) {
// ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
// return;
// }
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
// ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
// if (ret) {
// ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
// return;
// }
ret = esp_bluedroid_init();
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;
}
// ret = esp_bluedroid_init();
// if (ret) {
// ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
// return;
// }
ret = esp_bluedroid_enable();
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s enable bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;
}
// ret = esp_bluedroid_enable();
// if (ret) {
// ESP_LOGE(GATTS_TABLE_TAG, "%s enable bluetooth failed: %s", __func__, esp_err_to_name(ret));
// return;
// }
ret = esp_ble_gatts_register_callback(gatts_event_handler);
if (ret){
......
......@@ -79,4 +79,5 @@ extern uint8_t BT_Device_Name[14];
void Get_Mac_Init(void );
extern int bsp_Uart_Send_Data(uint8_t * data , unsigned int len);
extern uint8_t BT_Device_Name[14];
#endif
\ No newline at end of file
......@@ -12,8 +12,8 @@
#include "main_user.h"
#include "Protocol_CRC16.h"
#include "Protocol_User.h"
// #include "bt_app_main.h"
// #include "app_BT_User.h"
#include "bt_app_main.h"
#include "app_BT_User.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
......@@ -25,12 +25,12 @@
#include "MCU_Core_Protocol.h"
#include "Protocol_Lib.h"
#include "app_Ble_User.h"
// #include "app_BT_User.h"
// #include "bt_app_hf.h"
#include "app_BT_User.h"
#include "bt_app_hf.h"
#define TAG "MAIN_USER"
// extern esp_bd_addr_t peer_addr;
extern esp_bd_addr_t peer_addr;
uint32_t Sys_1ms_Cnt;
......@@ -65,7 +65,7 @@ static void Sys_Run_Tasks(void *arg)
Protocol_Send_Service();
Protocol_Service();
// BT_User_Process();
BT_User_Process();
}
if(SYS_RUN_TASK_20MS)
......@@ -93,8 +93,8 @@ static void Sys_Run_Tasks(void *arg)
{
testcnt = 0;
// printf("BT_User.BT_Sts = %d\r\n", BT_User.BT_Sts);
// printf("Ble_User.Ble_Sts = %d\r\n", Ble_User.Ble_Sts);
printf("BT_User.BT_Sts = %d\r\n", BT_User.BT_Sts);
printf("Ble_User.Ble_Sts = %d\r\n", Ble_User.Ble_Sts);
// esp_log_buffer_hex(TAG, peer_addr, 6);
......@@ -126,11 +126,11 @@ static void Sys_Run_Tasks(void *arg)
void app_main(void)
{
Protocol_User_Ctrl_Init();
// BT_User_Init();
BT_User_Init();
Ble_User_Init();
Get_Mac_Init();
// bsp_BT_Init();
bsp_Ble_Init();
bsp_BT_Init();
// bsp_Ble_Init();
bsp_Uart_Init();
printf("KL30 INIT OVER~~~~~~\r\n");
......
......@@ -308,8 +308,8 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set
# CONFIG_PARTITION_TABLE_TWO_OTA is not set
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="tianying100_partitions_two_ota.csv"
CONFIG_PARTITION_TABLE_FILENAME="tianying100_partitions_two_ota.csv"
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="QJ500_7C_partitions_two_ota.csv"
CONFIG_PARTITION_TABLE_FILENAME="QJ500_7C_partitions_two_ota.csv"
CONFIG_PARTITION_TABLE_OFFSET=0xA000
CONFIG_PARTITION_TABLE_MD5=y
# end of Partition Table
......@@ -647,16 +647,28 @@ CONFIG_BT_BLE_RPA_TIMEOUT=900
#
# Controller Options
#
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
# CONFIG_BTDM_CTRL_MODE_BLE_ONLY is not set
# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set
# CONFIG_BTDM_CTRL_MODE_BTDM is not set
CONFIG_BTDM_CTRL_MODE_BTDM=y
CONFIG_BTDM_CTRL_BLE_MAX_CONN=3
CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0
CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN=2
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN=2
# CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI is not set
CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM=y
CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=1
CONFIG_BTDM_CTRL_PCM_ROLE_EDGE_CONFIG=y
CONFIG_BTDM_CTRL_PCM_ROLE_MASTER=y
# CONFIG_BTDM_CTRL_PCM_ROLE_SLAVE is not set
CONFIG_BTDM_CTRL_PCM_POLAR_FALLING_EDGE=y
# CONFIG_BTDM_CTRL_PCM_POLAR_RISING_EDGE is not set
CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0
CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0
# CONFIG_BTDM_CTRL_AUTO_LATENCY is not set
CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT=y
CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF=y
CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=3
CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0
CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=2
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=2
CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y
# CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set
CONFIG_BTDM_CTRL_PINNED_TO_CORE=0
......@@ -2104,13 +2116,15 @@ CONFIG_BLUFI_INITIAL_TRACE_LEVEL=2
CONFIG_SMP_ENABLE=y
# CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY is not set
CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT=30
CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
# CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY is not set
# CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY is not set
# CONFIG_BTDM_CONTROLLER_MODE_BTDM is not set
CONFIG_BTDM_CONTROLLER_MODE_BTDM=y
CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN=3
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN=2
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN=2
CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=3
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=0
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=2
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=2
CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0
CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y
# CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4 is not set
......
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