Page 1 of 1

Sending Binary data using the IP Socket Device

Posted: Sat Oct 06, 2018 2:03 am
by incoronado
I need to send "A5 5B 02 03 01 00 04 00 00 00 00 00 F4" in hex form using the "IP Socket Device". I can't use chr(0) in a string because it terminates the string, Does anyone know if there any way I can do this given the Send Data property is AlphaNumeric?

Re: Sending Binary data using the IP Socket Device

Posted: Mon Oct 08, 2018 11:06 am
by ScottBot
I can't think of any way, unless there is a way to have the receiver interpret the data as a hex string instead of an integer.

I could probably add some kind of escape sequence to tell the device to convert a hex byte to integer. If you can't find a way around it, let me know and I can look into that.

Re: Sending Binary data using the IP Socket Device

Posted: Mon Oct 08, 2018 5:25 pm
by incoronado
I thought about it and I can’t think of a way with HB. I have been working with node.js using it as a gateway to get greater capabilty-especially JSON objects. I’ll probably forward the hex string to my node.js server and handle it that way.

I have used wireshark to capture IP data from the included windows app that controls the video matrix and have verified that it is sending only HEX data including 00/null values. These companies need to get with the program start using restful APIs that use JSON instead of raw TCP sockets that require hex/binary operations. They will attract much more interest in the IOT/SI space.

Re: Sending Binary data using the IP Socket Device

Posted: Mon Oct 08, 2018 6:04 pm
by incoronado
Did you ever consider adding node.js capabilty as an alernative to using vbs? node.js is ubiquitous and has an extensive package repository (NPM) and mature frameworks. It has native support for JSON objects. This might serve to open up HB to a much larger user base.

Re: Sending Binary data using the IP Socket Device

Posted: Tue Oct 09, 2018 1:58 pm
by ScottBot
I haven't looked into it. I suppose if it had a good API and library to make it easy to add, I could consider it.

Re: Sending Binary data using the IP Socket Device

Posted: Wed Oct 10, 2018 3:56 pm
by Richard Naninck
Having node.js in HB would be a great add on. Can't wait :D

Re: Sending Binary data using the IP Socket Device

Posted: Wed Oct 10, 2018 5:15 pm
by ScottBot
So are you guys looking to be able to write nodeJS code (instead of VB code) for the script device/task, or is the need to be able to call into HouseBot (maybe through the external control device) through a nodejs module (housebot API) from an externally running nodejs?

Re: Sending Binary data using the IP Socket Device

Posted: Thu Oct 11, 2018 9:42 am
by Richard Naninck
I already call HB through node.js in my Apple Homekit setup. So I would like node.js like vbscript without sacrificeing vbscript btw.

Re: Sending Binary data using the IP Socket Device

Posted: Thu Oct 11, 2018 12:55 pm
by ScottBot
So is it node.js (runs a webserver) that you want, or just javascript?

Re: Sending Binary data using the IP Socket Device

Posted: Sat Oct 13, 2018 11:22 am
by Richard Naninck
As long as it can handle eventlisteners and is multithreading. Both at which vbscript is very limited.
Sometimes I have to write external scripts because HouseBot cannot the On event.
I use node.js to catch events from my Nest smokedetectors because vbscript and therefore HouseBot can't handle it internally.
Same still goes for Meedio Messages.
So for me it would be great if HouseBot would find a way to catch events.

Code: Select all

Set oPktX = WScript.CreateObject("PktX.PacketX")
WScript.ConnectObject oPktX, "PacketX_"
Set objHB = WScript.CreateObject("HBControlMod.HBControl")
Call objHB.Connect(4714, "192.168.0.3", "")

Public Sub PacketX_OnPacket(ByRef oPacket)
	
	Select Case oPacket.Protocol
		Case PktXProtocolTypeUDP: Call Decode_UDP(oPacket)
		Case PktXProtocolTypeTCP: Call Decode_TCP(oPacket)
	End Select
End Sub

Re: Sending Binary data using the IP Socket Device

Posted: Fri Oct 26, 2018 6:21 pm
by incoronado
Sorry for the lagged response. I myself would envision .js to work a lot like your .vbs implementation.

Maybe what you really want is to merely add .js support and maybe not node.js since HB is already a server.

Node.js is a single threaded language which in background uses multiple threads to execute asynchronous code. Node.js is non-blocking which means that all functions ( callbacks ) are delegated to the event loop and they are ( or can be ) executed by different threads. That is handled by Node.js run-time.


Sample pseudo .js listener code.

HB.AddListener(HB.OBJECT_VALUE_CHANGE, this.DEVICE, function(data) {
HB.SetPropertyValue("HB Property", "HB Property Value");
}, this);


This way you could interact with any existing HB properties without having to do much work.