Author Topic: Question about GSD...  (Read 6850 times)

mkbrown69

  • Guru
  • ****
  • Posts: 213
    • View Profile
Question about GSD...
« on: March 19, 2013, 03:25:45 am »
Good day folks!

I'm working on a device template using GSD for an IP enabled device, and I was wondering if it's possible to obtain the IP address of the device from device data?  I'm building various URL's for device control, and it would be cleaner to be able to retrieve the IP address from the device's data...

Thanks for your time!

/Mike

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Question about GSD...
« Reply #1 on: March 19, 2013, 04:12:02 pm »
why? If your TCP port device data is set correctly in your Device Template, and the IP address is properly set in the device instance, then GSD will open up a socket to it, and give you the conn_ object to communicate with it.

-Thom

mkbrown69

  • Guru
  • ****
  • Posts: 213
    • View Profile
Re: Question about GSD...
« Reply #2 on: March 20, 2013, 02:52:45 am »
Hi Thom!

Why?  To be different, of course!  ;)

Seriously, though, the device in question has a SOAP interface used to subscribe to events emitted by the device, and a REST interface to control it.  I have a basic set of commands working to control it via REST, using a hard-coded variable for the IP.  Before I go writing code to query the device table directly, I'm asking for a less ugly, more Thom-approved method.   ;D

I plan on getting to the subscription stuff next using the conn_object.  It's slow-going teaching myself SOAP, XML parsing, and ruby all at once, plus figuring out the relevant LMCE infrastructure.

Thanks for your time!

/Mike

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Question about GSD...
« Reply #3 on: March 20, 2013, 03:38:52 am »
DUDE... if you're needing to get the IP address, you're doing it wrong.

Again, is your IP address specified in your device instance (Advanced > configuration > devices) ?
Do you have a TCP Port device data defined?

-Thom

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Question about GSD...
« Reply #4 on: March 20, 2013, 03:40:55 am »
Why don't you stop by the IRC channel (#linuxmce-devel, on irc.freenode.net), we can help you there.

-Thom

mkbrown69

  • Guru
  • ****
  • Posts: 213
    • View Profile
Re: Question about GSD...
« Reply #5 on: March 20, 2013, 04:16:52 am »
Hi Thom,

I'm not that IRC saavy/equipped; I should probably add that to my list of things to learn.  I'm also not sure how well it'd work via my iPad since I bounce between Safari, Textastic, and iSSH.  Long story...

Anyway, based on my understanding of the devices' SDK, it needs a channel for the subscription for the SOAP events with a periodic heartbeat response, and commands are sent via the REST interface (so, two connections).  Based on my understanding of the conn_object, it's a single channel implementation, but bi-directional.  This all is with the caveat/disclaimer that I don't play a programmer on TV or the Internet;  I'm a sysadmin who's managed to learn enough about programming to be able to glue various bits and pieces together.

So, I have this little private method which works beautifully, and I can control manually-defined children lights of the device quite nicely.

Code: [Select]
def sendISYcommand(command)
#$username=device_.devdata_[114].to_s
#$password=device_.devdata_[115].to_s
#$host=device_.devdata_[?].to_s

$host = "192.168.80.148"
$port = device_.devdata_[69].to_s
res = Net::HTTP.start($host) {|http|
req = Net::HTTP::Get.new(command)
req.basic_auth device_.devdata_[114].to_s, device_.devdata_[115].to_s
response = http.request(req)
xml_data = (response.body)
log("====== / sendISYcommand response body ======")
log(xml_data)
log("====== sendISYcommand response body / ======")
doc = REXML::Document.new(xml_data)
log(doc)
s = REXML::XPath.first(doc, "RestResponse/status")
log(s)
return s.text
}
end
I'll worry about http/https via the port data later when the driver is close to completion.  Pulling device data like username & password works well.  I'm just looking to find a means to obtain the IP cleanly for sending these REST commands.  My next project is the conn_object for the subscription, and figure out all the other xml parsing that'll go along with it.

Thanks again for your time and guidance.

/Mike
« Last Edit: March 20, 2013, 04:31:06 am by mkbrown69 »

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Question about GSD...
« Reply #6 on: March 24, 2013, 07:57:51 am »
You can stop by the channel using one of a few methods:

* Windows: mIRC http://www.mirc.com/
* Mac: Colloquy http://www.colloquy.info/
* Linux: install x-chat using your favorite distro method.

set the network to FreeNode, and once connected, connect to #linuxmce-devel

or use the web interface @ http://webirc.freenode.net/

again, you can go to the #linuxmce-devel and meet us there.

-Thom