Sorry for my question ( i'm newbie) and for my English (i'm italian) ...:) ...
I have a simple switch over ethernet that i use for different utilities( light, radio, etc) .... I can switch on or off on browser with command
192.168.1.201/forms.htm?led1=1 ----> turn on
192.168.1.201/forms.htm?led1=0 ----> turn off
how can I create a device that implements this switch? i have to write code or i can use any template?
Thanks a lot
Claudio
Hi,
You have to write some code. But you can create GSD template, which is simpler than a full c++ template. Search the wiki for GSD to get started.
You should also get an understanding of the device template system before starting.
br,
sambuca
The Panasonic IP camera template is a good example of using GSD to talk over TCP to an HTTP socket.
-Thom
Thanks......i'll try ....
Claudio
The wiki is down so i cannot see if there's any more direct HTTP-support in GSD, but take a look at this: http://snippets.dzone.com/posts/show/788
It contains most of what you need to initiate a HTTP POST from Ruby.
/Joakim
thanks.....i have turn on my first light!!!!! ;D
but i hardcode :-[ the path and ip.....infact
.. when i use variable path (device_.devdata_[2];) i have the path with ip address.
example
in config: path is only "/forms.htm"
in log if i print variable: path is "192.168.1.201/forms.htm"
i need two different value: ipaddress and path!
with path i can use a my new data, but with ip? how can i have he value of ip?
thanks again!!!
Just add it to the device template, use the "Device Data" section to add as many as you like.
/Joakim
OK....done... perfect! (the error was because i hadn't restart router)
but if i want know the device data IP in ruby code?
Other data have a number (example #2 for path) .. IP data no!!! I wish not replicate IP in other data field.
How i have to do? where i can find the all property of device object?
PS: sorry.....I hope that my behavior is correct, otherwise I apologize
I think your behaviour is not only correct, I think it's exactly as expected. But perhaps this discussion should be in the Developer's forum and not in the Users.
All the device data is stored in the devdata vector. I've looked around, but not found a complete list of the index numbers to use to retrieve the various data. Some I've found:
12 - Child ID
59 - User Code
249 - 3Phase
999 - Serial Number
114 - User name
115 - Password
2 - fix_path
More info http://wiki.linuxmce.org/index.php/Edit_Device_Template
Anyone who knows where there's a complete list of index numbers?
/Joakim
/Joakim
Joakim,
usually, when I am faced with DeviceData information, I look at mysql pluto_main.DeviceData, but the information in there looks different that one you've laid out
as Possy says, the best way is to look at the data in the database. The Web admin's Advanced->DCE->Device Data page can help here, giving you the device data name, its number, its parameters, and what device templates use this command.
-Thom
Hi ,
I am a bit confused over how to compile the http request, I am comparing with the Panasonic IP Camera but I am not sure of how the 192.168.1.201/forms.htm?led1=1
would fit in.
please advice me.
thanks Stefan
I'm very happy... if i can help u....
but now I do not have access to the code. Tonight I'll copy the code here and I'll explain how to do
Claudio
ok...... look my code......if you have other problem...say me .. i
But because Joakim said: "perhaps this discussion should be in the Developer's forum and not in the Users." .... ;D ....perhaps we have to open a new topic in Developers!!
require'net/http'
fix_path=device_.devdata_[2];
fix_path='/'+fix_path if(fix_path[0]!='/'[0]);
h=Net::HTTP.new('192.168.1.201',80)
resp,data=h.get(fix_path+absolute_channel.to_s,nil)
absolute_channel is an input parameter.
fix_path is a device_data "path"
Claudio
PS:last problem (for me) is a IP: i have hardcode the ip ....
Thank you Claudio i will see if I understand.
Best Regards Stefan
the ip address is available as a variable. Please look at the Panasonic IP Camera template.
-Thom
I'm very sorry...thom.....but i dont find the ip variable in IP Camera template.
Perhaps i don't use conn object? is a problem?
IP Camera Template Code
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
fix_path=device_.devdata_[2];
fix_path='/'+fix_path if(fix_path[0]!='/'[0]);
s = "GET "+fix_path+" HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"
conn_.Send(s)
My Code
require'net/http'
fix_path=device_.devdata_[2];
fix_path='/'+fix_path if(fix_path[0]!='/'[0]);
h=Net::HTTP.new('192.168.1.201',80)
resp,data=h.get(fix_path+absolute_channel.to_s,nil)
Claudio
you're making this too hard, bro.
way too hard.
seriously, stop. before I smack you.
if you use conn_. guess what?
all of those details are set up for you, you just need to send and receive data down that pipe appropriately.
*thwap-you-upside-the-head* ;)
-Thom