Sending Binary data using the IP Socket Device

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Sending Binary data using the IP Socket Device

Post 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?
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Sending Binary data using the IP Socket Device

Post 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.
Scott
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Re: Sending Binary data using the IP Socket Device

Post 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.
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Re: Sending Binary data using the IP Socket Device

Post 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.
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Sending Binary data using the IP Socket Device

Post 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.
Scott
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: Sending Binary data using the IP Socket Device

Post by Richard Naninck »

Having node.js in HB would be a great add on. Can't wait :D
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Sending Binary data using the IP Socket Device

Post 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?
Scott
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: Sending Binary data using the IP Socket Device

Post 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.
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Sending Binary data using the IP Socket Device

Post by ScottBot »

So is it node.js (runs a webserver) that you want, or just javascript?
Scott
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: Sending Binary data using the IP Socket Device

Post 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
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Re: Sending Binary data using the IP Socket Device

Post 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.
Post Reply