From 3bdb4ea043a592a17dfc290190c4eb6cb4f6adbc Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Wed, 17 Aug 2016 16:45:02 +0200 Subject: [PATCH] Some progress --- src/se/hal/HalSpeechClient.java | 8 +- src/se/hal/intf/HalDeviceData.java | 25 +++++ src/se/hal/intf/HalEventData.java | 17 +--- src/se/hal/intf/HalSensorData.java | 17 +--- .../tellstick/TellstickGroupProtocol.java | 2 +- .../hal/plugin/tellstick/TellstickParser.java | 8 +- .../plugin/tellstick/TellstickProtocol.java | 27 +----- .../NexaSelfLearning.java | 67 ++----------- .../plugin/tellstick/device/Oregon0x1A2D.java | 55 +++++++++++ .../protocol/NexaSelfLearningProtocol.java | 95 +++++++++++++++++++ .../Oregon0x1A2DProtocol.java} | 45 +-------- .../SensorDataAggregationDeamonTest.java | 2 +- .../TelstickSerialCommNexaOnOffTest.java | 4 +- .../NexaSelfLearningTest.java | 13 ++- 14 files changed, 212 insertions(+), 173 deletions(-) create mode 100755 src/se/hal/intf/HalDeviceData.java rename src/se/hal/plugin/tellstick/{protocols => device}/NexaSelfLearning.java (62%) create mode 100755 src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java create mode 100755 src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java rename src/se/hal/plugin/tellstick/{protocols/Oregon0x1A2D.java => protocol/Oregon0x1A2DProtocol.java} (59%) rename test/se/hal/plugin/tellstick/{protocols => protocol}/NexaSelfLearningTest.java (88%) diff --git a/src/se/hal/HalSpeechClient.java b/src/se/hal/HalSpeechClient.java index a3252ec2..663faae2 100755 --- a/src/se/hal/HalSpeechClient.java +++ b/src/se/hal/HalSpeechClient.java @@ -50,17 +50,17 @@ public class HalSpeechClient { bot.initialize(); /********************************************************************/ -/* NexaSelfLearning nexa1 = new NexaSelfLearning(); +/* NexaSelfLearningProtocol nexa1 = new NexaSelfLearningProtocol(); nexa1.setHouse(15087918); nexa1.setUnit(0); switches.put("livingroom", new SwitchEventData("livingroom", nexa1)); - NexaSelfLearning nexa2 = new NexaSelfLearning(); + NexaSelfLearningProtocol nexa2 = new NexaSelfLearningProtocol(); nexa2.setHouse(15087918); nexa2.setUnit(1); switches.put("bedroom", new SwitchEventData("bedroom", nexa2)); - NexaSelfLearning nexa3 = new NexaSelfLearning(); + NexaSelfLearningProtocol nexa3 = new NexaSelfLearningProtocol(); nexa3.setHouse(15087918); nexa3.setUnit(3); switches.put("kitchen", new SwitchEventData("kitchen", nexa3)); @@ -70,7 +70,7 @@ public class HalSpeechClient { public void stateChange(TellstickProtocol protocol) { for(SwitchEventData s : switches.values()) { if(s.equals(protocol)) { - String response = s.getName()+" window is "+(((NexaSelfLearning)protocol).isEnabled() ? "open": "closed"); + String response = s.getName()+" window is "+(((NexaSelfLearningProtocol)protocol).isEnabled() ? "open": "closed"); System.out.println(">>> " + response); tts.speak(response); return; diff --git a/src/se/hal/intf/HalDeviceData.java b/src/se/hal/intf/HalDeviceData.java new file mode 100755 index 00000000..02c47987 --- /dev/null +++ b/src/se/hal/intf/HalDeviceData.java @@ -0,0 +1,25 @@ +package se.hal.intf; + +/** + * Interface representing one report from an event + * + * Created by Ziver on 2016-08-17. + */ +public abstract class HalDeviceData { + + private long timestamp = -1; + + + public long getTimestamp(){ + return timestamp; + } + public void setTimestamp(long timestamp){ + this.timestamp = timestamp; + } + + + /** + * @return serialized event data converted to double that will be saved in DB. + */ + public abstract double getData(); +} diff --git a/src/se/hal/intf/HalEventData.java b/src/se/hal/intf/HalEventData.java index bdd9a5ae..1f090223 100755 --- a/src/se/hal/intf/HalEventData.java +++ b/src/se/hal/intf/HalEventData.java @@ -5,21 +5,6 @@ package se.hal.intf; * * Created by Ziver on 2016-08-17. */ -public abstract class HalEventData { +public abstract class HalEventData extends HalDeviceData{ - private long timestamp = -1; - - - public long getTimestamp(){ - return timestamp; - } - public void setTimestamp(long timestamp){ - this.timestamp = timestamp; - } - - - /** - * @return serialized event data converted to double that will be saved in DB. - */ - public abstract double getData(); } diff --git a/src/se/hal/intf/HalSensorData.java b/src/se/hal/intf/HalSensorData.java index 75113687..bab1d0e0 100755 --- a/src/se/hal/intf/HalSensorData.java +++ b/src/se/hal/intf/HalSensorData.java @@ -5,21 +5,6 @@ package se.hal.intf; * * Created by Ziver on 2016-08-17. */ -public abstract class HalSensorData { +public abstract class HalSensorData extends HalDeviceData{ - private long timestamp = -1; - - - public long getTimestamp(){ - return timestamp; - } - public void setTimestamp(long timestamp){ - this.timestamp = timestamp; - } - - - /** - * @return serialized sensor data converted to double that will be saved in DB. - */ - public abstract double getData(); } diff --git a/src/se/hal/plugin/tellstick/TellstickGroupProtocol.java b/src/se/hal/plugin/tellstick/TellstickGroupProtocol.java index fbfee128..fcda24a9 100755 --- a/src/se/hal/plugin/tellstick/TellstickGroupProtocol.java +++ b/src/se/hal/plugin/tellstick/TellstickGroupProtocol.java @@ -34,7 +34,7 @@ public interface TellstickGroupProtocol { * Protocols should extend this method if it has group functionality. * @return true if this object an the input is in the same group. */ - public boolean equalsGroup(TellstickProtocol obj); + public boolean equalsGroup(TellstickGroupProtocol obj); /** * Copy the state data from the group to this object. diff --git a/src/se/hal/plugin/tellstick/TellstickParser.java b/src/se/hal/plugin/tellstick/TellstickParser.java index 0191c500..80c0a6fb 100755 --- a/src/se/hal/plugin/tellstick/TellstickParser.java +++ b/src/se/hal/plugin/tellstick/TellstickParser.java @@ -22,8 +22,8 @@ package se.hal.plugin.tellstick; -import se.hal.plugin.tellstick.protocols.NexaSelfLearning; -import se.hal.plugin.tellstick.protocols.Oregon0x1A2D; +import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol; +import se.hal.plugin.tellstick.protocol.Oregon0x1A2DProtocol; import zutil.converter.Converter; import zutil.log.LogUtil; @@ -41,8 +41,8 @@ public class TellstickParser { private static HashMap> protocolMap; static { - registerProtocol(NexaSelfLearning.class); - registerProtocol(Oregon0x1A2D.class); + registerProtocol(NexaSelfLearningProtocol.class); + registerProtocol(Oregon0x1A2DProtocol.class); } private int firmwareVersion = -1; diff --git a/src/se/hal/plugin/tellstick/TellstickProtocol.java b/src/se/hal/plugin/tellstick/TellstickProtocol.java index 0a601416..37020880 100755 --- a/src/se/hal/plugin/tellstick/TellstickProtocol.java +++ b/src/se/hal/plugin/tellstick/TellstickProtocol.java @@ -19,20 +19,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package se.hal.plugin.tellstick; -import se.hal.intf.HalEventController; -import se.hal.intf.HalSensorController; +import se.hal.intf.HalEventConfig; +import se.hal.intf.HalEventData; /** * Created by Ziver on 2015-02-18. */ public abstract class TellstickProtocol { - private String protocol; - private String model; - private long timestamp = -1; + private final String protocol; + private final String model; public TellstickProtocol(String protocol, String model){ @@ -48,22 +46,7 @@ public abstract class TellstickProtocol { return model; } - public long getTimestamp() { - return timestamp; - } - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - - public Class getEventController() { - return TellstickSerialComm.class; - } - public Class getSensorController() { - return TellstickSerialComm.class; - } - - public abstract String encode(); + public String encode(HalEventConfig deviceConfig, HalEventData deviceData){ return null; } public abstract void decode(byte[] data); } diff --git a/src/se/hal/plugin/tellstick/protocols/NexaSelfLearning.java b/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java similarity index 62% rename from src/se/hal/plugin/tellstick/protocols/NexaSelfLearning.java rename to src/se/hal/plugin/tellstick/device/NexaSelfLearning.java index 911ee11f..0c0705e7 100755 --- a/src/se/hal/plugin/tellstick/protocols/NexaSelfLearning.java +++ b/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java @@ -20,12 +20,13 @@ * THE SOFTWARE. */ -package se.hal.plugin.tellstick.protocols; +package se.hal.plugin.tellstick.device; import se.hal.intf.HalEventConfig; +import se.hal.intf.HalEventController; import se.hal.plugin.tellstick.TellstickGroupProtocol; import se.hal.plugin.tellstick.TellstickProtocol; -import se.hal.struct.devicedata.SwitchEventData; +import se.hal.plugin.tellstick.TellstickSerialComm; import zutil.ByteUtil; import zutil.parser.binary.BinaryStruct; import zutil.parser.binary.BinaryStructInputStream; @@ -37,8 +38,7 @@ import java.io.IOException; /** * Created by Ziver on 2015-02-18. */ -public class NexaSelfLearning extends TellstickProtocol - implements HalEventConfig,TellstickGroupProtocol,BinaryStruct { +public class NexaSelfLearning implements HalEventConfig,TellstickGroupProtocol,BinaryStruct { @BinaryField(index=1, length=26) @Configurator.Configurable("House code") @@ -56,59 +56,6 @@ public class NexaSelfLearning extends TellstickProtocol private int unit = 0; - - public NexaSelfLearning() { - super("arctech", "selflearning"); - } - - - public String encode(){ - try { - // T[t0][t1][t2][t3][length][d1]..[dn]+ - StringBuilder enc = new StringBuilder(90); // Tellstick supports max 74 bytes - enc.append(new char[]{'T', 127, 255, 24, 0}); - enc.append((char)0); // length - - enc.append((char)0b0000_1001); // preamble - int length = 4; - byte[] data = BinaryStructOutputStream.serialize(this); - for (byte b : data){ - for (int i=7; i>=0; --i){ - if (ByteUtil.getBits(b, i, 1) == 0) - enc.append((char) 0b1010_1000); // 0b1010_1000 - else // 1 - enc.append((char) 0b1000_1010); // 0b1000_1010 - length += 4; - } - } - enc.append((char)0b0000_0000); // postemble - length += 2; - enc.setCharAt(5, (char)length); // Set calculated length - - enc.append("+"); - return enc.toString(); - } catch (IOException e) { - e.printStackTrace(); - } - - return ""; - } - - public void decode(byte[] data){ - // Data positions - // house = 0xFFFFFFC0 - // group = 0x00000020 - // method = 0x00000010 - // unit = 0x0000000F - // ----------------h------------ g m --u- - // 0x2CE81990 - 00101100_11101000_00011001_10 0 1 0000 - ON - // 0x2CE81980 - 00101100_11101000_00011001_10 0 0 0000 - OFF - - BinaryStructInputStream.read(this, data); - } - - - public int getHouse() { return house; } @@ -146,7 +93,7 @@ public class NexaSelfLearning extends TellstickProtocol return false; } @Override - public boolean equalsGroup(TellstickProtocol obj) { + public boolean equalsGroup(TellstickGroupProtocol obj) { if(obj instanceof NexaSelfLearning) return ((NexaSelfLearning) obj).house == house && (((NexaSelfLearning) obj).group || group ); @@ -158,4 +105,8 @@ public class NexaSelfLearning extends TellstickProtocol this.enable = ((NexaSelfLearning) group).enable; } + + public Class getEventController() { + return TellstickSerialComm.class; + } } diff --git a/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java b/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java new file mode 100755 index 00000000..87f115ac --- /dev/null +++ b/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java @@ -0,0 +1,55 @@ +package se.hal.plugin.tellstick.device; + +import se.hal.intf.HalEventController; +import se.hal.intf.HalSensorConfig; +import se.hal.intf.HalSensorController; +import se.hal.plugin.tellstick.TellstickProtocol; +import se.hal.plugin.tellstick.TellstickSerialComm; +import zutil.log.LogUtil; +import zutil.ui.Configurator; + +import java.util.logging.Logger; + +/** + * Created by Ziver on 2015-11-19. + */ +public class Oregon0x1A2D implements HalSensorConfig { + private static final Logger logger = LogUtil.getLogger(); + + @Configurator.Configurable("Address") + private int address = 0; + @Configurator.Configurable("Report Interval(ms)") + private int interval = 60*1000; // default 1 min + + + + + @Override + public boolean equals(Object obj){ + if(! (obj instanceof Oregon0x1A2D)) + return false; + return ((Oregon0x1A2D)obj).address == this.address; + } + + public String toString(){ + return "address:"+address; + } + + + + @Override + public long getDataInterval() { + return interval; + } + + @Override + public AggregationMethod getAggregationMethod() { + return AggregationMethod.SUM; + } + + @Override + public Class getSensorController() { + return TellstickSerialComm.class; + } + +} diff --git a/src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java b/src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java new file mode 100755 index 00000000..0888be67 --- /dev/null +++ b/src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2015 Ziver + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package se.hal.plugin.tellstick.protocol; + +import se.hal.intf.HalEventConfig; +import se.hal.plugin.tellstick.TellstickGroupProtocol; +import se.hal.plugin.tellstick.TellstickProtocol; +import zutil.ByteUtil; +import zutil.parser.binary.BinaryStruct; +import zutil.parser.binary.BinaryStructInputStream; +import zutil.parser.binary.BinaryStructOutputStream; +import zutil.ui.Configurator; + +import java.io.IOException; + +/** + * Created by Ziver on 2015-02-18. + */ +public class NexaSelfLearningProtocol extends TellstickProtocol { + + + + public NexaSelfLearningProtocol() { + super("arctech", "selflearning"); + } + + @Override + public String encode(){ + try { + // T[t0][t1][t2][t3][length][d1]..[dn]+ + StringBuilder enc = new StringBuilder(90); // Tellstick supports max 74 bytes + enc.append(new char[]{'T', 127, 255, 24, 0}); + enc.append((char)0); // length + + enc.append((char)0b0000_1001); // preamble + int length = 4; + byte[] data = BinaryStructOutputStream.serialize(this); + for (byte b : data){ + for (int i=7; i>=0; --i){ + if (ByteUtil.getBits(b, i, 1) == 0) + enc.append((char) 0b1010_1000); // 0b1010_1000 + else // 1 + enc.append((char) 0b1000_1010); // 0b1000_1010 + length += 4; + } + } + enc.append((char)0b0000_0000); // postemble + length += 2; + enc.setCharAt(5, (char)length); // Set calculated length + + enc.append("+"); + return enc.toString(); + } catch (IOException e) { + e.printStackTrace(); + } + + return ""; + } + + @Override + public void decode(byte[] data){ + // Data positions + // house = 0xFFFFFFC0 + // group = 0x00000020 + // method = 0x00000010 + // unit = 0x0000000F + // ----------------h------------ g m --u- + // 0x2CE81990 - 00101100_11101000_00011001_10 0 1 0000 - ON + // 0x2CE81980 - 00101100_11101000_00011001_10 0 0 0000 - OFF + + BinaryStructInputStream.read(this, data); + } + + +} diff --git a/src/se/hal/plugin/tellstick/protocols/Oregon0x1A2D.java b/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java similarity index 59% rename from src/se/hal/plugin/tellstick/protocols/Oregon0x1A2D.java rename to src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java index 26cc7d98..e2e9cd18 100755 --- a/src/se/hal/plugin/tellstick/protocols/Oregon0x1A2D.java +++ b/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java @@ -1,8 +1,7 @@ -package se.hal.plugin.tellstick.protocols; +package se.hal.plugin.tellstick.protocol; import se.hal.intf.HalSensorConfig; import se.hal.plugin.tellstick.TellstickProtocol; -import se.hal.struct.devicedata.PowerConsumptionSensorData; import zutil.log.LogUtil; import zutil.ui.Configurator; @@ -11,29 +10,16 @@ import java.util.logging.Logger; /** * Created by Ziver on 2015-11-19. */ -public class Oregon0x1A2D extends TellstickProtocol implements HalSensorConfig { +public class Oregon0x1A2DProtocol extends TellstickProtocol { private static final Logger logger = LogUtil.getLogger(); - @Configurator.Configurable("Address") - private int address = 0; - @Configurator.Configurable("Report Interval(ms)") - private int interval = 60*1000; // default 1 min - - private double temperature = 0; - private double humidity = 0; - - public Oregon0x1A2D(){ + public Oregon0x1A2DProtocol(){ super("oregon", "0x1A2D"); } - @Override - public String encode() { - return null; - } - @Override public void decode(byte[] data) { //class:sensor;protocol:oregon;model:0x1A2D;data:20BA000000002700; @@ -68,29 +54,4 @@ public class Oregon0x1A2D extends TellstickProtocol implements HalSensorConfig { } - @Override - public boolean equals(Object obj){ - if(! (obj instanceof Oregon0x1A2D)) - return false; - return ((Oregon0x1A2D)obj).address == this.address; - } - - public String toString(){ - return "address:"+address+ - ", temperature:"+temperature+ - ", humidity:"+humidity; - } - - - - @Override - public long getDataInterval() { - return interval; - } - - @Override - public AggregationMethod getAggregationMethod() { - return AggregationMethod.SUM; - } - } diff --git a/test/se/hal/deamon/SensorDataAggregationDeamonTest.java b/test/se/hal/deamon/SensorDataAggregationDeamonTest.java index fa52c4eb..fa09fd0d 100755 --- a/test/se/hal/deamon/SensorDataAggregationDeamonTest.java +++ b/test/se/hal/deamon/SensorDataAggregationDeamonTest.java @@ -42,7 +42,7 @@ public class SensorDataAggregationDeamonTest { System.out.println("Adding user to database"); db.exec("INSERT INTO user(id, external, username) VALUES(222, 0, 'test')"); //adding user System.out.println("Adding sensor to database"); - db.exec("INSERT INTO sensor(id, user_id, external_id, type) VALUES(111, 222, 333, 'se.hal.plugin.tellstick.protocols.Oregon0x1A2D')"); //adding sensor + db.exec("INSERT INTO sensor(id, user_id, external_id, type) VALUES(111, 222, 333, 'se.hal.plugin.tellstick.protocol.Oregon0x1A2DProtocol')"); //adding sensor System.out.println("Generating raw data and saving it to the database..."); PreparedStatement stmt = db.getPreparedStatement("INSERT INTO sensor_data_raw (timestamp, sensor_id, data) VALUES(?, ?, ?)"); try{ diff --git a/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java b/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java index c16167bc..29fc0df2 100755 --- a/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java +++ b/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java @@ -1,6 +1,6 @@ package se.hal.plugin.tellstick; -import se.hal.plugin.tellstick.protocols.NexaSelfLearning; +import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol; /** * Created by Ziver on 2015-11-19. @@ -17,7 +17,7 @@ public class TelstickSerialCommNexaOnOffTest { Thread.sleep(1000); - NexaSelfLearning nexa = new NexaSelfLearning(); + NexaSelfLearningProtocol nexa = new NexaSelfLearningProtocol(); //nexa.setHouse(11772006); nexa.setHouse(14160770); nexa.setGroup(false); diff --git a/test/se/hal/plugin/tellstick/protocols/NexaSelfLearningTest.java b/test/se/hal/plugin/tellstick/protocol/NexaSelfLearningTest.java similarity index 88% rename from test/se/hal/plugin/tellstick/protocols/NexaSelfLearningTest.java rename to test/se/hal/plugin/tellstick/protocol/NexaSelfLearningTest.java index 73beaa52..072ee09a 100755 --- a/test/se/hal/plugin/tellstick/protocols/NexaSelfLearningTest.java +++ b/test/se/hal/plugin/tellstick/protocol/NexaSelfLearningTest.java @@ -20,9 +20,8 @@ * THE SOFTWARE. */ -package se.hal.plugin.tellstick.protocols; +package se.hal.plugin.tellstick.protocol; -import zutil.ByteUtil; import zutil.converter.Converter; import java.nio.charset.StandardCharsets; @@ -33,7 +32,7 @@ public class NexaSelfLearningTest { @org.junit.Test public void testEncode() throws Exception { - NexaSelfLearning nexa = new NexaSelfLearning(); + NexaSelfLearningProtocol nexa = new NexaSelfLearningProtocol(); nexa.setHouse(11_772_006); nexa.setUnit(0); nexa.turnOn(); @@ -61,7 +60,7 @@ public class NexaSelfLearningTest { @org.junit.Test public void decode_ON() throws Exception { - NexaSelfLearning nexa = decode("0x2CE81990"); + NexaSelfLearningProtocol nexa = decode("0x2CE81990"); assertEquals("House Code", 11772006, nexa.getHouse()); assertEquals("Unit Code", 0, nexa.getUnit()); @@ -70,15 +69,15 @@ public class NexaSelfLearningTest { @org.junit.Test public void decode_OFF() throws Exception { - NexaSelfLearning nexa = decode("0x2CE81980"); + NexaSelfLearningProtocol nexa = decode("0x2CE81980"); assertEquals("House Code", 11772006, nexa.getHouse()); assertEquals("Unit Code", 0, nexa.getUnit()); assertFalse("Enabled", nexa.isOn()); } - private NexaSelfLearning decode(String data){ - NexaSelfLearning nexa = new NexaSelfLearning(); + private NexaSelfLearningProtocol decode(String data){ + NexaSelfLearningProtocol nexa = new NexaSelfLearningProtocol(); nexa.decode(Converter.hexToByte(data)); return nexa; }