PDA

View Full Version : Best strategy for raising Girder events from cell phone?



Agonostis
May 28th, 2005, 01:24 PM
Cliff's notes: How would you raise a Girder event from your cell phone?

The whole Dickens:
I just moved to a new apartment and am redoing my girder-based cell-phone door unlocker.

The first version of this setup worked by sending an SMS (text message) to an AIM client. Girder running the taskcreate plugin raised an event when the IM window popped up, checked the name of the window (to determine that the IM was from my cell phone), and triggered the relay (wired to the intercom in the brownstone I was then living in).

This worked, but was pretty simplistic. When I got a new Windows Mobile-based cell phone, I redid it:

The second version worked through Windows Messenger and LuaCOM, but was essentially the same. The role formerly played by taskcreate was replaced by Lua interrupts (or whatever you call them, the one I used was OnMessageReceived in the Messenger COM object). More elegant, but same basic idea.

Now, I still have my WM-based cell phone, and my two roommates both have Blackberries. I can easily send SMS and Windows Messenger IMs, they can easily send SMS and email. We have a similar kind of intercom connected to the front door in our new apartment.

Given these criteria, what should my event-raising strategy be? Right now, the best I can come up with is a hodge-podge of setup1 and setup2; AIM-based for them, WinMessenger-based for me. This is not as pretty as I'd like, and I'm wondering if anyone has any better ideas?

Thanks a lot!

Promixis
May 28th, 2005, 01:54 PM
You had this working with Messenger and you didn't tell me! :)

Cool!

I am wondering too and I have the new Audiovox 5600. What about serving a webpage using Girder?

