Open alberto148 opened 8 years ago
--here is the fix. -alberto148
wifi.setmode(wifi.STATION) wifi.sta.config("ssid","password") print(wifi.sta.getip()) gpio2 = 4 gpio.mode(gpio2, gpio.OUTPUT) ws2812.init() srv=net.createServer(net.TCP) srv:listen(80,function(conn) conn:on("receive", function(client,request) if (string.find(request,"favicon") ~= nil) then return end print("request received") print(request) local buf = ""; local , , method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP"); if(method == nil)then , , method, path = string.find(request, "([A-Z]+) (.+) HTTP"); end local _GET = {} if (vars ~= nil)then for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do _GET[k] = v end end local redchecked,greenchecked,bluechecked = "","","" red,green,blue = 0,0,0 if(_GET.red == "red")then --gpio.write(led1, gpio.HIGH); red = 255 redchecked = " checked " end if(_GET.green == "green")then green = 255 greenchecked = " checked " end if(_GET.blue == "blue")then -- gpio.write(led2, gpio.LOW); blue = 255 bluechecked = " checked " end buf = buf.."
PANIC: unprotected error in call to Lua API (init.lua:55: attempt to call field 'writergb' (a nil value))