EepA50401 implements EepReceive { @Override public boolean update(EspRadioTelegram telegram) { if(!deviceID.equals(telegram.getSenderID())) { return false; } if(!eepType.isValidRadioTelegramRORG(telegram)) { log.warn( "Discarded received radio telegram from device " + "with ID {0} because of a configuration error: " + "Command for device with ID {0} has been configured " + "with an invalid EEP {1} for this device.", deviceID, getType() ); return false; } this.controlData.update(telegram.getPayload()); if(isTeachInTelegram()) { return false; } boolean isUpdate = false; if(command == Command.TEMPERATURE) { isUpdate = updateTemperature(telegram); } else if(command == Command.HUMIDITY) { isUpdate = updateHumidity(telegram); } return isUpdate; } EepA50401(DeviceID deviceID, String commandString); @Override String toString(); @Override EepType getType(); @Override boolean update(EspRadioTelegram telegram); @Override void updateSensor(Sensor sensor); static final int EEP_A50401_TSN_OFFSET; static final int EEP_A50401_TSN_SIZE; static final String EEP_A50401_TSN_AVAILABLE_DESC; static final int EEP_A50401_TSN_AVAILABLE_VALUE; static final String EEP_A50401_TSN_NOT_AVAILABLE_DESC; static final int EEP_A50401_TSN_NOT_AVAILABLE_VALUE; static final int EEP_A50401_FRACTIONAL_DIGITS; }
@Test public void testInvalidRadioTelegramType() throws Exception { EepA50401 eep = (EepA50401)EepType.lookup("A5-04-01").createEep( deviceID, Constants.TEMPERATURE_STATUS_COMMAND, null ); EspRadioTelegram invalidTelegram = new Esp31BSTelegram(deviceID, (byte)0x00, (byte)0x00); boolean isUpdate = eep.update(invalidTelegram); Assert.assertFalse(isUpdate); invalidTelegram = new Esp21BSTelegram(deviceID, (byte)0x00, (byte)0x00); isUpdate = eep.update(invalidTelegram); Assert.assertFalse(isUpdate); }
@Test public void testInvalidDeviceID() throws Exception { EepA50401 eep = (EepA50401)EepType.lookup("A5-04-01").createEep( deviceID, Constants.TEMPERATURE_STATUS_COMMAND, null ); int rawTemperatureValue = 0; boolean isTemperatureAvailable = true; boolean isTeachIn = false; DeviceID invalidDeviceID = DeviceID.fromString("0xFF800002"); EspRadioTelegram telegram = createRadioTelegramESP3( invalidDeviceID, rawTemperatureValue, 0, isTemperatureAvailable, isTeachIn ); Boolean isUpdate = eep.update(telegram); Assert.assertFalse(isUpdate); telegram = createRadioTelegramESP2( invalidDeviceID, rawTemperatureValue, 0, isTemperatureAvailable, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertFalse(isUpdate); }