Agonostis
May 28th, 2005, 03:22 PM
I got it working, but never did all the things I wanted to do (there's never enough time!). I'm starting a new job July 6, and have some time between now and then to tweak it.

The web page is an interesting idea. Can you go into some more detail? How would I secure it (i.e., make sure only myself and my two roommates can unlock the door)?

Promixis
May 29th, 2005, 06:22 AM
There is the hppd plugin. Security will be an issue (as always...)

Agonostis
May 29th, 2005, 12:24 PM
Well, security is pretty important here...this is not changing the volume on my receiver, this is unlocking my front door!

In the AIM setup, the taskcreate plugin checked the name of the window, which is the cell phone number from whence the SMS originated; not my (or the flavor of the week's) number, no unlocky.

In the Messenger Setup, the idea was pretty much the same (though less clunky): the Lua code checked various account details (usually screen name and email address) of the originating message.

I can't immediately come up with a way to do similar screening via a webpage, especially when the connections will be from cell phones, which I doubt have static IP addresses!

I'd love to be proven wrong, though, as the webpage approach has a lot of other advantages. Any way I can secure it against a list of 3-5 "priveleged" event-raisers (without having to enter a password or anything else that might cause my roommates to say they'd rather just use the damn key!)?

danward79
May 29th, 2005, 01:38 PM
I have just been playing around with this, and got my lights going from my mobile.

I wonder if it would be possible to add a passworded web page?

Agonostis
May 29th, 2005, 01:45 PM
@Danward, how do you communicate between your mobile and girder?

danward79
May 29th, 2005, 10:55 PM
Hi

I used the httpd demo, and modified it to receive events and send them to the pc with my x10 controller on.

This is my HTML file,

<html>
<head>
<title>Home Control</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>
<body>
<h1>Flat Control</h1>


Use Links below to operate device



Office Lamp (index.html?X10LightsOnorOff&X10Light3)

HiFi Lamp (index.html?X10LightsOnorOff&X10Light2)

Standing Lamp (index.html?X10LightsOnorOff&X10Light1)

Aquarium Light (index.html?X10LightsOnorOff&X10Light4)

</p>
</body>
</html>

I then set up a command line in girder to execute


C&#58;\Program Files\girder\ieventc.exe

and in Step size I put the following


192.168.0.4 1024 girder &#91;pld1&#93; &#91;pld2&#93;

So then, I pointed my mobile phones browser to the url and port of my system, so "http://123.456.789.1:xxxx/index.html"

and then clicked the links to control the lights, easy! :wink:

the screen is only 176 x 220 on my phone but it is still a cool concept. I have a motorola e398 at the moment.

It would be nice if I could work out how to send some stuff to the page like, the current status of the lights etc.

mhwlng
May 29th, 2005, 11:22 PM
it's a bit simpler than that :D

you don't need ieventc.exe

you can learn an httpd event !

the latest httpd plugin can run luascript and display lua variables :

something like this works :

<html>
<head>
<title>Girder Httpd demo</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>
<body>
<%
teststring="sometext"
a= 5
b = 6
c= a + b
%>
contents of teststring :
<%=
teststring
%>

contents of c :
<%=
c
%>

</body>
</html>


simple feedback, back to girder is also posible by clicking a hyperlink.
forms/unicode html files etc. are not supported...

if you use an = sign in the cgi parameter, it ends up as a global variable

without the = sign, it only ends up in the pld? variable

index.html?testing1&testing2 fills pld1 with "testing1" and pld2 with "testing2"

index.html?a=5 creates a global variable a and sets it to value 5

so code like this works in the httpd event:
TriggerEvent(pld1,18 )

and the links would be

http://192.168.0.1/index.html?someevent
http://192.168.0.1/index.html?someotherevent


Marcel

mhwlng
May 29th, 2005, 11:39 PM
hmmm

it seems in the move from girder.nl to promixis.com, the httpd plugin reverted to an older version ????

use the one from the link in my sig. instead. (it was already included in the marcel 1.2.zip)

Marcel

danward79
May 29th, 2005, 11:57 PM
I was going to say! "I can not get the variables to work!"

Thanks Marcel

danward79
May 30th, 2005, 12:36 AM
Marcel,

How can a variable be set in girder and displayed on the html page?

mhwlng
May 30th, 2005, 12:44 AM
see my marcelv1.2.zip

imdb.lua and imdb.htm

(look at the comment at the top of imdb.lua)

Marcel

danward79
May 30th, 2005, 01:12 AM
Cool figured it out thanks!

Any ideas on security?

mhwlng
May 30th, 2005, 01:18 AM
that's tricky

because forms aren't supported, so you can't enter a password in an edit box...

forms support would require a serious amount of coding.
I don't have time to add such a feature, but the source code to the plugin is available :D

of course, you could add a password as a cgi parameter,

so anyone just requesting the page will get nowhere, only with :

http://192.168.0.1/index.html?someevent&secretpassword

not very secure though, if someone reads the url on the phone or in the favorites list of the browser or the browser cache...


Marcel

danward79
May 30th, 2005, 02:18 AM
Thanks, I suppose that is a start. Better than nothing

Agonostis
May 30th, 2005, 12:35 PM
Thanks guys, this seems like a great new strategy to try out!

I have what is probably a silly question: in my new place I have cable modem and a router; will I need to open a port on the router for the httpd plugin to work? (I haven't even looked at the plugin yet, so i apologize if this is obvious).

Thanks again.

danward79
May 30th, 2005, 12:39 PM
Hi,

In my router, I just setup a port forwarding.

Agonostis
May 30th, 2005, 10:47 PM
Alright, I cannot get this to work.

I put the plugin in the plugins directory. I enabled it in girder. I set it to look at a port. I forwarded that port in my router. I set it to look at C:\test. I created C:\test and put the included sample index.html in the C:\test directory.

I imported the sample .gml. I open up index.html, click all the links, and nothing happens.

What am I missing? Sorry if it's obvious, and thanks everybody for their help.

Update: Fussing with the event got it to work. Now i can trigger events from my phone from the web browser (awesome!), but the variable stuff does not work (pld1 never changes no matter which link i click in the sample)

Any suggestions?

danward79
May 31st, 2005, 01:56 AM
Hi,

To get variables to work, I am assumming you mean variables set from girder.

Try this


<html>
<head>
<title>Home Control</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>
<body>
<h1>Flat Control</h1>
<%
x= whatisx&#40;&#41;
%>
x is equal to&#58;
<%=
x
%>


Use Links below to operate device



Office Lamp (index.html?X10LightsOnorOff&X10Light3)

HiFi Lamp (index.html?X10LightsOnorOff&X10Light2)

Standing Lamp (index.html?X10LightsOnorOff&X10Light1)

Aquarium Light (index.html?X10LightsOnorOff&X10Light4)

</p>
</body>
</html>

Then make a function in girder lua like this


function whatisx &#40;&#41;

x = "Hello"

return x

end

you will need to run that code first before you goto the webpage, that way the function is in the memory. You could also have the function linked to an event code etc. but that is just an example. You could probably have the variables linked to hyperlinks to, but I did not get that far.

mhwlng
June 5th, 2005, 10:31 AM
Dan...


Because forms aren't supported, so you can't enter a password in an edit box...

I thought of a better way :

Just create a bunch of buttons that form a decimal keypad, each with a url like :

http://192.168.0.1/index.html?onebutton
http://192.168.0.1/index.html?twobutton
http://192.168.0.1/index.html?backspacebutton
http://192.168.0.1/index.html?enterbutton


etc.

and then handle the button presses in Girder (with some feedback of '*' characters when the page is refreshed)

and compare the password when the enter button is pressed.


Marcel

danward79
June 5th, 2005, 10:47 AM
Nice Idea, I like that. Cheers