Re: Global Cache GC-100-12 control

1,048 views
Skip to first unread message

TomL

unread,
Dec 11, 2012, 2:11:11 PM12/11/12
to tas...@googlegroups.com
No, http GET won't work in your case.  When a client sends a Http get request (like "http://www.google.com:80/index.html") to a server machine ("www.google.com"), a web server app on the server machine listening on port 80 handles that request and sends back the requested item ("index.html").  

client to server: "Hey, www.google.com, talking to port 80.  Give me document: index.html.  [over]"
server to client: "Sure thing, here: [coontents of index.html]. [over]"
The End.

What you have going on is more like a serial terminal connection on port 4998

client to server: "hey XXX.XX.XXX.XXX, talking to port 4998.  You there?"
server to client: "yeah."
client to server: "1,1\x0D"
server to client: "er, ok."
client to server: [after waiting 0.8 seconds] "1,0\x0D"
server to client: "er, ok."
The End


Basically, you're using a shell script to launch a ssh client to connect to the remote host (your server).  Once the connection is made, you would then shoot your serial commands:

1,1\x0D
\x0D
\x0D
\x0D
\x0D
\x0D
\x0D
1,0\x0D

The extra "\x0D" in the middle are to establish the 0.8 second "pause".  Then close the connection.

I would try this all out interactively at the shell command line first before using Tasker in any way.  

Tom

On Tuesday, December 11, 2012 12:25:23 PM UTC-5, Andy Z wrote:
I use a global cache gc-100-12 device for home automation.  I control it with an app called iRule and it sends IR commands to my AV equipment and also use its relay closures to control my garage door.

iRule doesn't have a widget which is where Tasker comes in.  I would like to create 2 widget icons, 1 for each garage door, and send the commands required to open or close each when pressed.

The gc-100-12 listens on port 4998 and when connected via wifi to my network it is reached on a stanard internal IP address, the control protocol is available here:



The command string for garage door 1 as sent via iRule is:  1,1\x0D  a delay of .8 seconds and then 1,0\x0D

This replicates the pressing of the garage door button and releasing it which triggers the door to either open or close.  It completes the circuit for .8 seconds.

1,1 and 1,0 are the commands followed by a standard carriage return.

I must admit that I am totally new to Tasker and plan to delve deeper in to what it can do for me, but this is why I bought it and I have no idea how to proceed from here.

I am thinking that an http get process with XXX.XX.XXX.XXX:4998 address is the start, but from there I am not sure how to enter the rest of the info to send the commands.

Any help would be greatly appreciated.  

GermainZ

unread,
Dec 11, 2012, 2:32:43 PM12/11/12
to tas...@googlegroups.com
Nice idea using a shell script.
Regarding the waiting part, wouldn't usleep 800 work as well?

Andy Z

unread,
Dec 11, 2012, 2:57:24 PM12/11/12
to tas...@googlegroups.com
Ok, thanks for the replies, but I am at a loss with how to get this going.  

The global cache needs to be sent the command in this format based on their documentation:

5.3.2 Relay Closures
GC-100 relays are activated by sending a "1" state and deactivated with a "0."  Activation of a normally
open contact will close (or connect) the relay output pins, while a normally closed contact will open (or
disconnect) the relay output pins. Note: relay states are not preserved through a power cycle and all
relays will return to their inactive state until a 1 state is re-sent.
setstate
Relay state is set as follows:
setstate,<connectoraddress>,<outputstate>↵
where;
<connectoraddress> is defined in section 1.
<outputstate> is |0|1| (where 0 is inactive, 1 is active)


so for my garage door 1, the relay address is 3:1 so the sequence would be:

setstate,<3:1>,<1>↵
pause for .8 seconds
setstate,<3:1>,<0>↵

So, this is the info I need to send in a shell command, but not sure how to test this in a cmd line in windows to start and definitely now sure how to go about sending this via Tasker.

Again, thanks to all for taking a look at this.  

TomL

unread,
Dec 11, 2012, 8:54:05 PM12/11/12
to tas...@googlegroups.com
From windows, find and launch the telnet client. It may also be called hyperterminal. if you can't find it, you can always google for "putty" and install that.

Using telnet or hyperterminal or putty, open a telnet (not ssh, just regular telnet) connection to your server xxx.xx.xxx.xxx port 4954 (or whatever the specific number). Then start typing the commands in by hand.

Does that do anything?

Tom

TomL

unread,
Dec 11, 2012, 8:56:27 PM12/11/12
to tas...@googlegroups.com
I think it would be more like usleep 800000 if you want 0.8 seconds. or you can just blindly pad the input with carriage returns and hope for the 0.8 second delay. :)

Tom

Andy Z

unread,
Dec 12, 2012, 10:13:41 AM12/12/12
to tas...@googlegroups.com
From the CMD line in Windows 7 I typed telnet, this started the telnet client.

