Author Topic: Java Application for retrieving data from module  (Read 1042 times)

callumj

  • Newbie
  • *
  • Posts: 10
Java Application for retrieving data from module
« on: February 18, 2009, 05:19:37 AM »
I have created a Java application that basically parses the JSON and returns value of specific channels and input/outputs. It also allows converting the JSON to XML output.
I am happy to publish all the source code for it, is the official wiki up?

The usage is below

usage: application
 -channel <number>     the channel to query
 -module <feedkey>     the module to connect to
 -operation <opmode>   set the operation to perform

The operations available are
help                print this help
xmldump             provide an xml output (requires just the -module <feedkey> flag)
analoginput         return the value of the AnalogInput
analoginputraw      return the value of the AnalogInputRaw
digitalinput        get the status of the DigitalInput
digitalinputstate   return the value of the DigitalInputState
digitaloutput       get the status of the DigitalOutput
digitaloutputstate  return the value of the DigitalOutputState

Source at: http://mullac.org/2009/02/iobridge-java-application.html

Uses both the json-simple library and the Apache Commons CLI
« Last Edit: February 19, 2009, 12:42:07 AM by callumj »

callumj

  • Newbie
  • *
  • Posts: 10
Re: Java Application for retrieving data from module
« Reply #1 on: February 19, 2009, 05:01:24 AM »
Just a couple of updates.

The source is now available via subversion at http://mullac.org:6666/svn/repo1/IOBridgeTalk/

As of this post the version now supports the ability to read from an XML config file formatted as such
<config>
<feedkey></feedkey>
<channel></channel>
<operation</operation>

However, by passing command line arguments you override the XML config.


geraldcor

  • Jr. Member
  • **
  • Posts: 56
Re: Java Application for retrieving data from module
« Reply #2 on: February 19, 2009, 04:18:18 PM »
So...how do I deal with the subversion situation? Do I need to download it through subversion or can I just go to the web index I see? Do I need to compile something? I'm somewhat of a novice when it comes to Java, subversion and figuring out how it all comes together. Thanks

Greg

callumj

  • Newbie
  • *
  • Posts: 10
Re: Java Application for retrieving data from module
« Reply #3 on: February 20, 2009, 08:13:11 PM »
I will do up a guide to compile with Apache Ant.
Currently (I believe) this application only works with POSIX OSes (so not Windows) as Apache CLI is used to detect command line arguments.

callumj

  • Newbie
  • *
  • Posts: 10
Re: Java Application for retrieving data from module
« Reply #4 on: February 21, 2009, 02:14:56 AM »
Tested on Mac OS X and Windows 7 with Java 1.5

Ok here is how to use it (http://mullac.org/2009/02/iobridgetalk-running-application.html)
Download the distribution from http://mullac.org/java/iobridge/dist.zip and unzip.

Execute "java -jar IOBridgeTalk.jar" in a command prompt
You can also then pass arguments and operations to the command for example:

java -jar IOBridgeTalk -operation help
will list all the available operations

java -jar IOBridgeTalk.jar -operation analoginputraw -module u38Wsd322S2QQ7 -channel 4
will give the value of the analog input in raw

You can also create an XML file in your home directory called iobridgetalk.xml with the following:
Code: [Select]
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<feedkey>u38WrfLSXBoYOciQQ7</feedkey>
<channel>4</channel>
<operation>analoginputraw</operation>

</config>

These will then fill in the arguments if they do not exist, however you can override them.


iobridge

  • Administrator
  • Hero Member
  • *****
  • Posts: 669
    • ioBridge Support
Re: Java Application for retrieving data from module
« Reply #5 on: February 21, 2009, 04:02:12 PM »
ioBridge Support
Community Team

whitehexagon

  • Full Member
  • ***
  • Posts: 118
    • SunshineApps
Re: Java Application for retrieving data from module
« Reply #6 on: May 06, 2009, 07:11:59 AM »
I was interested in the java code for retrieving the json module data, but the links seem to redirect only to flickr.  Can I assume that a data lookup call is just a GET with the widget URL or is this a more direct module API?
Home Automation via a native iPhone application.  Search for HomeWatch in iTunes.