0

Get Input From IR Remote To JS App

Here is my current autorun.brs file:

sub Main()
reg = CreateObject("roRegistrySection", "networking")
reg.write("ssh", "22")
n = CreateObject("roNetworkConfiguration", 0)
n.SetLoginPassword("password")
n.Apply()
reg.flush()

info = CreateObject("roDeviceInfo")
m.PlayerId = info.GetDeviceUniqueId()
m.mPort = CreateObject("roMessagePort")
m.configIR = CreateObject("roAssociativeArray")
m.configIR.source = "Iguana"
m.configIR.encodings = CreateObject("roArray", 1, false)
m.configIR.encodings[0] = "NEC"
m.IRRecep = CreateObject("roIRReceiver", m.configIR)
m.IRRecep.SetPort(m.msgPort)
m.irReceiver = CreateObject("roIRReceiver", m.configIR)

if type(m.irReceiver) = "roIRReceiver" then
m.irReceiver.SetPort(m.mPort)
endif

r = CreateObject("roRectangle", 0, 0, 1920, 1080)

is = {
port: 2999
}

config = {
nodejs_enabled: true
inspector_server: is
brightsign_js_objects_enabled: true
url: "file:///sd:/frontend/index.html"
}

m.node = CreateObject("roNodeJS", "app.js", {message_port: m.mPort})
sleep(5000)
m.h = CreateObject("roHtmlWidget", r, config)
m.h.Show()

while true
' do nothing
endwhile

end sub

In this file, I am trying to register my IguanaWorks IR Receiver, then start an express server, and finally show an html page (which makes calls to the server, hence the 5000 ms wait).

* I am sure there are numerous things wrong with this file, so if you see anything alarming outside my specific needs here, please share. *

I need to add an event listener in my javascript (which is loaded through file:///sd:/frontend/index.html) to be triggered by inputs on the remote. I don't know if I have to use the message port for this or the bs javascript API or both. Can someone steer me in the right direction here?

1 comment

  • 0
    Avatar
    Brandon Stryker

    following up on this. Since posting I have been able to post messages to my nodeJs app, confirm in the nodeJs app that the messages are being received (kinda...), print status updates to the message port, and view messages in the message port. I have not yet been able to confirm via the message port that a single roIRReceiver event has occurred. The Iguana Works transceiver is supposed to be able to receive input from a range of remote codes. I have tried the codes from a few popular brands (first and foremost roku) and have still failed to confirm that any messages events are being created and if they are they are certainly not in the messagePort (which I am viewing via ssh to the device). All other expected messages are in the messagePort log.

Please sign in to leave a comment.