Fixed TC and initial implementation of Nexa group transmissions. issue 12
This commit is contained in:
parent
b93c8bc124
commit
cf646bb340
4 changed files with 29 additions and 11 deletions
|
|
@ -65,4 +65,12 @@ public abstract class TellstickProtocol {
|
|||
|
||||
public abstract String encode();
|
||||
public abstract void decode(byte[] data);
|
||||
|
||||
/**
|
||||
* 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(Object obj){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class NexaSelfLearning extends TellstickProtocol implements SwitchEventDa
|
|||
@Configurator.Configurable("House code")
|
||||
private int house = 0;
|
||||
@Configurator.Configurable("Group code")
|
||||
private int group = 0;
|
||||
private boolean group = false;
|
||||
@Configurator.Configurable("Unit code")
|
||||
private int unit = 0;
|
||||
|
||||
|
|
@ -47,6 +47,8 @@ public class NexaSelfLearning extends TellstickProtocol implements SwitchEventDa
|
|||
|
||||
|
||||
public String encode(){
|
||||
// Binary 0 => "01"
|
||||
// Binary 1 => "10"
|
||||
StringBuilder enc = new StringBuilder();
|
||||
enc.append(new char[]{'T', 127, 255, 24, 1});
|
||||
|
||||
|
|
@ -58,6 +60,9 @@ public class NexaSelfLearning extends TellstickProtocol implements SwitchEventDa
|
|||
m.append( (house & (1 << i)) == 0 ? "01" : "10" );
|
||||
}
|
||||
// Group
|
||||
if (group)
|
||||
m.append("10");
|
||||
else
|
||||
m.append("01");
|
||||
|
||||
// On or OFF
|
||||
|
|
@ -89,7 +94,6 @@ public class NexaSelfLearning extends TellstickProtocol implements SwitchEventDa
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
enc.append("+");
|
||||
return enc.toString();
|
||||
}
|
||||
|
|
@ -110,13 +114,12 @@ public class NexaSelfLearning extends TellstickProtocol implements SwitchEventDa
|
|||
house |= (data[1] & 0xFF) << 2;
|
||||
house |= (data[0] & 0xC0) >>> 6;
|
||||
|
||||
group = data[0] & 0x20;
|
||||
group >>>= 5;
|
||||
int tmpGroup = data[0] & 0x20; // >>> 5
|
||||
group = tmpGroup != 0;
|
||||
|
||||
enable = (data[0] & 0x10) != 0;
|
||||
|
||||
unit = data[0] & 0x0F;
|
||||
//unit++;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -126,10 +129,10 @@ public class NexaSelfLearning extends TellstickProtocol implements SwitchEventDa
|
|||
public void setHouse(int house) {
|
||||
this.house = house;
|
||||
}
|
||||
public int getGroup() {
|
||||
public boolean getGroup() {
|
||||
return group;
|
||||
}
|
||||
public void setGroup(int group) {
|
||||
public void setGroup(boolean group) {
|
||||
this.group = group;
|
||||
}
|
||||
public int getUnit() {
|
||||
|
|
@ -162,9 +165,16 @@ public class NexaSelfLearning extends TellstickProtocol implements SwitchEventDa
|
|||
public boolean equals(Object obj){
|
||||
if(obj instanceof NexaSelfLearning)
|
||||
return ((NexaSelfLearning) obj).house == house &&
|
||||
((NexaSelfLearning) obj).group == group &&
|
||||
((NexaSelfLearning)obj).unit == unit;
|
||||
return false;
|
||||
}
|
||||
public boolean equalsGroup(Object obj){
|
||||
if(obj instanceof NexaSelfLearning)
|
||||
return ((NexaSelfLearning) obj).house == house &&
|
||||
(((NexaSelfLearning) obj).group || group );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class TelstickSerialCommNexaOnOffTest {
|
|||
NexaSelfLearning nexa = new NexaSelfLearning();
|
||||
//nexa.setHouse(11772006);
|
||||
nexa.setHouse(14160770);
|
||||
nexa.setGroup(0);
|
||||
nexa.setGroup(false);
|
||||
nexa.setUnit(1);
|
||||
|
||||
System.out.println("Up and Running");
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class NexaSelfLearningTest {
|
|||
NexaSelfLearning nexa = decode("0x2CE81990");
|
||||
|
||||
assertEquals("House Code", 11772006, nexa.getHouse());
|
||||
assertEquals("Unit Code", 1, nexa.getUnit());
|
||||
assertEquals("Unit Code", 0, nexa.getUnit());
|
||||
assertTrue("Enabled", nexa.isOn());
|
||||
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ public class NexaSelfLearningTest {
|
|||
NexaSelfLearning nexa = decode("0x2CE81980");
|
||||
|
||||
assertEquals("House Code", 11772006, nexa.getHouse());
|
||||
assertEquals("Unit Code", 1, nexa.getUnit());
|
||||
assertEquals("Unit Code", 0, nexa.getUnit());
|
||||
assertFalse("Enabled", nexa.isOn());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue