Commit 53a60fb7 authored by 薛小虎's avatar 薛小虎

feat: 添加经典蓝牙控制电话接口;添加经典蓝牙自动重连;添加hfp不接收音频逻辑;修改串口中

parent 00c58b72
...@@ -20,6 +20,8 @@ void Uart_ID10_process(void) ...@@ -20,6 +20,8 @@ void Uart_ID10_process(void)
{ {
Protocol_Send(0x10,ID10,1); Protocol_Send(0x10,ID10,1);
} }
// printf("send 0x10 \r\n");
} }
...@@ -109,17 +111,9 @@ void Uart_ID03_process(const Protocol_Data_t *pData) ...@@ -109,17 +111,9 @@ void Uart_ID03_process(const Protocol_Data_t *pData)
void MCU_T_32(void) void MCU_SOC_Commnuication(void)
{ {
// printf("MCU_T_32!!\r\n");
Protocol_Service(); Protocol_Service();
// if(ID21_num >= 5)
// {
// ID21_num = 0;
// //ESP32需要升级
// }
} }
...@@ -9,5 +9,7 @@ extern void Uart_ID12_process(void); ...@@ -9,5 +9,7 @@ extern void Uart_ID12_process(void);
extern void Uart_ID20_process(const Protocol_Data_t *pData); extern void Uart_ID20_process(const Protocol_Data_t *pData);
extern void Uart_ID02_process(void); extern void Uart_ID02_process(void);
extern void Uart_ID03_process(const Protocol_Data_t *pData); extern void Uart_ID03_process(const Protocol_Data_t *pData);
extern void MCU_T_32(void);
void MCU_SOC_Commnuication(void);
#endif #endif
...@@ -104,7 +104,7 @@ void Ble_to_MCU(void) ...@@ -104,7 +104,7 @@ void Ble_to_MCU(void)
Protocol_uint8_t ID = 0; Protocol_uint8_t ID = 0;
if (1) if (1)
{ {
ID = 0; ID = 0x10;
} }
else else
{ {
...@@ -159,7 +159,7 @@ void Protocol_Send_Service(void) ...@@ -159,7 +159,7 @@ void Protocol_Send_Service(void)
//int i = 0; //int i = 0;
//for(i = 0;i < SendLen;i++) //for(i = 0;i < SendLen;i++)
// printf("data is %x !!!\r\n",UsartDataBuf[i]); // printf("data is %x !!!\r\n",UsartDataBuf[i]);
sendData(TX_TASK_TAG, (const char*)UsartDataBuf,SendLen); bsp_Uart_Send_Data(UsartDataBuf, SendLen);
//UART_Ch1_Send_Multiple_Byte(UsartDataBuf, SendLen);/*ESP32底层*/ //UART_Ch1_Send_Multiple_Byte(UsartDataBuf, SendLen);/*ESP32底层*/
} }
......
#include "app_BT_User.h" #include "app_BT_User.h"
#include <stdio.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" #define TAG "APP_BLE_USER"
BT_User_Control_Struct BT_User; BT_User_Control_Struct BT_User;
#define BT_ReConn_T 35
void BT_User_Init(void )
{
BT_User.BT_Sts = BT_Idle;
BT_User.Call_Sts = Call_Idle;
BT_User.ReconnTime = BT_ReConn_T - 5;
BT_User.HF_Ctrl = HF_Idle;
}
void BT_Connect_Event_Pro(void ) void BT_Connect_Event_Pro(void )
{ {
BT_User.BT_Sts = BT_Conn; BT_User.BT_Sts = BT_Conn;
BT_User.Call_Sts = Call_Idle; BT_User.Call_Sts = Call_Idle;
BT_User.ReconnTime = BT_ReConn_T - 5;
BT_User.HF_Ctrl = HF_Idle;
printf("TB CONN\r\n"); printf("TB CONN\r\n");
} }
...@@ -23,10 +35,94 @@ void BT_DisConnect_Event_Pro(void ) ...@@ -23,10 +35,94 @@ void BT_DisConnect_Event_Pro(void )
{ {
BT_User.BT_Sts = BT_Idle; BT_User.BT_Sts = BT_Idle;
BT_User.Call_Sts = Call_Idle; BT_User.Call_Sts = Call_Idle;
BT_User.ReconnTime = BT_ReConn_T - 5;
BT_User.HF_Ctrl = HF_Idle;
printf("TB DISCONN\r\n"); printf("TB DISCONN\r\n");
} }
uint32_t test_time;
void BT_User_Process(void )
{
test_time++;
if(test_time >= 6)
{
test_time = 0;
}
// printf("in %ld times\r\n", test_time);
switch(BT_User.Call_Sts)
{
case Call_OutCalling:
{
if(test_time >= 3)
{
// hf_reject_handler();
test_time = 0;
}
if(BT_User.HF_Ctrl == HF_Reject)
{
hf_reject_handler();
}
break;
}
case Call_IncomeCalling:
{
if(test_time >= 3)
{
// hf_answer_handler();
test_time = 0;
}
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(test_time >= 3)
{
// hf_reject_handler();
test_time = 0;
}
if(BT_User.HF_Ctrl == HF_Reject)
{
hf_reject_handler();
}
break;
}
}
if(BT_User.BT_Sts == BT_Idle)
{
BT_User.ReconnTime++;
printf("ReconnTime %d\r\n", BT_User.ReconnTime);
if(BT_User.ReconnTime >= BT_ReConn_T)
{
printf("Connect Start..............................\n");
app_BT_Get_BondDev();
esp_hf_client_connect(peer_addr);
printf("Connect..............................\n");
BT_User.ReconnTime = 0;
}
}
else
{
}
}
......
...@@ -17,15 +17,28 @@ typedef enum ...@@ -17,15 +17,28 @@ typedef enum
Call_OutCalling, Call_OutCalling,
Call_IncomeCalling, Call_IncomeCalling,
Call_InProcess, Call_InProcess,
Call_Authr,
}Call_Sts_Enum; }Call_Sts_Enum;
typedef enum
{
HF_Idle = 0,
HF_Reject,
HF_Answer,
}Call_HF_Ctrl_Enum;
typedef struct typedef struct
{ {
uint8_t BT_Sts; uint8_t BT_Sts;
uint8_t Call_Sts; uint8_t Call_Sts;
uint8_t ReconnTime;
uint8_t HF_Ctrl;
}BT_User_Control_Struct; }BT_User_Control_Struct;
extern BT_User_Control_Struct BT_User; 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 #endif
\ No newline at end of file
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
#include "sdkconfig.h" #include "sdkconfig.h"
#include "app_BT_User.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[] = { const char *c_hf_evt_str[] = {
"CONNECTION_STATE_EVT", /*!< connection state changed event */ "CONNECTION_STATE_EVT", /*!< connection state changed event */
...@@ -248,11 +251,11 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ ...@@ -248,11 +251,11 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
if(param->conn_stat.state == 0) if(param->conn_stat.state == 0)
{ {
BT_User.BT_Sts = BT_Conn; BT_DisConnect_Event_Pro();
} }
else if(param->conn_stat.state == 2) else if(param->conn_stat.state == 2)
{ {
BT_User.BT_Sts = BT_Idle; BT_Connect_Event_Pro();
} }
break; break;
} }
...@@ -271,6 +274,13 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ ...@@ -271,6 +274,13 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
bt_app_hf_client_audio_close(); bt_app_hf_client_audio_close();
} }
#endif /* #if CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI */ #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; break;
} }
...@@ -325,7 +335,7 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ ...@@ -325,7 +335,7 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
{ {
BT_User.Call_Sts = Call_Idle; BT_User.Call_Sts = Call_Idle;
printf("call over\r\n"); printf("call idle\r\n");
} }
else if(param->call.status == 1) else if(param->call.status == 1)
{ {
...@@ -462,3 +472,139 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ ...@@ -462,3 +472,139 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
break; 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;
}
...@@ -19,4 +19,20 @@ ...@@ -19,4 +19,20 @@
void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param); 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__*/ #endif /* __BT_APP_HF_H__*/
...@@ -25,12 +25,36 @@ ...@@ -25,12 +25,36 @@
// #include "gpio_pcm_config.h" // #include "gpio_pcm_config.h"
#include "esp_console.h" #include "esp_console.h"
// #include "app_hf_msg_set.h" // #include "app_hf_msg_set.h"
#include "app_BT_User.h"
esp_bd_addr_t peer_addr = {0}; esp_bd_addr_t peer_addr = {0};
static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; static char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1];
static uint8_t peer_bdname_len; static uint8_t peer_bdname_len;
int bond_dev_num;
int last_bond_dev_num = -1;
void app_BT_Get_BondDev(void )
{
bond_dev_num = esp_bt_gap_get_bond_device_num();
printf("dev_num %d\n", bond_dev_num);
if(last_bond_dev_num != bond_dev_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);
esp_log_buffer_hex(BT_HF_TAG, peer_addr, ESP_BD_ADDR_LEN);
}
last_bond_dev_num = bond_dev_num;
}
}
static const char remote_device_name[] = "ESP_HFP_AG";
// static const char remote_device_name[] = "ESP_HFP_AG";
static bool get_name_from_eir(uint8_t *eir, char *bdname, uint8_t *bdname_len) static bool get_name_from_eir(uint8_t *eir, char *bdname, uint8_t *bdname_len)
{ {
...@@ -68,26 +92,16 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) ...@@ -68,26 +92,16 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
{ {
switch (event) { switch (event) {
case ESP_BT_GAP_DISC_RES_EVT: { case ESP_BT_GAP_DISC_RES_EVT: {
for (int i = 0; i < param->disc_res.num_prop; i++){ // esp_hf_client_connect(peer_addr);
if (param->disc_res.prop[i].type == ESP_BT_GAP_DEV_PROP_EIR // esp_bt_gap_cancel_discovery();
&& get_name_from_eir(param->disc_res.prop[i].val, peer_bdname, &peer_bdname_len)){ printf("event state %d\n", event);
if (strcmp(peer_bdname, remote_device_name) == 0) {
memcpy(peer_addr, param->disc_res.bda, ESP_BD_ADDR_LEN);
ESP_LOGI(BT_HF_TAG, "Found a target device address: \n");
esp_log_buffer_hex(BT_HF_TAG, peer_addr, ESP_BD_ADDR_LEN);
ESP_LOGI(BT_HF_TAG, "Found a target device name: %s", peer_bdname);
printf("Connect.\n");
esp_hf_client_connect(peer_addr);
esp_bt_gap_cancel_discovery();
}
}
}
break; break;
} }
case ESP_BT_GAP_DISC_STATE_CHANGED_EVT: case ESP_BT_GAP_DISC_STATE_CHANGED_EVT:
ESP_LOGI(BT_HF_TAG, "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_SRVCS_EVT:
case ESP_BT_GAP_RMT_SRVC_REC_EVT: case ESP_BT_GAP_RMT_SRVC_REC_EVT:
printf("event state %d\n", event);
break; break;
case ESP_BT_GAP_AUTH_CMPL_EVT: { case ESP_BT_GAP_AUTH_CMPL_EVT: {
if (param->auth_cmpl.stat == ESP_BT_STATUS_SUCCESS) { if (param->auth_cmpl.stat == ESP_BT_STATUS_SUCCESS) {
...@@ -96,6 +110,8 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) ...@@ -96,6 +110,8 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
} else { } else {
ESP_LOGE(BT_HF_TAG, "authentication failed, status:%d", param->auth_cmpl.stat); ESP_LOGE(BT_HF_TAG, "authentication failed, status:%d", param->auth_cmpl.stat);
} }
printf("event state %d\n", event);
break; break;
} }
case ESP_BT_GAP_PIN_REQ_EVT: { case ESP_BT_GAP_PIN_REQ_EVT: {
...@@ -113,6 +129,8 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) ...@@ -113,6 +129,8 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
pin_code[3] = '4'; pin_code[3] = '4';
esp_bt_gap_pin_reply(param->pin_req.bda, true, 4, pin_code); esp_bt_gap_pin_reply(param->pin_req.bda, true, 4, pin_code);
} }
printf("event state %d\n", event);
break; break;
} }
...@@ -120,21 +138,27 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) ...@@ -120,21 +138,27 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
case ESP_BT_GAP_CFM_REQ_EVT: 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_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); esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
printf("event state %d\n", event);
break; break;
case ESP_BT_GAP_KEY_NOTIF_EVT: case ESP_BT_GAP_KEY_NOTIF_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_KEY_NOTIF_EVT passkey:%"PRIu32, param->key_notif.passkey); ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_KEY_NOTIF_EVT passkey:%"PRIu32, param->key_notif.passkey);
printf("event state %d\n", event);
break; break;
case ESP_BT_GAP_KEY_REQ_EVT: case ESP_BT_GAP_KEY_REQ_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_KEY_REQ_EVT Please enter passkey!"); ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_KEY_REQ_EVT Please enter passkey!");
printf("event state %d\n", event);
break; break;
#endif #endif
case ESP_BT_GAP_MODE_CHG_EVT: case ESP_BT_GAP_MODE_CHG_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_MODE_CHG_EVT mode:%d", param->mode_chg.mode); ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_MODE_CHG_EVT mode:%d", param->mode_chg.mode);
printf("event state %d\n", event);
break; break;
default: { default: {
ESP_LOGI(BT_HF_TAG, "event: %d", event); ESP_LOGI(BT_HF_TAG, "event: %d", event);
printf("event state %d\n", event);
break; break;
} }
} }
...@@ -149,7 +173,7 @@ enum { ...@@ -149,7 +173,7 @@ enum {
/* handler for bluetooth stack enabled events */ /* handler for bluetooth stack enabled events */
static void bt_hf_client_hdl_stack_evt(uint16_t event, void *p_param); static void bt_hf_client_hdl_stack_evt(uint16_t event, void *p_param);
void bt_app_main_init(void) void bsp_BT_Init(void)
{ {
/* Initialize NVS — it is used to store PHY calibration data */ /* Initialize NVS — it is used to store PHY calibration data */
esp_err_t ret = nvs_flash_init(); esp_err_t ret = nvs_flash_init();
......
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
#ifndef BT_APP_MAN_H #ifndef BT_APP_MAN_H
#define BT_APP_MAN_H #define BT_APP_MAN_H
void bt_app_main_init(void); void bsp_BT_Init(void);
void app_BT_Get_BondDev(void );
#endif #endif
\ No newline at end of file
...@@ -79,7 +79,7 @@ void init_Uart(void) { ...@@ -79,7 +79,7 @@ void init_Uart(void) {
uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
} }
int sendData(const char* logName, const char* data , unsigned int len) int bsp_Uart_Send_Data(uint8_t * data , unsigned int len)
{ {
// const int len = strlen(data); // const int len = strlen(data);
const int txBytes = uart_write_bytes(UART_NUM_1, data, len); const int txBytes = uart_write_bytes(UART_NUM_1, data, len);
...@@ -94,25 +94,16 @@ static void rx_task(void *arg) ...@@ -94,25 +94,16 @@ static void rx_task(void *arg)
static const char *RX_TASK_TAG = "RX_TASK"; static const char *RX_TASK_TAG = "RX_TASK";
esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO); esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO);
uint8_t* data = (uint8_t*) malloc(RX_BUF_SIZE+1); uint8_t* data = (uint8_t*) malloc(RX_BUF_SIZE+1);
while (1) { while (1)
{
const int rxBytes = uart_read_bytes(UART_NUM_1, data, RX_BUF_SIZE, 10 / portTICK_PERIOD_MS); const int rxBytes = uart_read_bytes(UART_NUM_1, data, RX_BUF_SIZE, portMAX_DELAY);
if (rxBytes < 255) if (rxBytes < 1000)
{
QJ_UARTRX.Rxlen = rxBytes;
// printf("CPY!!\r\n");
memcpy(QJ_UARTRX.Rxbuff, data, rxBytes);
}
for (uint16_t i = 0; i < QJ_UARTRX.Rxlen; i++)
{ {
UART_Put(QJ_UARTRX.Rxbuff[i]); for (uint16_t i = 0; i < rxBytes; i++)
} {
if (rxBytes > 0) { UART_Put(data[i]);
data[rxBytes] = 0; }
//ESP_LOGI(RX_TASK_TAG, "Read %d bytes: '%s'", rxBytes, data);
//ESP_LOG_BUFFER_HEXDUMP(RX_TASK_TAG, data, rxBytes, ESP_LOG_INFO);
} }
MCU_T_32();
} }
free(data); free(data);
} }
......
...@@ -76,5 +76,5 @@ int bsp_Ble_Gatts_Send_Indicate(uint8_t len, uint8_t *data); ...@@ -76,5 +76,5 @@ int bsp_Ble_Gatts_Send_Indicate(uint8_t len, uint8_t *data);
void simple_ota_service(void); void simple_ota_service(void);
extern int sendData(const char* logName, const char* data , unsigned int len); extern int bsp_Uart_Send_Data(uint8_t * data , unsigned int len);
#endif #endif
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "Protocol_CRC16.h" #include "Protocol_CRC16.h"
#include "Protocol_User.h" #include "Protocol_User.h"
#include "bt_app_main.h" #include "bt_app_main.h"
#include "app_BT_User.h"
#define TAG "MAIN_USER" #define TAG "MAIN_USER"
...@@ -51,7 +52,7 @@ static void Sys_Run_Tasks(void *arg) ...@@ -51,7 +52,7 @@ static void Sys_Run_Tasks(void *arg)
if(SYS_RUN_TASK_10MS) if(SYS_RUN_TASK_10MS)
{ {
Protocol_Send_Service();
} }
if(SYS_RUN_TASK_20MS) if(SYS_RUN_TASK_20MS)
...@@ -71,6 +72,10 @@ static void Sys_Run_Tasks(void *arg) ...@@ -71,6 +72,10 @@ static void Sys_Run_Tasks(void *arg)
if(SYS_RUN_TASK_1000MS) if(SYS_RUN_TASK_1000MS)
{ {
BT_User_Process();
simple_ota_service();
Protocol_Send_Service();
testcnt++; testcnt++;
if(testcnt >= 5) if(testcnt >= 5)
{ {
...@@ -84,11 +89,7 @@ static void Sys_Run_Tasks(void *arg) ...@@ -84,11 +89,7 @@ static void Sys_Run_Tasks(void *arg)
// Ble_Msg_RequestNavi_RLY(); // Ble_Msg_RequestNavi_RLY();
} }
simple_ota_service();
} }
vTaskDelay(1); vTaskDelay(1);
...@@ -98,8 +99,10 @@ static void Sys_Run_Tasks(void *arg) ...@@ -98,8 +99,10 @@ static void Sys_Run_Tasks(void *arg)
void app_main(void) void app_main(void)
{ {
bt_app_main_init(); BT_User_Init();
Ble_User_Init(); Ble_User_Init();
bsp_BT_Init();
bsp_Ble_Init(); bsp_Ble_Init();
bsp_Uart_Init(); bsp_Uart_Init();
......
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