• Уважаемые посетители сайта esp8266.ru!
    Мы отказались от размещения рекламы на страницах форума для большего комфорта пользователей.
    Вы можете оказать посильную поддержку администрации форума. Данные средства пойдут на оплату услуг облачных провайдеров для сайта esp8266.ru
  • Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

Нужна помощь nodemcu+conn.send

dittohead

New member
Возникла такая проблема:

раньше на nodemcu работал такой код:
Код:
function sendPage(conn)
   conn:send('HTTP/1.1 200 OK')
   conn:send('<!DOCTYPE HTML>')
   conn:send('<html>')
   conn:send('<head><meta content="text/html; charset=utf-8"><style>input{width: 100px; height: 100px;}</style>')
   conn:send('<title>ESP8266 test</title></head>')
   conn:send('<body><h1></h1>')
   conn:send('Status: <b>')
   if (status == "UNLOCK") then      conn:send('<B><font color=green>xxx</font></B>')
   elseif (status == "LOCK") then    conn:send('<B><font color=red>yyyy</font></B>')
   else                    
   --   conn:send(status)
     -- conn:send('%')
   end
   conn:send('</b><br /><br />')
   conn:send('<form action="/" method="POST">')

   if (status == "UNLOCK") then  conn:send('<input type="submit" style="background-color:red" name="cmd1" value="UNLOCK"/><br /><br />')
   elseif (status == "LOCK") then  conn:send('<input style="background-color:green" type="submit" name="cmd1" value="LOCK"/>')
   end

   conn:send('</form>')
   conn:send('</body></html>')
end



srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
   conn:on("receive", function(conn,payload)
      --next row is for debugging output only
      print(payload)
      if (string.find(payload, "GET / HTTP/1.1") ~= nil) then
         print("GET received")
         sendPage(conn)
      else
         swstat={string.find(payload,"cmd1=")}
         --If POST value exist, set LED power
         if swstat[2]~=nil then
            print("Command received: " .. payload)
           if (status == "UNLOCK") then
                status = "LOCK"
           else
           status = "UNLOCK"
           end
            sendPage(conn)
         end
      end
   end)
   conn:on("sent", function(conn)
      conn:close()
      print("Connection closed")
   end)
end)


теперь почему то надо формировать всю html ку в одну длинную строку, и отправлять за один send
пробовал крайний nodemcu и тот,что был раньше
что я делаю не так?
или еспшке паски?

з.ы. раньше спокойно ее прошивал без танцев с бубном, а теперь помогает только esptools.py
 
Последнее редактирование:
Сверху Снизу