@@ -0,0 +1,3107 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage jaist.echonet.samples;%0A%0Aimport jaist.echonet.EOJ;%0Aimport jaist.echonet.EchonetCharacterProperty;%0Aimport jaist.echonet.EchonetNode;%0Aimport jaist.echonet.EchonetProperty;%0Aimport jaist.echonet.LocalEchonetObject;%0Aimport jaist.echonet.gui.NetworkScanner;%0Aimport java.net.InetAddress;%0Aimport java.net.UnknownHostException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0A%0A/**%0A *%0A * @author haha%0A */%0Apublic class TemperatureSensorApp %7B%0A%0A    EchonetNode context;%0A    LocalEchonetObject temperaturesensor;%0A    byte numberofsensors = 1;%0A    static byte TEMPSENSORCLASSGROUP = 0x00;%0A    static byte TEMPSENSORCLASS = 0x11;%0A%0A    public static void main(String args%5B%5D) %7B%0A        InetAddress address = null;%0A        try %7B%0A            if (args.length %3E 0) %7B%0A                address = InetAddress.getByName(args%5B0%5D);%0A            %7D%0A        %7D catch (UnknownHostException ex) %7B%0A            Logger.getLogger(NetworkScanner.class.getName()).log(Level.SEVERE, null, ex);%0A        %7D%0A        new TemperatureSensorApp(address);%0A    %7D%0A%0A    public TemperatureSensorApp(InetAddress address) %7B%0A        context = new EchonetNode(address);%0A        context.registerEchonetObject(getTemperatureSensorInstance());%0A        Thread t = context.start();%0A        //prevent exit of program; t is a daemon thread.%0A        while (true) %7B%0A            try %7B%0A                t.join();%0A            %7D catch (InterruptedException ex) %7B%0A                Logger.getLogger(TemperatureSensorApp.class.getName()).log(Level.SEVERE, null, ex);%0A            %7D%0A        %7D%0A    %7D%0A%0A    private LocalEchonetObject getTemperatureSensorInstance() %7B%0A        EOJ sensoreoj = new EOJ(TEMPSENSORCLASSGROUP, TEMPSENSORCLASS, numberofsensors++);%0A        List%3CEchonetProperty%3E properties = new ArrayList%3C%3E();%0A        properties.add(new EchonetCharacterProperty((byte) 0x80, true, false, true, 1, 0, new byte%5B%5D%7B0x30%7D));%0A        properties.add(new EchonetProperty((byte) 0xE0, true, false, true, 2, 1) %7B%0A%0A            short temperature = 0;%0A%0A            @Override%0A            public byte%5B%5D read() %7B%0A                byte%5B%5D result = new byte%5B2%5D;%0A                //convert the temperature%0A                result%5B0%5D = (byte) (temperature %3E%3E 8);%0A                result%5B1%5D = (byte) (temperature & 0x00ff);%0A                System.out.println(%22Current temperature: %22 + temperature * 10 + %22%5Cn%22);%0A%0A                //increase temperature for next time %0A                temperature++;%0A                return result;%0A            %7D%0A%0A            @Override%0A            public boolean write(byte%5B%5D data) %7B%0A                throw new UnsupportedOperationException(%22This will never be called%22);%0A            %7D%0A%0A            @Override%0A            public boolean isEmpty() %7B%0A                return false;%0A            %7D%0A        %7D);%0A%0A        LocalEchonetObject sensor = new LocalEchonetObject(sensoreoj, properties);%0A        return sensor;%0A    %7D%0A%7D%0A

Add sample temperature sensor application.