mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
station连接成功关ap
This commit is contained in:
@@ -146,8 +146,10 @@ int application_start(void)
|
||||
// }
|
||||
// }
|
||||
|
||||
//sys_config = mico_system_context_init(sizeof(user_config_t)); //获取Flash中的配置
|
||||
if (user_config->last_wifi_status != NOTIFY_STATION_UP)
|
||||
{
|
||||
ap_init();
|
||||
}
|
||||
wifi_init();
|
||||
user_udp_init();
|
||||
key_init();
|
||||
|
||||
@@ -60,14 +60,15 @@ typedef struct
|
||||
char version;
|
||||
user_plug_config_t plug[PLUG_NUM];
|
||||
char user[maxNameLen];
|
||||
WiFiEvent last_wifi_status;
|
||||
} user_config_t;
|
||||
|
||||
extern char rtc_init;
|
||||
extern uint32_t total_time;
|
||||
extern char strMac[16];
|
||||
extern uint32_t power;
|
||||
extern system_config_t * sys_config;
|
||||
extern user_config_t * user_config;
|
||||
extern system_config_t* sys_config;
|
||||
extern user_config_t* user_config;
|
||||
extern char socket_status[32];
|
||||
extern mico_gpio_t Relay[Relay_NUM];
|
||||
|
||||
|
||||
@@ -69,18 +69,28 @@ static void wifi_get_ip_callback(IPStatusTypedef *pnet, void * arg)
|
||||
wifi_status = WIFI_STATE_CONNECTED;
|
||||
user_function_cmd_received(1,"{\"cmd\":\"device report\"}");
|
||||
}
|
||||
|
||||
//wifi连接状态改变回调
|
||||
static void wifi_status_callback(WiFiEvent status, void *arg)
|
||||
static void wifi_status_callback(WiFiEvent status, void* arg)
|
||||
{
|
||||
if (status == NOTIFY_STATION_UP) //wifi连接成功
|
||||
{
|
||||
user_config->last_wifi_status = status;
|
||||
//wifi_status = WIFI_STATE_CONNECTED;
|
||||
} else if (status == NOTIFY_STATION_DOWN) //wifi断开
|
||||
//关闭AP
|
||||
OSStatus status = micoWlanSuspendSoftAP();
|
||||
if (status != kNoErr)
|
||||
{
|
||||
os_log("close ap error[%d]", status);
|
||||
}
|
||||
}
|
||||
else if (status == NOTIFY_STATION_DOWN) //wifi断开
|
||||
{
|
||||
wifi_status = WIFI_STATE_NOCONNECT;
|
||||
if (!mico_rtos_is_timer_running(&wifi_led_timer)) mico_rtos_start_timer(&wifi_led_timer);
|
||||
}
|
||||
}
|
||||
|
||||
//100ms定时器回调
|
||||
static void wifi_led_timer_callback(void* arg)
|
||||
{
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
|
||||
#ifndef __USER_WIFI_H_
|
||||
#define __USER_WIFI_H_
|
||||
|
||||
|
||||
#include "mico.h"
|
||||
#include "micokit_ext.h"
|
||||
|
||||
|
||||
enum {
|
||||
WIFI_STATE_FAIL,
|
||||
WIFI_STATE_NOCONNECT,
|
||||
@@ -17,13 +14,10 @@ enum {
|
||||
WIFI_STATE_EASYLINKING,
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern char wifi_status;
|
||||
extern void wifi_init(void);
|
||||
extern void ap_init(void);
|
||||
extern void wifi_start_easylink(void);
|
||||
extern void wifi_connect(char* wifi_ssid, char* wifi_key);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user