From eb8240ecb2863734386d96c36d9873a9f3b6094f Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Tue, 19 Sep 2023 21:01:21 +0800 Subject: [PATCH] fixed udp service bugs --- WifiMgr.lua | 14 ++++++++++---- init.lua | 2 -- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/WifiMgr.lua b/WifiMgr.lua index 063aedd..9cfed5f 100644 --- a/WifiMgr.lua +++ b/WifiMgr.lua @@ -20,13 +20,19 @@ function ManualLink(ssid,passwd) wifi.setmode(wifi.STATION) StationCfg.ssid=ssid StationCfg.pwd=passwd - StationCfg.save=true + StationCfg.save=false wifi.sta.config(StationCfg) wifi.sta.connect() - PageMainScene(ssid,wifi.sta.getip().."","V1.0"); + if wifi.sta.getip() == nil then + SetIP("192.168.1.115","255.255.255.0","192.168.1.1") + print("No Ip get,default to 192.168.1.115!"); + end + PageMainScene(ssid,wifi.sta.getip(),"V1.0"); local lightArr = {[1]=false,[2]=false,[3]=false,[4]=false} PageLight(lightArr) - + --Service Open + StartUDPService(); + print(wifi.sta.status()); end --mobile setting ap and passwd @@ -37,7 +43,7 @@ function AutoLinkByMobile() enduser_setup.start( "DY-Light-Controller", function() - print("Connected to WiFi as:" .. wifi.sta.getip()) + print("Connected to WiFi!") end, function(err, str) print("enduser_setup: Err #" .. err .. ": " .. str) diff --git a/init.lua b/init.lua index 64dc632..d435c18 100644 --- a/init.lua +++ b/init.lua @@ -6,8 +6,6 @@ require("OLED_SSD1306") require("WifiMgr") require("UDPService") function Init() - SetIP("192.168.1.115","255.255.255.0","192.168.1.1"); AutoLink(); - --StartUDPService(); end Init();