From 7beec37206b27b248969ab67ac1f7ca7b3875651 Mon Sep 17 00:00:00 2001 From: TJ Borromeo Date: Wed, 6 May 2015 13:25:02 -0700 Subject: [PATCH] Update init.lua Add one local variable to reduce one function call and take advantage of nil<=>false equivalance. --- init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 99a33df..9925fab 100644 --- a/init.lua +++ b/init.lua @@ -56,14 +56,15 @@ collectgarbage() local joinCounter = 0 local joinMaxAttempts = 5 tmr.alarm(0, 3000, 1, function() - if wifi.sta.getip() == nil and joinCounter < joinMaxAttempts then + local ip = wifi.sta.getip() + if ip and joinCounter < joinMaxAttempts then print('Connecting to WiFi Access Point ...') joinCounter = joinCounter +1 else if joinCounter == joinMaxAttempts then print('Faild to connect to WiFi Access Point.') else - print('IP: ',wifi.sta.getip()) + print('IP: ',ip) -- Uncomment to automatically start the server in port 80 --dofile("httpserver.lc")(80) end