I entered open XXX.XXX.X.XXX 4998 it said connect too.... and just stays there, any key I press from there causes a unkowncommand 14 to be displayed.

Andy Z

unread,
Dec 12, 2012, 10:48:27 AM12/12/12
to tas...@googlegroups.com
I tried putty per your suggestion.  This works a little better, I get a connection and a shell.  I opened a TCP connection per the instructions from global cache.  I tried
setstate,3:1,1 follow quickly by setstate,3:1,0 as fast as I could type it.  A few times a return message was received but followed so closely by unknowncommand 14 that I couldn't read it.  The garage door didn't respond though.

I was able to send the getversion command and get a response, but in the putty window the returned version is immediately replaced by unknowncommand 14 message

blink,1 and blink,0 work to first start the power led blinking and then stop it, both follow immediately with unkowncommand 14

So, some moderate movement in the right direction.....


Andy Z

unread,
Dec 12, 2012, 11:22:58 AM12/12/12
to tas...@googlegroups.com
Ok, some further movement.  Global Cache has their own program, iTest that will send strings to the unit.

setstate,3:1,1 opens the garage door.  

I have no idea why the same thing doesn't work via putty.  Could it be the carriage return?  I was just hitting "Enter" is there some syntax like what is found in irule, \x0d, that is needed in putty?

So, I have the IP address and port, the commands are confirmed to work via the global cache utility.  

The timing of the setstate,3:1,0 does not appear to be that important or time sensitive.  It just needs to be sent before another command to trigger the door can be sent.

I have opened a ticket with global cache to inquire about why the same setstate,3:1,1 command does not work with Putty.   

A few steps in the right direction, now what?

Thanks again for the support.


TomL

unread,
Dec 12, 2012, 12:01:41 PM12/12/12
to tas...@googlegroups.com
You're getting very close.  You can use putty to send the getversion command to the server and get a response?  Let's focus on that.

I think you'll probably need to tweak one or two of putty's terminal emulation settings.  Try changing Config > Terminal:

"Implicit CR is every LF"
or
"Implicit LF in EVERY CR"

Also changing Config > Connection > Telnet:
"Return key sends Telnet New Line instead of ^M"


Tom

TomL

unread,
Dec 12, 2012, 12:28:38 PM12/12/12
to tas...@googlegroups.com
If you can reliably connect to your server using telnet and issue it commands by hand, you can move to the next step of doing it from a terminal program on your phone.  Same idea, you're opening a telnet session to the server and typing in commands.

