每2s判断联网(有问题)
This commit is contained in:
parent
cabe8296ea
commit
d3151dd787
.vscode
applications
my_pro
14
.vscode/keil-assistant.log
vendored
14
.vscode/keil-assistant.log
vendored
@ -20,3 +20,17 @@
|
||||
|
||||
[info] Log at : 2025/1/18|00:50:06|GMT+0800
|
||||
|
||||
[info] Log at : 2025/2/3|17:47:00|GMT+0800
|
||||
|
||||
[info] Log at : 2025/2/11|20:47:29|GMT+0800
|
||||
|
||||
[info] Log at : 2025/2/13|18:00:08|GMT+0800
|
||||
|
||||
[info] Log at : 2025/2/16|09:16:38|GMT+0800
|
||||
|
||||
[info] Log at : 2025/2/18|16:29:01|GMT+0800
|
||||
|
||||
[info] Log at : 2025/3/5|20:26:51|GMT+0800
|
||||
|
||||
[info] Log at : 2025/3/10|21:09:20|GMT+0800
|
||||
|
||||
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -27,7 +27,9 @@
|
||||
"rgb.h": "c",
|
||||
"main.h": "c",
|
||||
"indicator_led.h": "c",
|
||||
"drv_matrix_led.h": "c"
|
||||
"drv_matrix_led.h": "c",
|
||||
"init.h": "c",
|
||||
"string.h": "c"
|
||||
},
|
||||
// "cortex-debug.openocdPath": "d:/Develop/"
|
||||
}
|
8
.vscode/tasks.json
vendored
8
.vscode/tasks.json
vendored
@ -81,7 +81,7 @@
|
||||
{
|
||||
"label": "编译下载(j1)",
|
||||
"type": "shell",
|
||||
"command": "scons -j1 && copy /z ${workspaceFolder}\\rtthread.bin f:\\",
|
||||
"command": "scons -j1 && copy /z ${workspaceFolder}\\rtthread.bin g:\\",
|
||||
"args": [],
|
||||
"problemMatcher": {
|
||||
"owner": "cpp",
|
||||
@ -103,7 +103,7 @@
|
||||
"label": "编译下载(j8)",
|
||||
"type": "shell",
|
||||
// "command": "scons -j8 && pyocd flash -t stm32l431rctx ${workspaceFolder}/rt-thread.elf",
|
||||
"command": "scons -j8 && copy /z ${workspaceFolder}\\rtthread.bin f:\\",
|
||||
"command": "scons -j8 && copy /z ${workspaceFolder}\\rtthread.bin g:\\",
|
||||
"args": [],
|
||||
"problemMatcher": {
|
||||
"owner": "cpp",
|
||||
@ -132,7 +132,7 @@
|
||||
"label": "下载固件(pyocd)",
|
||||
"type": "shell",
|
||||
// "command": "pyocd flash -t stm32l431rctx ${workspaceFolder}/rt-thread.elf",
|
||||
"command": "copy /z ${workspaceFolder}/rtthread.bin f:\\",
|
||||
"command": "copy /z ${workspaceFolder}/rtthread.bin g:\\",
|
||||
"args": [],
|
||||
|
||||
"args": [],
|
||||
@ -191,7 +191,7 @@
|
||||
"label": "全部编译下载(j8)",
|
||||
"type": "shell",
|
||||
// "command": "scons -c && cd ${workspaceFolder} && rm -fv *.elf *.hex *.bin *.map && scons -j8 && pyocd flash -t stm32l431rctx ${workspaceFolder}/rt-thread.elf",
|
||||
"command": "scons -c && cd ${workspaceFolder} && rm -fv *.elf *.hex *.bin *.map && scons -j8 && copy /z ${workspaceFolder}/rtthread.bin f:\\",
|
||||
"command": "scons -c && cd ${workspaceFolder} && rm -fv *.elf *.hex *.bin *.map && scons -j8 && copy /z ${workspaceFolder}/rtthread.bin g:\\",
|
||||
"args": [],
|
||||
"problemMatcher": {
|
||||
"owner": "cpp",
|
||||
|
@ -52,7 +52,7 @@ int main_init(void)
|
||||
|
||||
char str[] = "wifi join Dong abcd07691234";
|
||||
my_round(20);
|
||||
system(str);
|
||||
// system(str);
|
||||
// rt_thread_mdelay(18000);
|
||||
// char *argv[] = {"wifi", "join", "Dong", "abcd07691234"};
|
||||
// wifi_join(4, argv);
|
||||
|
@ -39,8 +39,8 @@ int main(void)
|
||||
system("snake");
|
||||
// rt_wlan_config_autoreconnect(RT_TRUE);
|
||||
// rt_wlan_connect("Dong", "abcd07691234");
|
||||
rt_wlan_connect("as", "88888888");
|
||||
rt_wlan_connect("as", "88888888");
|
||||
// rt_wlan_connect("as", "07691234");
|
||||
// wlan_connected=rt_wlan_connect("as", "07691234");
|
||||
system("myproject");
|
||||
// system("mqtt");
|
||||
mytime();
|
||||
|
@ -10,6 +10,7 @@
|
||||
//串口
|
||||
rt_device_t serial;
|
||||
char str[] = "forward\n";
|
||||
int wlan_connected=-RT_ERROR;
|
||||
|
||||
extern char tmp[];
|
||||
void lcd_black(int x, int y)
|
||||
|
@ -9,6 +9,7 @@
|
||||
//串口
|
||||
extern rt_device_t serial;
|
||||
extern char str[];
|
||||
extern int wlan_connected;
|
||||
|
||||
void mytime();
|
||||
void greattime();
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <ulog.h>
|
||||
#include "my_func.h"
|
||||
#include "indicator_led.h"
|
||||
|
||||
#define THREAD_PRIORITY 25
|
||||
#define THREAD_STACK_SIZE 4096
|
||||
#define THREAD_TIMESLICE 5
|
||||
@ -30,6 +29,7 @@ rt_thread_t Test_Thread = RT_NULL;
|
||||
rt_thread_t CDC_Thread = RT_NULL;
|
||||
rt_thread_t Serial_Thread = RT_NULL;
|
||||
rt_thread_t LED_Thread = RT_NULL;
|
||||
rt_thread_t wlan_connect_tid = RT_NULL;
|
||||
|
||||
char DEMO_PRODUCT_KEY[IOTX_PRODUCT_KEY_LEN + 1] = {0};
|
||||
char DEMO_DEVICE_NAME[IOTX_DEVICE_NAME_LEN + 1] = {0};
|
||||
@ -44,6 +44,9 @@ int HAL_GetDeviceSecret(char device_secret[IOTX_DEVICE_SECRET_LEN]);
|
||||
uint64_t HAL_UptimeMs(void);
|
||||
int HAL_Snprintf(char *str, const int len, const char *fmt, ...);
|
||||
|
||||
#define WLAN_CONNECTED 1;
|
||||
#define WLAN_DISCONNECTED 0;
|
||||
|
||||
// 定义接受文件内容的缓冲区
|
||||
char buffer[1026] = {};
|
||||
char tmp[1026];
|
||||
@ -52,7 +55,8 @@ rt_atomic_t page_chosen = 1;
|
||||
rt_atomic_t page_first = 1;
|
||||
rt_atomic_t page_stop = 0;
|
||||
rt_atomic_t last_stop = 0;
|
||||
rt_atomic_t mqtt_enable = 0;
|
||||
rt_atomic_t last_connect_status = -RT_ERROR;
|
||||
rt_atomic_t mqtt_enable = 1;
|
||||
|
||||
void *pclient = NULL;
|
||||
|
||||
@ -270,11 +274,29 @@ void tmp_payload(void)
|
||||
else
|
||||
{
|
||||
lcd_show_string(240 / 2 - 24 * 2, 240 / 2 + 12, 32, "enable ");
|
||||
if (mqtt_enable && !last_stop)
|
||||
if (mqtt_enable && !last_stop && wlan_connected == RT_EOK)
|
||||
{
|
||||
last_stop = 1;
|
||||
mqt_init();
|
||||
}
|
||||
if (wlan_connected == RT_EOK)
|
||||
{
|
||||
lcd_show_string(240 / 2 - 24 * 2, 240 / 2 + 12 + 32, 32, "connect");
|
||||
// if (last_connect_status != RT_EOK)
|
||||
// {
|
||||
// mqt_init();
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_show_string(240 / 2 - 24 * 2, 240 / 2 + 12 + 32, 32, "disconnect");
|
||||
// if (last_connect_status == RT_EOK)
|
||||
// {
|
||||
// IOT_MQTT_Destroy(&pclient);
|
||||
// rt_thread_delete(MQTT_Thread);
|
||||
// }
|
||||
}
|
||||
// last_connect_status = wlan_connected;
|
||||
}
|
||||
}
|
||||
if (ps_data > 1022)
|
||||
@ -408,7 +430,19 @@ void cdc_entry(void *parameter)
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
}
|
||||
void wlan_connect_thread(void *parameter)
|
||||
{
|
||||
(void *)parameter;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (wlan_connected != RT_EOK)
|
||||
{
|
||||
wlan_connected = rt_wlan_connect("as", "07691234");
|
||||
}
|
||||
rt_thread_mdelay(2000);
|
||||
}
|
||||
}
|
||||
// /* 用于接收消息的信号量 */
|
||||
// static struct rt_semaphore rx_sem;
|
||||
// /* 接收数据回调函数 */
|
||||
@ -462,6 +496,20 @@ void ath_init(void)
|
||||
return;
|
||||
}
|
||||
}
|
||||
void wla_init(void)
|
||||
{
|
||||
wlan_connect_tid = rt_thread_create("wlanas", wlan_connect_thread, RT_NULL, THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
|
||||
|
||||
if (wlan_connect_tid != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(wlan_connect_tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("wlan_connect_thread Create Failed!\n");
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(wla_init, wla_init, "Infrared");
|
||||
void serial_init(void)
|
||||
{
|
||||
// // 初始化设备
|
||||
@ -505,7 +553,7 @@ void serial_init(void)
|
||||
}
|
||||
void mqt_init(void)
|
||||
{
|
||||
MQTT_Thread = rt_thread_create("MTQQ_Thread", mqtt_example_main, RT_NULL, THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
|
||||
MQTT_Thread = rt_thread_create("MQTT_Thread", mqtt_example_main, RT_NULL, THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
|
||||
|
||||
if (MQTT_Thread != RT_NULL)
|
||||
{
|
||||
@ -591,6 +639,7 @@ void tst_init(void)
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(tst_init, no_mqtt, "Infrared");
|
||||
|
||||
// void evn_init(void)
|
||||
// {
|
||||
// if(rt_event_create("my_event2", RT_IPC_FLAG_FIFO) != RT_EOK)
|
||||
@ -607,7 +656,13 @@ void my_project(void)
|
||||
|
||||
ath_init();
|
||||
|
||||
// mqt_init();
|
||||
wla_init();
|
||||
|
||||
if (wlan_connected == RT_EOK)
|
||||
{
|
||||
last_stop = 1;
|
||||
mqt_init();
|
||||
}
|
||||
|
||||
ap3_init();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user