Forráskód Böngészése

reasonably good working state

etisab 10 éve
szülő
commit
d6eb4ea8e9
4 módosított fájl, 18 hozzáadás és 16 törlés
  1. 0 1
      BUILD/index.html
  2. 1 1
      BUILD/sendYo.lua
  3. 14 10
      BUILD/wifiSetup.lua
  4. 3 4
      index_unminified.html

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 1
BUILD/index.html


+ 1 - 1
BUILD/sendYo.lua

@@ -2,7 +2,7 @@ wifi.sleeptype(wifi.NONE_SLEEP)
 wifi.setmode(wifi.STATION)
 
 if YO_RECIPIENT then
-	debugMsg('sending yo to' .. YO_RECIPIENT)
+	debugMsg('sending yo to ' .. YO_RECIPIENT)
 	local contentString = "api_token=0c6ac771-71fa-420f-810c-2853989a8ca6&username="..string.upper(YO_RECIPIENT)
 	local contentLength = string.len(contentString)
 

+ 14 - 10
BUILD/wifiSetup.lua

@@ -40,8 +40,7 @@ function waitForWifiStatus(conn)
       debugMsg ("Waiting for Wifi status, currently " .. wifi.sta.status())
       restartSetupTimeout()
     else
-      local newStatus = wifi.sta.status()
-      debugMsg("Wifi status: " .. newStatus)
+      debugMsg("Wifi status: " .. wifi.sta.status())
       tmr.stop(WIFI_WAIT_TIMER)
       sendIndex(conn)
     end
@@ -91,6 +90,7 @@ function updateSettings(payload)
 end
 
 function setupServer()
+  local updated
   srv = net.createServer(net.TCP, 60)
   srv:listen(80, function(conn)
     conn:on("receive", function(conn, payload)
@@ -98,20 +98,21 @@ function setupServer()
       debugMsg(payload)
 
       restartSetupTimeout()
-      local updated = updateSettings(payload)
+      updated = updateSettings(payload)
       waitForWifiStatus(conn)
     end)
 
     conn:on("sent", function(conn)
       conn:close()
-      if updated then
+      debugMsg("sent: " .. tostring(updated) .. ' ' .. wifi.sta.status())
+      if updated and wifi.sta.status() == 5 then
+        
         debugMsg("updated and connected")
-        tmr.alarm(SUCCESS_SETUP_TIMER, 5000, tmr.ALARM_SINGLE, function()
-          if wifi.sta.status() == 5 then
-            debugMsg("closing AP")
-            stopBroadcastAP()
-          end
+        tmr.alarm(SUCCESS_SETUP_TIMER, 1000, tmr.ALARM_SINGLE, function()
+          debugMsg("closing AP")
+          stopBroadcastAP()
         end)
+
       end
     end)
   end)
@@ -134,7 +135,7 @@ function sendIndex(conn)
   local recipient = YO_RECIPIENT
   if not recipient then
     recipient = ''
-    debugMsg("recipient" .. recipient)
+    debugMsg("recipient: " .. recipient)
   end
 
   file.open('index.html')
@@ -146,6 +147,9 @@ function sendIndex(conn)
   indexhtml = string.gsub(indexhtml, "_R_", recipient)
 
   debugMsg('sending indexhtml')
+  debugMsg('____________')
+  debugMsg(indexhtml)
+  debugMsg('____________')
   conn:send(indexhtml)
 end
 

+ 3 - 4
index_unminified.html

@@ -27,7 +27,7 @@
       font-size: 50px;
     }
 
-    #h {
+    h1 {
       background-color: #813a9d;
       width: 100%;
       height: 70px;
@@ -44,12 +44,11 @@
     } 
   </style>
   <body>
-  <h1 id="h">Yo Button</h1>
+  <h1>Yo Button</h1>
 
-  <h2>Current settings</h2>
   <input type="text" value="network: _S_" readonly><br>
   <input type="text" value="status: _T_" readonly><br>
-  <h2>Will send Yos to</h2>
+  <h2>Send Yos to:</h2>
   <input type="text" value="_R_" readonly><br>
 
   <h2>New settings:</h2>

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott