Commit 74238459 authored by 李秉薇's avatar 李秉薇

feat:解决冲突

parents c9441ce6 a2e830ab
# Embed the server root certificate into the final binary # Embed the server root certificate into the final binary "simple_ota_example.c"
idf_build_get_property(project_dir PROJECT_DIR) idf_build_get_property(project_dir PROJECT_DIR)
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" 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_CRC16.c"
"Protocol_Lib.c" "Protocol_Lib.c"
"Protocol_User.c" "Protocol_User.c"
......
...@@ -210,6 +210,8 @@ static Protocol_uint32_t Protocol_UartSend(const Protocol_uint8_t *pData, Protoc ...@@ -210,6 +210,8 @@ static Protocol_uint32_t Protocol_UartSend(const Protocol_uint8_t *pData, Protoc
return 0; return 0;
} }
extern void wifiServiceStart(void);
uint32_t SwitchMode=0;
static void Protocol_UartHandle(const Protocol_Data_t *pData)//esp接收底板数据 static void Protocol_UartHandle(const Protocol_Data_t *pData)//esp接收底板数据
{ {
if ( pData->CmdID == 0x20 )//收到底板发送的数据后,传状态 if ( pData->CmdID == 0x20 )//收到底板发送的数据后,传状态
...@@ -269,7 +271,9 @@ static void Protocol_UartHandle(const Protocol_Data_t *pData)//esp接收底板 ...@@ -269,7 +271,9 @@ static void Protocol_UartHandle(const Protocol_Data_t *pData)//esp接收底板
if(Wifi_OTA_Request == 0) if(Wifi_OTA_Request == 0)
{ {
Wifi_OTA_Request = 1; Wifi_OTA_Request = 1;
printf("get ota req! \r\n"); printf("收到进入OTA指令 \r\n");
SwitchMode=1;
wifiServiceStart();
} }
// } // }
} }
...@@ -319,15 +323,12 @@ void Uart_Send_Id10_Pro(void )//esp32发送启动完成给底板 ...@@ -319,15 +323,12 @@ void Uart_Send_Id10_Pro(void )//esp32发送启动完成给底板
void Uart_Send_Id12_Pro(void )//收到底板回复的0x20后,发送蓝牙类型 ID12[0]是判断蓝牙是否连接 不等于0是连接 void Uart_Send_Id12_Pro(void )//收到底板回复的0x20后,发送蓝牙类型 ID12[0]是判断蓝牙是否连接 不等于0是连接
{ {
uint8_t ID12[15] = {0}; uint8_t ID12[3] = {0};
ID12[0] |= (uint8_t)(BT_User.BT_Sts << 4);//经典 ID12[0] |= (uint8_t)(BT_User.BT_Sts << 4);//经典
ID12[0] |= Ble_User.Ble_Sts;//ble ID12[0] |= Ble_User.Ble_Sts;//ble
unsigned int i = 0; ID12[1] = 22; //小时
for(i = 0;i < 14;i++) ID12[2] = 22; //分钟
{ Protocol_Send(0x12, ID12, 3);
ID12[ i + 1 ] = BT_Device_Name[ i ];
}
Protocol_Send(0x12, ID12, 15);
} }
void Uart_Send_Id01_Pro(void) void Uart_Send_Id01_Pro(void)
......
...@@ -28,4 +28,102 @@ void Protocol_User_Ctrl_Init(void ); ...@@ -28,4 +28,102 @@ void Protocol_User_Ctrl_Init(void );
void Prot_Send_Msg_Process(void ); void Prot_Send_Msg_Process(void );
Protocol_uint32_t CalcCrc32(Protocol_uint8_t buf[], int Len); Protocol_uint32_t CalcCrc32(Protocol_uint8_t buf[], int Len);
#ifdef UPGRADE_N32G031
#define CMD_SET_BR 0x01//设置串口波特率
#define CMD_GET_INF 0x10//读取芯片型号索引、BOOT 版本号、芯片 ID
#define CMD_FLASH_ERASE 0x30//擦除 FLASH
#define CMD_FLASH_DWNLD 0x31//下载用户程序到 FLASH
#define CMD_DATA_CRC_CHECK 0x32//CRC 校验下载用户程
#define CMD_OPT_RW 0x40//读取/配置选项字节(包含了读保护等级、FLASH 页写保护、Data0/1 配置等)
#define CMD_SYS_RESET 0x50//系统复位
#define CMD_APP_GO 0x51//跳转到用户区执行程序
typedef struct
{
Protocol_uint8_t CMDH; //宏定义所包含的
Protocol_uint8_t CMDL;
Protocol_uint16_t LEN; //不关心发送的端格式
Protocol_uint8_t PAR[4];//需要处理好段格式
Protocol_uint8_t DAT[160];//补充的数据直接补充好再传到下层
}UpdateProtocolStructure;//上层协议数据结构
typedef struct
{
Protocol_uint8_t CMDH ;
Protocol_uint8_t CMDL ;
Protocol_uint8_t LEN[2];
union
{
Protocol_uint8_t DAT[128];
struct
{
Protocol_uint8_t unused_0 :8;
Protocol_uint8_t BootVer :8;
Protocol_uint8_t BootCmdVer :8;
Protocol_uint8_t UCID [16];
Protocol_uint8_t ChipID_UID [12];
Protocol_uint8_t DBGMCU_IDCODE[4];
Protocol_uint8_t Other [16];
Protocol_uint8_t CR1 :8;
Protocol_uint8_t CR2 :8;
}Chipinf;
struct
{
Protocol_uint8_t CR1 :8;
Protocol_uint8_t CR2 :8;
}Erase;
struct
{
Protocol_uint8_t CR1 :8;
Protocol_uint8_t CR2 :8;
}download;
struct
{
Protocol_uint8_t CR1 :8;
Protocol_uint8_t CR2 :8;
}verification;
struct
{
Protocol_uint8_t CR1 :8;
Protocol_uint8_t CR2 :8;
}reset;
struct
{
Protocol_uint8_t CR1 :8;
Protocol_uint8_t CR2 :8;
}appgo;
struct
{
struct Protocol_Lib
{
Protocol_uint8_t RDP ;
Protocol_uint8_t nRDP ;
Protocol_uint8_t USER ;
Protocol_uint8_t nUSER ;
Protocol_uint8_t Data0;
Protocol_uint8_t nData0;
Protocol_uint8_t Data1;
Protocol_uint8_t nData1;
Protocol_uint8_t WRP0;
Protocol_uint8_t nWRP0;
Protocol_uint8_t WRP1;
Protocol_uint8_t nWRP1;
Protocol_uint8_t RDP2;
Protocol_uint8_t nRDP2;
Protocol_uint8_t Reserved;
Protocol_uint8_t nReserved;
}optionbyte;
Protocol_uint8_t CR1 :8;
Protocol_uint8_t CR2 :8;
}flashOpt;
}dat;
}N32G031_ACK_Structure;//下层应答协议
extern N32G031_ACK_Structure N32G031_ACK;
Protocol_uint32_t UpdateN32G031Protocol_Send(UpdateProtocolStructure SendPd);
Protocol_uint32_t UpdateN32G031Protocol_Parse(const Protocol_uint8_t *pData, Protocol_uint32_t len);
#endif
#endif #endif
...@@ -503,6 +503,8 @@ void Ble_User_Task(void *pvParameter) ...@@ -503,6 +503,8 @@ void Ble_User_Task(void *pvParameter)
vTaskDelete(NULL); vTaskDelete(NULL);
} }
TaskHandle_t Ble_User_Task_hdl=NULL;
void Ble_User_Init(void ) void Ble_User_Init(void )
{ {
BleRecSuc_Semaphore = xSemaphoreCreateBinary(); BleRecSuc_Semaphore = xSemaphoreCreateBinary();
...@@ -529,6 +531,5 @@ void Ble_User_Init(void ) ...@@ -529,6 +531,5 @@ void Ble_User_Init(void )
Ble_Clear_Rx_Buffer(); Ble_Clear_Rx_Buffer();
xTaskCreatePinnedToCore(Ble_User_Task, "Ble_User", 4096, NULL, 10, NULL, 0); xTaskCreatePinnedToCore(Ble_User_Task, "Ble_User", 4096, NULL, 10, Ble_User_Task_hdl, 0);
} }
...@@ -19,8 +19,8 @@ static void bt_app_task_handler(void *arg); ...@@ -19,8 +19,8 @@ static void bt_app_task_handler(void *arg);
static bool bt_app_send_msg(bt_app_msg_t *msg); static bool bt_app_send_msg(bt_app_msg_t *msg);
static void bt_app_work_dispatched(bt_app_msg_t *msg); static void bt_app_work_dispatched(bt_app_msg_t *msg);
static QueueHandle_t bt_app_task_queue = NULL; QueueHandle_t bt_app_task_queue = NULL;
static TaskHandle_t bt_app_task_handle = NULL; 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) 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)
{ {
......
...@@ -104,12 +104,12 @@ static void Uart_Rx_Task(void *arg) ...@@ -104,12 +104,12 @@ static void Uart_Rx_Task(void *arg)
} }
free(data); free(data);
} }
TaskHandle_t Uart_Rx_Taskhdl;
void bsp_Uart_Init(void ) void bsp_Uart_Init(void )
{ {
init_Uart(); init_Uart();
Protocol_KL30_Wakeup_Init(); Protocol_KL30_Wakeup_Init();
xTaskCreatePinnedToCore(Uart_Rx_Task, "Ble_User", 4096, NULL, 4, NULL, 1); xTaskCreatePinnedToCore(Uart_Rx_Task, "Ble_User", 4096, NULL, 4, Uart_Rx_Taskhdl, 1);
} }
...@@ -119,16 +119,16 @@ void bsp_Uart_Init(void ) ...@@ -119,16 +119,16 @@ void bsp_Uart_Init(void )
extern void simple_ota_main(void); // extern void simple_ota_main(void);
void simple_ota_service(void) // void simple_ota_service(void)
{ // {
if(Wifi_OTA_Request == 1) // if(Wifi_OTA_Request == 1)
{ // {
Wifi_OTA_Request = 2; // Wifi_OTA_Request = 2;
simple_ota_main(); // simple_ota_main();
vTaskDelay(portMAX_DELAY); // vTaskDelay(portMAX_DELAY);
} // }
} // }
...@@ -138,7 +138,7 @@ void simple_ota_service(void) ...@@ -138,7 +138,7 @@ void simple_ota_service(void)
uint8_t BT_Device_Name[14] = "QJ-Viva"; uint8_t BT_Device_Name[14] = "RT-Viva";
#define GATTS_TABLE_TAG "GATTS_TABLE_DEMO" #define GATTS_TABLE_TAG "GATTS_TABLE_DEMO"
...@@ -147,9 +147,9 @@ uint8_t BT_Device_Name[14] = "QJ-Viva"; ...@@ -147,9 +147,9 @@ uint8_t BT_Device_Name[14] = "QJ-Viva";
#define PROFILE_APP_IDX 0 #define PROFILE_APP_IDX 0
#define ESP_APP_ID 0x55 #define ESP_APP_ID 0x55
#define SAMPLE_DEVICE_NAME "QJ-Viva" #define SAMPLE_DEVICE_NAME "RT-Viva"
#define SVC_INST_ID 0 #define SVC_INST_ID 0
#define SVC_INST_ID1 1 #define SVC_INST_ID1 1
esp_bd_addr_t rand_addr = {0xC0, 0x30, 0x05, 0x70, 0x09, 0xFA}; esp_bd_addr_t rand_addr = {0xC0, 0x30, 0x05, 0x70, 0x09, 0xFA};
...@@ -182,7 +182,7 @@ static uint8_t raw_adv_data[] = { ...@@ -182,7 +182,7 @@ static uint8_t raw_adv_data[] = {
0x02, 0x01, 0x02, 0x02, 0x01, 0x02,
0x03, 0x03, 0x69, 0x67, 0x03, 0x03, 0x69, 0x67,
0x09, 0xff, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x09, 0xff, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08, 0x09, 'Q', 'J', '-', 'V', 'i', 'v', 'a', 0x08, 0x09, 'R', 'T', '-', 'V', 'i', 'v', 'a',
// 0x08, 0x16, 0x60, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08, 0x16, 0x60, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };
......
...@@ -73,11 +73,11 @@ void bsp_Uart_Init(void ); ...@@ -73,11 +73,11 @@ void bsp_Uart_Init(void );
int bsp_Ble_Gatts_Send_Indicate(uint8_t len, uint8_t *data); int bsp_Ble_Gatts_Send_Indicate(uint8_t len, uint8_t *data);
void simple_ota_service(void); // void simple_ota_service(void);
extern uint8_t BT_Device_Name[14]; extern uint8_t BT_Device_Name[14];
void Get_Mac_Init(void ); void Get_Mac_Init(void );
extern int bsp_Uart_Send_Data(uint8_t * data , unsigned int len); extern int bsp_Uart_Send_Data(uint8_t * data , unsigned int len);
extern uint8_t BT_Device_Name[14];
#endif #endif
\ No newline at end of file
...@@ -86,7 +86,7 @@ static void Sys_Run_Tasks(void *arg) ...@@ -86,7 +86,7 @@ static void Sys_Run_Tasks(void *arg)
if(SYS_RUN_TASK_1000MS) if(SYS_RUN_TASK_1000MS)
{ {
simple_ota_service(); // simple_ota_service();
testcnt++; testcnt++;
if(testcnt >= 10) if(testcnt >= 10)
...@@ -120,32 +120,46 @@ static void Sys_Run_Tasks(void *arg) ...@@ -120,32 +120,46 @@ static void Sys_Run_Tasks(void *arg)
vTaskDelay(1); vTaskDelay(1);
} }
vTaskDelete(NULL); // vTaskDelete(NULL);
} }
TaskHandle_t wifi_service_hdl; TaskHandle_t wifi_service_hdl=NULL;
extern uint32_t SwitchMode;
extern void wifiServiceStart(void);
static void wifi_service_task(void *arg) static void wifi_service_task(void *arg)
{ {
while (1) while (1)
{ {
// if(SwitchMode == 1)
// {
// delele_tasks();
// SwitchMode=2;
// }
wifi_service_timer(); wifi_service_timer();
wifi_service(); wifi_service();
vTaskDelay(pdMS_TO_TICKS(100)); vTaskDelay(pdMS_TO_TICKS(100));
} }
} }
TaskHandle_t Sys_Run_Taskshdl=NULL;
void app_main(void) void app_main(void)
{ {
Protocol_User_Ctrl_Init(); Protocol_User_Ctrl_Init();
// BT_User_Init(); BT_User_Init();
// Ble_User_Init(); Ble_User_Init();
// Get_Mac_Init(); Get_Mac_Init();
// bsp_BT_Init(); bsp_BT_Init();
// bsp_Ble_Init(); bsp_Ble_Init();
bsp_Uart_Init(); bsp_Uart_Init();
// printf("KL30 INIT OVER~~~~~~\r\n"); printf("KL30 INIT OVER~~~~~~\r\n");
// xTaskCreatePinnedToCore(Sys_Run_Tasks, "Sys_Run_Tasks", 4096, NULL, 3, NULL, 1); xTaskCreatePinnedToCore(Sys_Run_Tasks, "Sys_Run_Tasks", 4096, NULL, 3, Sys_Run_Taskshdl, 1);
xTaskCreatePinnedToCore(wifi_service_task, "wifi_service_task", 4096, NULL, 5, &wifi_service_hdl, 1); xTaskCreatePinnedToCore(wifi_service_task, "wifi_service_task", 4096, NULL, 5, &wifi_service_hdl, 1);
} }
void delele_tasks(void)
{
vTaskSuspend(Sys_Run_Taskshdl);
vTaskSuspend(Ble_User_Task_hdl);
bt_app_task_shut_down( );
vTaskDelay(pdMS_TO_TICKS(100));
}
#ifndef _MAIN_USER_H_ #ifndef _MAIN_USER_H_
#define _MAIN_USER_H_ #define _MAIN_USER_H_
extern TaskHandle_t Ble_User_Task_hdl;
extern TaskHandle_t Sys_Run_Taskshdl;
extern TaskHandle_t Uart_Rx_Taskhdl;
extern void bt_app_task_shut_down(void);
extern void delateBleUser_Task(void);
#endif #endif
\ No newline at end of file
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#include "driver/uart.h" #include "driver/uart.h"
#include "esp_wifi.h" #include "esp_wifi.h"
#include "wifi_service.h" #include "wifi_service.h"
#include "main_user.h"
static const char *TAG = "wifi_service"; static const char *TAG = "wifi_service";
extern void delele_tasks(void);
/***************************************************** /*****************************************************
* 首次启动HTTP服务器后, 如果一直没有STA设备加入 * 首次启动HTTP服务器后, 如果一直没有STA设备加入
* 就不能触发STA disconnect事件,也就不会自动关闭HTTP服务器 * 就不能触发STA disconnect事件,也就不会自动关闭HTTP服务器
...@@ -15,7 +15,7 @@ static const char *TAG = "wifi_service"; ...@@ -15,7 +15,7 @@ static const char *TAG = "wifi_service";
******************************************************/ ******************************************************/
static unsigned char http_server_stop_counter = 0; static unsigned char http_server_stop_counter = 0;
static unsigned char softap_service_stop_flag = 0; static unsigned char softap_service_stop_flag = 0;
static unsigned short wifi_service_stop_timer = 0; static unsigned short wifi_service_stop_timer = 0;
wifi_service_t wifi_service_info; wifi_service_t wifi_service_info;
void wifi_service_init(void) void wifi_service_init(void)
...@@ -31,11 +31,7 @@ void wifi_service_init(void) ...@@ -31,11 +31,7 @@ void wifi_service_init(void)
void wifi_service_timer(void) void wifi_service_timer(void)
{ {
if(wifi_service_info.status == WIFI_SERVICE_STOP)
{
// 开启WiFi服务
wifi_service_info.status = WIFI_SERVICE_INIT;
}
if (wifi_service_info.status == WIFI_SERVICE_START) if (wifi_service_info.status == WIFI_SERVICE_START)
{ {
if (wifi_service_stop_timer < 300) if (wifi_service_stop_timer < 300)
...@@ -61,11 +57,11 @@ void wifi_service(void) ...@@ -61,11 +57,11 @@ void wifi_service(void)
if (wifi_service_info.status == WIFI_SERVICE_INIT) // 收到指令: WiFi服务初始化 if (wifi_service_info.status == WIFI_SERVICE_INIT) // 收到指令: WiFi服务初始化
{ {
wifi_service_info.status = WIFI_SERVICE_START; wifi_service_info.status = WIFI_SERVICE_START;
ESP_LOGI(TAG, "---- 关闭CAN总线, 卸载LIN driver, 开启WiFi服务..."); ESP_LOGI(TAG, "---- 开启WiFi服务...\n");
// Bsp_Can_Sleep_Init(); // Bsp_Can_Sleep_Init();
// uart_driver_delete(UART_NUM_1); // uart_driver_delete(UART_NUM_1);
// delele_tasks();
softap_service_start(); softap_service_start();
} }
else else
...@@ -121,3 +117,12 @@ void wifi_service(void) ...@@ -121,3 +117,12 @@ void wifi_service(void)
} }
} }
} }
void wifiServiceStart(void)
{
if(wifi_service_info.status == WIFI_SERVICE_STOP)
{
// 开启WiFi服务
wifi_service_info.status = WIFI_SERVICE_INIT;
}
}
\ No newline at end of file
...@@ -26,5 +26,5 @@ void wifi_service(void); ...@@ -26,5 +26,5 @@ void wifi_service(void);
extern void Bsp_Can_Sleep_Init(void); extern void Bsp_Can_Sleep_Init(void);
extern void Bsp_Can_Wakeup_Init(void); extern void Bsp_Can_Wakeup_Init(void);
extern void bsp_Uart1_Init(void); extern void bsp_Uart1_Init(void);
extern void wifiServiceStart(void);
#endif #endif
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