1. 解决ble 冷启动不能局域网控制的问题
之前的版本只能应对中途断网的情况。现在的应该可以应对无网启动的情况
This commit is contained in:
@ -689,7 +689,7 @@ void read_device_data(void)
|
||||
e_printf("主数据和备份数据都无效,使用默认值\r\n");
|
||||
// 只打印g_device_control的当前值,不打印data.control
|
||||
e_printf("上电次数: %d\r\n", g_device_control.power_on_cnt);
|
||||
e_printf("配网状态: %d\r\n", g_device_control.is_networked);
|
||||
e_printf("配网状态: %d\r\n", g_device_control.is_bound);
|
||||
e_printf("是否是新设备: %d\r\n", !g_device_control.is_net_configured);
|
||||
e_printf("开关状态: %d\r\n", g_device_control.on);
|
||||
e_printf("灯光模式: %d\r\n", g_device_control.elightMode);
|
||||
@ -703,7 +703,7 @@ void read_device_data(void)
|
||||
// 更新设备控制状态
|
||||
e_printf("设备状态恢复:\r\n");
|
||||
e_printf("上电次数: %d => %d\r\n", g_device_control.power_on_cnt, data.control.power_on_cnt);
|
||||
e_printf("配网状态: %d => %d\r\n", g_device_control.is_networked, data.control.is_networked);
|
||||
e_printf("配网状态: %d => %d\r\n", g_device_control.is_bound, data.control.is_bound);
|
||||
e_printf("是否是新设备: %d => %d\r\n", !g_device_control.is_net_configured, !data.control.is_net_configured);
|
||||
e_printf("开关状态: %d => %d\r\n", g_device_control.on, data.control.on);
|
||||
e_printf("灯光模式: %d => %d\r\n", g_device_control.elightMode, data.control.elightMode);
|
||||
@ -741,7 +741,7 @@ void save_device_data(void)
|
||||
last_control.cct_local != g_device_control.cct_local ||
|
||||
last_control.colourMode != g_device_control.colourMode ||
|
||||
last_control.power_on_cnt != g_device_control.power_on_cnt ||
|
||||
last_control.is_networked != g_device_control.is_networked ||
|
||||
last_control.is_bound != g_device_control.is_bound ||
|
||||
last_control.is_net_configured != g_device_control.is_net_configured;
|
||||
|
||||
if (!need_save) {
|
||||
@ -1041,7 +1041,9 @@ static int handle_network_status(void)
|
||||
{
|
||||
uint8_t start_net_cfg = 0;
|
||||
// 如果已经配网,直接返回
|
||||
if (g_device_control.is_networked) {
|
||||
if (g_device_control.is_bound) {
|
||||
// 如果已经配网,则设置发出ble广播确保如果没法连接路由器可以转为本地蓝牙控制
|
||||
start_hilink_ble_net_config(0xFFFFFFFF);
|
||||
return start_net_cfg;
|
||||
}
|
||||
|
||||
@ -1053,6 +1055,7 @@ static int handle_network_status(void)
|
||||
start_net_config();
|
||||
start_net_cfg = 1;
|
||||
}
|
||||
|
||||
|
||||
// 保存设备状态
|
||||
req_save_device_data();
|
||||
@ -1195,9 +1198,9 @@ void handle_device_online(void)
|
||||
}
|
||||
e_printf("device online!\r\n");
|
||||
g_device_control.is_net_configured = true;//设备上线后,认为设备已经配网成功,就取消标记为新设备,终生只存在这一次标记
|
||||
if (!g_device_control.is_networked) {
|
||||
if (!g_device_control.is_bound) {
|
||||
e_printf("设备首次上线,记录配网状态\r\n");
|
||||
g_device_control.is_networked = true;
|
||||
g_device_control.is_bound = true;
|
||||
g_device_control.power_on_cnt = 0; // 重置上电计数
|
||||
stop_breath_timer(); // 停止呼吸灯
|
||||
set_light2net_cfg_done();
|
||||
@ -1224,8 +1227,8 @@ bool g_reset_factory_flag = false;
|
||||
void handle_device_unbind(void)
|
||||
{
|
||||
e_printf("设备被解绑,重置配网状态\r\n");
|
||||
if (g_device_control.is_networked) {
|
||||
g_device_control.is_networked = false;
|
||||
if (g_device_control.is_bound) {
|
||||
g_device_control.is_bound = false;
|
||||
g_device_control.power_on_cnt = 0; // 重置上电计数
|
||||
stop_spotlight_main_task();
|
||||
device_control_t tmp = DEFAULT_DEVICE_DATA;//恢复默认
|
||||
@ -1242,7 +1245,7 @@ static void check_net_cfg_power_on_keep_time(void)
|
||||
if (g_device_control.power_on_cnt <= 0) {
|
||||
return;
|
||||
}
|
||||
if (g_device_control.is_networked) {
|
||||
if (g_device_control.is_bound) {
|
||||
return;
|
||||
}
|
||||
if (uapi_systick_get_ms() > INIT_NET_CFG_PWOER_ON_KEEP_TIME) {
|
||||
@ -1380,7 +1383,7 @@ int spotlight_main(void) {
|
||||
// set_light(DEV_POWER_ON, g_device_control.brightness_local, g_device_control.cct_local);
|
||||
}
|
||||
|
||||
if (!g_device_control.is_networked && !g_device_control.is_net_configured) {
|
||||
if (!g_device_control.is_bound && !g_device_control.is_net_configured) {
|
||||
try_detect_factory_test();
|
||||
}
|
||||
start_spotlight_main_task();
|
||||
|
Reference in New Issue
Block a user