Changes between Version 3 and Version 4 of Java


Ignore:
Timestamp:
Aug 4, 2012, 12:45:28 PM (12 years ago)
Author:
Toël Hartmann
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Java

    v3 v4  
    11= Java =
    22
    3 == Requrements ==
     3== Tellstick ==
     4
     5
     6=== Requirements ===
    47
    58To be able to use your TellStick from Java your OS must look at it as a serial unit. In Linux this is relatively simple as the unit is installed as a usual unit under /dev and you can then use e.g. javacomm to work with the unit. In Windows it is harder as the unit does not show up as a usual serial connection. You can use JNI to call one of the DLL's that exist to communicate with TellStick. If there will be VCP-drivers for Windows (Virtual Communication Port, make a USB-unit look like a regular serial port) the same example as for Linux can be used.
     
    4144
    4245In the class NEXAUnit.java there is some code that may be helpful.
     46
     47== TellStickNet ==
     48
     49Telldus TellStickNet is designed to use Telldus online servers and telldus live API, but it is possible to use TellStickNet as listening device using TCP/IP locally.
     50
     51The first approach is described here
     52http://developer.telldus.se/blog/2012/03/02/help-us-develop-local-access-using-tellstick-net-build-your-own-firmware is
     53
     54The second approach is to make changes to the local network DNS and "emulate" telldus live.
     55
     56=== Network configuration ===
     57The TellStickNet is performing the folowing operations at boot:
     581 - request ip address using dhcp
     592 - resolve api.telldus.com using dns
     603 - HTTP request to api.telldus.com to get url to telldus live server
     614 - connect to telldus live server, register and exchange data.
     62
     63In order to make TellStickNet connect to you own software, you will have to setup and configure a local dns server and override the dns entries for telldus.com and telldus.se.
     64
     65My dns entries looks like this:
     66{{{
     67telldus.com
     68    api        10.0.1.5
     69    developer  62.20.121.252
     70    download   194.30.169.113
     71    local      10.0.1.5
     72    login      79.99.3.85
     73    www        194.30.169.113
     74telldus.se
     75    developer  62.20.121.252
     76}}}
     77
     7810.0.1.5 is my local computer running http server and the software to emulate telldus live.
     79
     80=== HTTP configuration ===
     81The TellStickNet is getting the address of the telldus live by asking api.telldus.com using a HTTP get.
     82
     83Simply setup a HTTP server somewhere and put a file named assign in a directory called server in the webroot.
     84
     85The assign file should contain:
     86{{{
     8711:local.telldus.comiAFCAs
     88}}}
     89OBS the address must have 5 letters as computer name.
     90
     91=== Software ===
     92The zip file JavaTellStickNet_20120804 contains a java application witch communicate with tellstick net.
     93This first beta version can only listen and parse nexa protocol (not self learning).
     94
     95If you are in a hurry, just use include the lib JavaTellStickNet.jar and toel.jar in your project and use the code:
     96{{{
     97    public void Start() {
     98       
     99        boolean proxyMode = false;                  // Set to true if you want the software to proxy data to Telldus Live real server
     100       
     101        Server server = new Server(proxyMode);
     102        //server.setLiveIp("79.99.3.85");           // Uncomment to change the default ip
     103        //server.setLivePort(45002");               // Uncomment to cahnge the default port
     104       
     105        // Start the server
     106        server.start();
     107       
     108        // Register event listener
     109        EventHandler.getInstance().subscribe(Event.TELLSTICK_EVENT, this);
     110       
     111        // EXAMPLE CODE: Run for 1 minute
     112        long start = System.currentTimeMillis();
     113        while (server.isRunning()) {
     114            Dev.sleep(100);
     115            if ((System.currentTimeMillis()-start)>60000) break;
     116        }
     117       
     118        // Shutdown everything
     119        server.shutdown();
     120       
     121    }
     122
     123    @Override
     124    public void eventTriggered(EventIF event) {
     125        System.out.println(event.getMessage());
     126        // Your code here...
     127    }
     128}}}
     129