The next step would be to use a linux command like nc (http://linux.die.net/man/1/nc) to send the commands to the server directly.  Depending on your phone, you may need to install busybox in order to get the nc command.  You would use nc kind of like this:

echo -n "getversion\r\nsetstate,3:1,1\r\nsetstate,3:1,0\r\n" | nc 123.45.678 4998

When that (or something like that) works, then you can put that command, into a Tasker Run Shell action, in a Task, that you can call from a shortcut, on your launcher screen.

Andy Z

unread,
Dec 12, 2012, 1:28:00 PM12/12/12
to tas...@googlegroups.com
Ok, now we're getting somewhere....

I installed Telnet Client from the playstore on my phone (EVO 4G LTE).  Open the terminal with IP and port.  I typed setstate,3:1,1 and pressed the execute button and the garage door went up.  setstate, 3:1,0 execute and then setstate,3:1,1 again and the door when down.

All commands received the standard response from the server that the command was received by indicated state,3:1,1 or state,3:1,0 as the case may be.

My phone is not rooted so busybox is not an option.

I feel like I'm super close here.  Thanks so much for the time TomL.  

So, I need tasker to open the telnet session, send the setstate,3:1,1 command, wait a short time and then send setstate,3:1,0 command and then close the telnet session.


TomL

unread,
Dec 12, 2012, 2:17:41 PM12/12/12
to tas...@googlegroups.com
Woohoo!  

1. Now for the last part.  Ideally you can avoid having to have Tasker go through the Telnet GUI to send the commands.  Not having root makes things tough, as almost all the cool command line networking tools need root.  You're basically looking for a Tasker plugin or any app that can accept an intent to open a TCP port to a remote server and allow you to send arbitrary strings.

2. If not, then you may be able to use Tasker's sendkey / sendevent / inputevent actions to script the launching of the telnet client,and the typing of the commands.

3. One last trick, which is a long shot, is to use a system log viewing utility, like logcat, to watch the Android system logs when you use the iRule app to open and close the garage door.  There's a chance that you might discover the intents that the iRule app uses and you may be able to use Tasker to send those intents to the iRule app and get it to do the garage door commands without needing to go through the iRule app UI.


Tom

TomL

unread,
Dec 12, 2012, 2:39:14 PM12/12/12
to tas...@googlegroups.com
Be warned that your network traffic between your phone and your server is visible and unencrypted to anyone on the network.  Meaning, anyone motivated enough can discover how to open your garage door remotely.

Tom

GermainZ

unread,
Dec 12, 2012, 2:50:18 PM12/12/12
to tas...@googlegroups.com
(About Tom's 3rd point) Some of the app's intents can be seen in the manifest. Decompile its apk and look for <intent <intent-filter> in AndroidManifest.xml. There might be more than one paragraph.

Andy Z

unread,
Dec 12, 2012, 2:52:17 PM12/12/12
to tas...@googlegroups.com
I've thought about that, the port is blocked to external traffic in my router which secures it a little bit more I think.  My router is secured with WPA2.  I know that it is possible to hack all of this.  I figure if anyone is motivated enough to do so would likely pick a target that had more to offer than my home does.  Also, a crowbar could do the same thing.

I'm lost by everything else you've said below.  

I see how to launch an app via tasker, but how to tell it to execute the desired commands and finish with QUIT....

Matt R

unread,
Dec 12, 2012, 6:15:16 PM12/12/12
to tas...@googlegroups.com
This app works really well for me to view app manifests without having to decompile them.  Also, this one works well for grabbing intents that get broadcast sometimes.

Matt

TomL

unread,
Dec 13, 2012, 8:58:03 AM12/13/12
to tas...@googlegroups.com
Andy, have a look at this (long ) thread about Tasker and EventGhost:


Maybe it might be relevent?

Tom

On Wednesday, December 12, 2012 1:28:00 PM UTC-5, Andy Z wrote:

Andy Z

unread,
Dec 13, 2012, 1:46:34 PM12/13/12
to tas...@googlegroups.com
This rabbit hole is getting deeper all the time.

I was hoping to avoid the need to use a PC for this, especially since I can open and close the garage door with my phone currently without the need for one.

But, i'd like to have an instantly executable widget/button to trigger the garage doors and possibly be able to add a tasker condition that opens it when near my SSID, still thinking about that.

So, I installed EventGhost on my PC and set up 2 macros, 1 for each garage door that triggers the commands, they work fine and return the feedback expected within Event Ghost.  

I've attempted to configure several android apps: tremote, EGremote and the actual Event Ghost app.  I haven't been able to figure out how to trigger the event ghost macros for the doors.  

 I am sure it is user error and this certainly isn't the forum to get help with those apps.

Every time I see the light at the end of the tunnel on this it turns out to be a train.  I made such quick work of setting up the macros in Event Ghost on the PC that I figured it would be quick work from there to trigger them via android.

Andy Z

unread,
Dec 13, 2012, 6:09:15 PM12/13/12
to tas...@googlegroups.com
Ok, getting closer...I think.

Installed terremote and the terremote tasker plug in.

Configured terremote and eventghost to communicate.  Sent eventghost a message of g1 and assigned that to the eventghost macro for garage door 1, did the same with a g2 message.  Saved these messages in terremote, assigned them each to a button and within terremote pressing each of the buttons triggers the respective garage door.  So this puts me back where I was at the start with iRule of having a button on my phone that triggers the garage doors, but with the added benefit that terremote and tasker can communicate.

So from here it should be a simple thing to achieve my goal:  2 widgets/button on my home screen that control the doors.

Not so fast.  I can't for the life of me figure out how to have tasker tell terremote to send the g1 message.  


Andy Z

unread,
Dec 15, 2012, 7:24:04 PM12/15/12
to tas...@googlegroups.com

Ok, taking a different tack.  

Going back to iRule to get this done.  I don't want to be running Event Ghost on a PC all the time to enable this.  It works with iRule alone and that is good enough if....I can use Tasker to launch iRule automatically when I come within range of my SSID.

Is that possible?  I've been playing around with Tasker trying to get that to work and am not finding a way to do this.  If I set it to launch when connected to my home SSID, it launches all the time when I'm home which is not what I want.  I currently have it set to launch when near my SSID, headst is plugged in and power  is any as this means I am in my car.  

Is there some sort of variable I am missing to set it to launch the app only when first encountering the SSID like when the phone switches from 3G/mobile data to my home wifi?

Because I would like to remove the need to indicate the phone is plugged in and has a headphone jack connected.  I would like to be able to use this simply when on a walk or in someone else's car returning to home, pull the phone out and bam, there's my garage door opener.....






Matt R

unread,
Dec 15, 2012, 9:39:36 PM12/15/12
to tas...@googlegroups.com
It should only fire once (when the profile first goes active). Is this profile going active and inactive over and over? Try checking the run log for confirmation (menu button -> more -> run log).

Matt

Reply all
Reply to author
Forward
0 new messages