IP Control of lights

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
PT
Senior Member
Posts: 147
Joined: Wed Apr 13, 2005 12:32 pm
Location: Hampshire.UK

IP Control of lights

Post by PT »

Scottbot



Good morning



I have an ip controller that controls garden lights etc. It has a web interface or comes with an SDK( with DLL) which I have modified I sthere any way of getting this directly controlled by house bot?

Below is module for Dll link and below that the Modified VB6 code



Module

Option Explicit

Declare Function Initreceivep6 Lib "socket.dll" Alias "receivep6" () As Long

Declare Function Datareceive Lib "socket.dll" Alias "receive" () As Long

Declare Function Datatransfer Lib "socket.dll" Alias "transfer" (ByVal variable As Long) As Long

Declare Function Datatransferp5 Lib "socket.dll" Alias "transferp5" (ByVal variable As Long) As Long

Declare Function Setdata Lib "socket.dll" Alias "setdata" (ByVal variable As Long) As Long

Declare Function Cleandata Lib "socket.dll" Alias "cleandata" (ByVal variable As Long) As Long

Declare Sub Setip Lib "socket.dll" Alias "setip" (ByVal variable As String)





VB6 code

Option Explicit

Dim wr_iostatus



Private Sub Delay(Optional ByVal HowLong As Single)

Dim OldTime As Single, Continue As Single



OldTime = Timer



Do While Continue < HowLong

Continue = Timer - OldTime

Loop



End Sub



Private Sub Command2_Click()

Dim J

J = Datatransfer(wr_iostatus)

Form1.Text1 = "io control setting val : " & J

End Sub



Private Sub Command3_Click()

Setip (Text2.Text)

Call Form_Load

End Sub



Private Sub Command10_Click()

Command10.Visible = False

Command18.Visible = True

wr_iostatus = Setdata(&H40)

End Sub



Private Sub Command11_Click()

Command11.Visible = False

Command19.Visible = True

wr_iostatus = Setdata(&H80)

End Sub



Private Sub Command18_Click()

Command10.Visible = True

Command18.Visible = False

wr_iostatus = Cleandata(&HBF)

End Sub



Private Sub Command19_Click()

Command11.Visible = True

Command19.Visible = False

wr_iostatus = Cleandata(&H7F)

End Sub



Private Sub Form_Load()

Dim P6



Timer2.Enabled = True



P6 = Initreceivep6



If (P6 And &H40) Then

Command10.Visible = False

Command18.Visible = True

Setdata (&H40)

Else

Command10.Visible = True

Command18.Visible = False

Cleandata (&HBF)

End If

If (P6 And &H80) Then

Command11.Visible = False

Command19.Visible = True

Setdata (&H80)

Else

Command11.Visible = True

Command19.Visible = False

Cleandata (&H7F)

End If

End Sub





Private Sub Timer2_Timer()

Label6.Caption = Date & Time

End Sub





Regards PT
Regards

PT

If it isn't broke,fix it till it is!
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Have you tried to use the Script Device for this? I'm not sure whether you can declare external functions in the script for this to be possible, but it's worth a shot.
Scott
PT
Senior Member
Posts: 147
Joined: Wed Apr 13, 2005 12:32 pm
Location: Hampshire.UK

Post by PT »

Scott

I have revisited this issue and have 2 more questions for you.I have managed to trim the VB code and now have a small window( with buttons etc) which I am controlling with girder and using housebot to send internet events. I have a task with a dynamic image which changes when the item is on /off. However this is blind communication as per infrared.

I will be looking at using VBscript to use with the script device. When the .dll is queried it provides response say "&H40" this is related to a switch being say on.Return value of &H80 being off.( for a given switch)

If I can get the VBscript to work, how can I get the return value into Housebot?

Secondly I also have a sdk for C++. Could this be used with housebot device sdk and more importantly how hard is it to compile. Do you need C++

Thanks in advance for help/suggestions
Regards

PT

If it isn't broke,fix it till it is!
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

PT wrote:If I can get the VBscript to work, how can I get the return value into Housebot?
Within the VBScript Device, you can either execute a Task or set a Property Value. So, for example, when you receive "&H80" you can call the SetPropertyValue() command from the VB Script. You pass it the Device, Property, and new value. You may need to create a new Device from a NULL Device and add properties to construct the Device with the properties you need.
Secondly I also have a sdk for C++. Could this be used with housebot device sdk and more importantly how hard is it to compile. Do you need C++
I can't say for sure, since I haven't seen the SDK, but if they are providing one, I'm assuming it should be possible. However, you do need to know a bit about C++ to be able to wire it all together. And "yes", you will need a C++ compiler and linker to build the plugin.
Scott
PT
Senior Member
Posts: 147
Joined: Wed Apr 13, 2005 12:32 pm
Location: Hampshire.UK

Post by PT »

Scott



Thanks for the reply.

The C++ sdk in fact uses pretty much the same arguments as the VB and indeed the same dll.

I need to see how the vbscript communicates with the dll first.

In my vb.exe it is a moudle wihich parses the info from the dll.

I am pretty new to the vb stuff so I am just feeling my way around the various flavours.

Any help/pointers much appreciated.
Regards

PT

If it isn't broke,fix it till it is!
PT
Senior Member
Posts: 147
Joined: Wed Apr 13, 2005 12:32 pm
Location: Hampshire.UK

Post by PT »

Scott



I have looked at this further and it would seem I need to have an activeXdll for vb script to work(No idea how to do this yet). :? I believe I will then be able to communicate with the dll I have from vb script.

However in my playing and reserch I now have a vb program which accepts internet events( as per girder) so I can code up (one way) direct access to my controller in one vb program.

I guess i could also link back status(actual not just instruction) with external com control.

I will aslo be buying C++ in the next few days to look at making the device.
Regards

PT

If it isn't broke,fix it till it is!
Post Reply