Giter Club home page Giter Club logo

nodemcu-ssdp's Introduction

NodeMCU rgb led controller with SSDP capability.

Installation

  • You should use latest firmware from nodemcu-firmware with multicast support
  • Place these files on top of NodeMCU-httpserver.
  • Add upnp.lua and http/rgb.lua to list of files to compile.
  • Add dofile("upnp.lc") after dofile("httpserver.lc")(80).
  • Yo should see "OVOI RGB controller" in your upnp browser.
  • it is working at least in windows network browser and upnp-inspector.

nodemcu-ssdp's People

Contributors

pastukhov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodemcu-ssdp's Issues

UPnP failing on latest NodeMCU builds

I have been using your piece of code successfully on the NodeMCU firmware, until the latest modifications to the network layer.
I modified your code to make it compatible with the changes to the UDP commands: changing from net.createServer to net.createUDPSocket.

net.multicastJoin(wifi.sta.getip(), "239.255.255.250")

local ssdp_notify = "NOTIFY * HTTP/1.1\r\n"..
"HOST: 239.255.255.250:1900\r\n"..
"CACHE-CONTROL: max-age=100\r\n"..
"NT: upnp:rootdevice\r\n"..
"USN: uuid:c5baf4a1-0c8e-44da-9714-ef01234"..string.format("%x",node.chipid()).."::upnp:rootdevice\r\n"..
"NTS: ssdp:alive\r\n"..
"SERVER: NodeMCU/20150415 UPnP/1.1 ovoi/0.1\r\n"..
"Location: http://"..wifi.sta.getip().."/DimmableLight.xml\r\n\r\n"


local ssdp_response = "HTTP/1.1 200 OK\r\n"..
"Cache-Control: max-age=100\r\n"..
"EXT:\r\n"..
"SERVER: NodeMCU/20150415 UPnP/1.1 ovoi/0.1\r\n"..
"ST: upnp:rootdevice\r\n"..
"USN: uuid:c5baf4a1-0c8e-44da-9714-ef01234"..string.format("%x",node.chipid()).."\r\n"..
"Location: http://"..wifi.sta.getip().."/DimmableLight.xml\r\n\r\n"

notifyCount = 0

local function notify()
    notifyCount = notifyCount + 1
    if notifyCount == 3 then
        tmr.stop(3)
        notifyCount = nil
        ssdp_notify = nil
        collectgarbage()
    else
        UPnP = net.createUDPSocket()
        --UPnP:connect(1900,"239.255.255.250")
        UPnP:send(1900,'239.255.255.250',ssdp_notify)
        print("Sending notify")
        UPnP:close()
        UPnP = nil
        notify = nil
        collectgarbage()
    end


end

local function response(connection, payLoad)
        if string.match(payLoad,"M-SEARCH") then
            connection:send(1900,'239.255.255.250',ssdp_response)
            print("sent "..node.heap())
        end
end


tmr.alarm(3, 10000, 1, notify())




UPnPd = net.createUDPSocket()

UPnPd:on("receive", response )
--[[
UPnPd:on("sent", function(connection, payLoad) 
         print("sent "..node.heap())
       
      end)]]--
UPnPd:listen(1900,"239.255.255.250")

This code runs fine, until the response function is called.
The code then fails with: PANIC: unprotected error in call to Lua API (upnp2.lua:46: illegal value)
Which means connection:send(1900,'239.255.255.250',ssdp_response) fails.

So far I was not able to find out what is triggering this.
Any ideas/suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.