Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RT200T_ESP32
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
RT200T
RT200T_ESP32
Commits
a2e830ab
Commit
a2e830ab
authored
May 30, 2024
by
李茂军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:串口打开wifi
parent
5a96e48d
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
253 additions
and
326 deletions
+253
-326
CMakeLists.txt
RT200T_2_ESP32/main/CMakeLists.txt
+1
-2
Protocol_User.c
RT200T_2_ESP32/main/Protocol_User.c
+5
-1
Protocol_User.h
RT200T_2_ESP32/main/Protocol_User.h
+99
-0
app_Ble_User.c
RT200T_2_ESP32/main/app_Ble_User.c
+3
-2
bt_app_core.c
RT200T_2_ESP32/main/bt_app_core.c
+2
-2
gatts_table_creat_demo.c
RT200T_2_ESP32/main/gatts_table_creat_demo.c
+12
-12
gatts_table_creat_demo.h
RT200T_2_ESP32/main/gatts_table_creat_demo.h
+1
-1
main_user.c
RT200T_2_ESP32/main/main_user.c
+25
-11
main_user.h
RT200T_2_ESP32/main/main_user.h
+5
-3
sdkconfig
RT200T_2_ESP32/sdkconfig
+84
-281
wifi_service.c
RT200T_2_ESP32/source/wifi/wifi_service.c
+15
-10
wifi_service.h
RT200T_2_ESP32/source/wifi/wifi_service.h
+1
-1
No files found.
RT200T_2_ESP32/main/CMakeLists.txt
View file @
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"
...
...
RT200T_2_ESP32/main/Protocol_User.c
View file @
a2e830ab
...
@@ -209,6 +209,8 @@ static Protocol_uint32_t Protocol_UartSend(const Protocol_uint8_t *pData, Protoc
...
@@ -209,6 +209,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
)
//收到底板发送的数据后,传状态
...
@@ -268,7 +270,9 @@ static void Protocol_UartHandle(const Protocol_Data_t *pData)//esp接收底板
...
@@ -268,7 +270,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
();
}
}
// }
// }
}
}
...
...
RT200T_2_ESP32/main/Protocol_User.h
View file @
a2e830ab
...
@@ -26,5 +26,104 @@ extern Protocol_User_Ctrl_Struct Prot_User;
...
@@ -26,5 +26,104 @@ extern Protocol_User_Ctrl_Struct Prot_User;
void
Protocol_User_Ctrl_Init
(
void
);
void
Protocol_User_Ctrl_Init
(
void
);
void
Prot_Send_Msg_Process
(
void
);
void
Prot_Send_Msg_Process
(
void
);
#define UPGRADE_N32G031
#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
RT200T_2_ESP32/main/app_Ble_User.c
View file @
a2e830ab
...
@@ -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
);
}
}
RT200T_2_ESP32/main/bt_app_core.c
View file @
a2e830ab
...
@@ -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
)
{
{
...
...
RT200T_2_ESP32/main/gatts_table_creat_demo.c
View file @
a2e830ab
...
@@ -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);
}
//
}
}
//
}
...
...
RT200T_2_ESP32/main/gatts_table_creat_demo.h
View file @
a2e830ab
...
@@ -73,7 +73,7 @@ void bsp_Uart_Init(void );
...
@@ -73,7 +73,7 @@ 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
];
...
...
RT200T_2_ESP32/main/main_user.c
View file @
a2e830ab
...
@@ -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
));
}
RT200T_2_ESP32/main/main_user.h
View file @
a2e830ab
#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
RT200T_2_ESP32/sdkconfig
View file @
a2e830ab
This diff is collapsed.
Click to expand it.
RT200T_2_ESP32/source/wifi/wifi_service.c
View file @
a2e830ab
...
@@ -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
RT200T_2_ESP32/source/wifi/wifi_service.h
View file @
a2e830ab
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment