0

Event on Connection Lost / Changing IP Address

Hi brightscripters,


My BrightSign Player is connected to network in dhcp, so the network configs are automatically setted
problem: CONNECTION LOST
Whene the connection is "ON" again (can't find the word in my mental italian dictionary), the BrightSign get an other ip address

 Is there a method with custom scripting to detect event on connection lost / change ip address?

My custom script has a timer that tick every 10sec that can check the network connection. but...how can i do it?

 

thanks

Luca

3 comments

  • 0
    Avatar
    Bright Scripters

    What type of connection loss are you interested in?

    BrightSign provide an event when the physical connection is attached/detached.

    https://docs.brightsign.biz/display/DOC/roNetworkAttached

  • 0
    Avatar
    Luca Ceccato

    SOLVED!!
    thank you

     

    I created a roNetworkHotplug object and setted my msgPort

    so i can get and handle roNetworkAttached and roNetworkDetached

     

    ...
     
    control.HOTPLUG = CreateObJect("roNetworkHotplug")
    control.HOTPLUG.SetPort(control.msgport)
     
    ....
     
    if type(msg) = "roNetworkAttached" then
                if m.settings.ManualIp then
                    nc = CreateObject("roNetworkConfiguration", 0)
                    nc.SetIP4Address(m.settings.IPAddress$)
                    nc.SetIP4Netmask(m.settings.Subnet$)
                    nc.SetIP4Broadcast(m.settings.Broadcast$)
                    nc.SetIP4Gateway(m.settings.Gateway$)
                    if m.settings.DNS1$ <> "" then nc.AddDNSServer(m.settings.DNS1$)
                    if m.settings.DNS2$ <> "" then nc.AddDNSServer(m.settings.DNS2$)

                    nc.Apply()
                    nc = 0
                else
                    nc = CreateObject("roNetworkConfiguration", 0)
                    nc.SetDHCP()

                    network = nc.GetCurrentConfig()

                    m.settings.IPAddress$ = network.ip4_address
                    m.settings.Subnet$ = network.ip4_netmask
                    m.settings.Gateway$ = network.ip4_gateway
                    m.settings.Broadcast$ = network.ip4_broadcast
                    m.settings.DNS1$ = network.dns_servers[0]
                    m.settings.DNS2$ = network.dns_servers[1]

                    nc.Apply()
                    nc = 0
                end if
                videoMode = CreateObject("roVideoMode")
                resX = videoMode.GetResX()
                resY = videoMode.GetResY()
                videoMode = invalid
                r = CreateObject("roRectangle", 0, resY / 2 - resY / 64, resX, resY / 32)
                twParams = CreateObject("roAssociativeArray")
                twParams.LineCount = 1
                twParams.TextMode = 2
                twParams.Rotation = 0
                twParams.Alignment = 1
                tw = CreateObject("roTextWidget", r, 1, 2, twParams)
                tw.PushString("Network Attached! IP: " + m.settings.IPAddress$)
                tw.Show()
                sleep(2500)
                tw.Hide()

            else if type(msg) = "roNetworkDetached" then
                videoMode = CreateObject("roVideoMode")
                resX = videoMode.GetResX()
                resY = videoMode.GetResY()
                videoMode = invalid
                r = CreateObject("roRectangle", 0, resY / 2 - resY / 64, resX, resY / 32)
                twParams = CreateObject("roAssociativeArray")
                twParams.LineCount = 1
                twParams.TextMode = 2
                twParams.Rotation = 0
                twParams.Alignment = 1
                tw = CreateObject("roTextWidget", r, 1, 2, twParams)
                tw.PushString("WARNING!!! Network Detached!")
                tw.Show()

            end if
    end if
    ....
  • 1
    Avatar
    Bright Scripters

    Good job!

    Thanks for sharing your code.

Please sign in to leave a comment.