Sending ASCII characters via TCP

Team,

I’m trying to develop a DTH for my TV and have a few bits of functionality working. The one I can’t work out is to send a simple string to the TV on a specific TCP port.

Data: 1012
IP: tv_IP
Port: 4660

I’m tried the following but with no luck:

def on() {
log.debug "Executing ‘on’"
def result = new physicalgraph.device.HubAction(“1012”, physicalgraph.device.Protocol.LAN, “C0A8003C:1234”)
log.debug result.toString()
sendHubCommand(result);

}

def off() {
log.debug "Executing ‘off’"
def result = new physicalgraph.device.HubAction(“1012”, physicalgraph.device.Protocol.LAN, “192.168.0.60:4660”)
log.debug result.toString()
sendHubCommand(result);
}

I was trying every combination so the On function uses the HEX version of the IP and the off version uses the decimal equivalent. I’ve even changed this to be the MAC address of the TV.

Is this even possible?

What brand and firmware?

I did penetration testing on 16 different models as part of a full security analysis for a client and the software on the newer smart tv’s sees this as an attack.

Celcus 48 inch 4k tv. Its a rebranded vestel unit.

I know this should work bases on the fact that if i send the packet from my laptop it turns on the tv. The tv will respond to this.

I just need confirmation that my code is correct, or rather which one oa correct.

The code looks good, do you mind if I try it on mine and tweak it a little if needed?

Go for it. Just edit the ip decimal and hex appropriately.

I don’t have any problems with my Samsung 65" curved SUHD, but I don’t have any other brands (all my tv’s are Samsung) to test on and while most tv’s ir frame data field length is 8 bits Samsungs is 12. You would think the ir frame wouldn’t have any effect but it does. So my test might be irrelevant.

Only other things I can think of are hex translation or authentication issues but its working from laptop.

If all else fails a simple workaround is an arduino board with ir controller connected to ST via shield. Use Teensy ++ to send all commands to tv from arduino

I don’t think the wife will like that. So when you say you tested the code can you explain what you did?

well that’s bizarre, I figured this out.

I ended up sending this as a remote code, using the same code I use for HDMI switching etc, and that worked. What’s weird is that in my packet captures this isn’t how the smartapp on my phone does it.

Anyways it now works.

Sorry I didn’t get back to you right away but I see you figured it out.

What I did was send the ir codes via hex and worked fine for me. For that though you have to know the encryption of each code and correct length for each manufacturer…which is usually pretty easy to figure out. Then you send the same data to the correct port depending on manufacturer.

Known working ports:

Samsung 65531 52235 55000
LG 32400 32469 1900
Vizio 5353 13000
Sharp 10002

Those are the ports that will accept commands, obviously a port scanner will help find any open ports but you need to know the correct ones along with correct hex length and encryption.

Code should look similar to this:

Samsung 65 Curved SUHD over IP
Samsung
http://www.Samsung.com
Samsung TV over IP Interface
UN65KS9800FXZA
1.0
crlf

<implementationList>
    <implementationFile>I_Samsung.xml</implementationFile>
</implementationList>         <settings>
    <protocol>crlf</protocol>
   <ioPort>65531</ioPort>
</settings>

...
     function tvStartup(lul_device)
        luup.log("Running I_Samsung.xml")
    end

…Off

– Power off
sendCommand("POWR0 ")

    <action>
 <serviceId>urn:com:serviceId:DiscretePower1</serviceId>
        <name>On</name>
        <run>
            -- Power on
            sendCommand("POWR1   ")
        </run>
    </action>

Obviously just fill in appropriate service id, correct tv, xml, and port