@Test public void testInvalidRadioTelegramType() throws Exception { EepA50904 eep = (EepA50904)EepType.lookup("A5-09-04").createEep( deviceID, Constants.CONCENTRATION_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); }
@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.CONCENTRATION) { isUpdate = updateRangeVariable(concentration, telegram); } else if(command == Command.TEMPERATURE) { if(isTemperatureAvailable()) { isUpdate = updateRangeVariable(temperature, telegram); } else { isUpdate = false; } } else if(command == Command.HUMIDITY) { if(isHumidityAvailable()) { isUpdate = updateRangeVariable(humidity, telegram); } else { isUpdate = false; } } return isUpdate; }
EepA50904 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.CONCENTRATION) { isUpdate = updateRangeVariable(concentration, telegram); } else if(command == Command.TEMPERATURE) { if(isTemperatureAvailable()) { isUpdate = updateRangeVariable(temperature, telegram); } else { isUpdate = false; } } else if(command == Command.HUMIDITY) { if(isHumidityAvailable()) { isUpdate = updateRangeVariable(humidity, telegram); } else { isUpdate = false; } } return isUpdate; } }
EepA50904 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.CONCENTRATION) { isUpdate = updateRangeVariable(concentration, telegram); } else if(command == Command.TEMPERATURE) { if(isTemperatureAvailable()) { isUpdate = updateRangeVariable(temperature, telegram); } else { isUpdate = false; } } else if(command == Command.HUMIDITY) { if(isHumidityAvailable()) { isUpdate = updateRangeVariable(humidity, telegram); } else { isUpdate = false; } } return isUpdate; } EepA50904(DeviceID deviceID, String commandString); }
EepA50904 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.CONCENTRATION) { isUpdate = updateRangeVariable(concentration, telegram); } else if(command == Command.TEMPERATURE) { if(isTemperatureAvailable()) { isUpdate = updateRangeVariable(temperature, telegram); } else { isUpdate = false; } } else if(command == Command.HUMIDITY) { if(isHumidityAvailable()) { isUpdate = updateRangeVariable(humidity, telegram); } else { isUpdate = false; } } return isUpdate; } EepA50904(DeviceID deviceID, String commandString); @Override String toString(); @Override EepType getType(); @Override boolean update(EspRadioTelegram telegram); @Override void updateSensor(Sensor sensor); }
EepA50904 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.CONCENTRATION) { isUpdate = updateRangeVariable(concentration, telegram); } else if(command == Command.TEMPERATURE) { if(isTemperatureAvailable()) { isUpdate = updateRangeVariable(temperature, telegram); } else { isUpdate = false; } } else if(command == Command.HUMIDITY) { if(isHumidityAvailable()) { isUpdate = updateRangeVariable(humidity, telegram); } else { isUpdate = false; } } return isUpdate; } EepA50904(DeviceID deviceID, String commandString); @Override String toString(); @Override EepType getType(); @Override boolean update(EspRadioTelegram telegram); @Override void updateSensor(Sensor sensor); static final int EEP_A50904_HSN_OFFSET; static final int EEP_A50904_HSN_SIZE; static final String EEP_A50904_HSN_AVAILABLE_DESC; static final int EEP_A50904_HSN_AVAILABLE_VALUE; static final String EEP_A50904_HSN_NOT_AVAILABLE_DESC; static final int EEP_A50904_HSN_NOT_AVAILABLE_VALUE; static final int EEP_A50904_TSN_OFFSET; static final int EEP_A50904_TSN_SIZE; static final String EEP_A50904_TSN_AVAILABLE_DESC; static final int EEP_A50904_TSN_AVAILABLE_VALUE; static final String EEP_A50904_TSN_NOT_AVAILABLE_DESC; static final int EEP_A50904_TSN_NOT_AVAILABLE_VALUE; static final int EEP_A50904_TMP_FRACTIONAL_DIGITS; static final int EEP_A50904_HUM_FRACTIONAL_DIGITS; static final int EEP_A50904_CONC_FRACTIONAL_DIGITS; }