Author Topic: Generic IP Device - Configure  (Read 1998 times)

ClaudioLNX

  • Newbie
  • *
  • Posts: 7
    • View Profile
Generic IP Device - Configure
« on: October 31, 2011, 12:31:47 pm »
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

sambuca

  • Guru
  • ****
  • Posts: 449
    • View Profile
Re: Generic IP Device - Configure
« Reply #1 on: October 31, 2011, 12:55:03 pm »
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

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5505
  • DOES work for LinuxMCE.
    • View Profile
Re: Generic IP Device - Configure
« Reply #2 on: October 31, 2011, 01:52:43 pm »
The Panasonic IP camera template is a good example of using GSD to talk over TCP to an HTTP socket.

-Thom

ClaudioLNX

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Generic IP Device - Configure
« Reply #3 on: November 01, 2011, 12:56:41 pm »
Thanks......i'll try ....

Claudio

JoakimL

  • Veteran
  • ***
  • Posts: 149
    • View Profile
Re: Generic IP Device - Configure
« Reply #4 on: November 02, 2011, 09:45:22 am »
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

ClaudioLNX

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Generic IP Device - Configure
« Reply #5 on: November 05, 2011, 04:01:51 pm »
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!!!

JoakimL

  • Veteran
  • ***
  • Posts: 149
    • View Profile
Re: Generic IP Device - Configure
« Reply #6 on: November 05, 2011, 06:11:25 pm »
Just add it to the device template, use the "Device Data" section to add as many as you like.

/Joakim

ClaudioLNX

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Generic IP Device - Configure
« Reply #7 on: November 06, 2011, 12:04:23 pm »
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


JoakimL

  • Veteran
  • ***
  • Posts: 149
    • View Profile
Re: Generic IP Device - Configure
« Reply #8 on: November 06, 2011, 06:15:43 pm »
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

posde

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3059
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Generic IP Device - Configure
« Reply #9 on: November 06, 2011, 06:18:55 pm »
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

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5505
  • DOES work for LinuxMCE.
    • View Profile
Re: Generic IP Device - Configure
« Reply #10 on: November 06, 2011, 10:55:37 pm »
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

ladekribs

  • Veteran
  • ***
  • Posts: 86
    • View Profile
Re: Generic IP Device - Configure
« Reply #11 on: November 09, 2011, 06:49:34 pm »
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

ClaudioLNX

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Generic IP Device - Configure
« Reply #12 on: November 10, 2011, 03:59:49 pm »
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

ClaudioLNX

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Generic IP Device - Configure
« Reply #13 on: November 10, 2011, 08:56:50 pm »
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!!

Code: [Select]
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 ....
« Last Edit: November 11, 2011, 07:19:03 am by ClaudioLNX »

ladekribs

  • Veteran
  • ***
  • Posts: 86
    • View Profile
Re: Generic IP Device - Configure
« Reply #14 on: November 10, 2011, 09:39:55 pm »
Thank you Claudio i will see if I understand.

Best Regards Stefan