use of org.opensmartgridplatform.dlms.interfaceclass.method.MBusClientMethod in project open-smart-grid-platform by OSGP.
the class SetEncryptionKeyExchangeOnGMeterCommandExecutor method getTransferKeyMethodParameter.
private MethodParameter getTransferKeyMethodParameter(final String mbusDeviceIdentification, final int channel, final byte[] gMeterUserKey, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final DlmsDevice mbusDevice = this.dlmsDeviceRepository.findByDeviceIdentification(mbusDeviceIdentification);
if (mbusDevice == null) {
throw new ProtocolAdapterException("Unknown M-Bus device: " + mbusDeviceIdentification);
}
final byte[] mbusDefaultKey = this.secretManagementService.getKey(messageMetadata, mbusDeviceIdentification, G_METER_MASTER);
final byte[] encryptedUserKey = this.encryptMbusUserKey(mbusDefaultKey, gMeterUserKey);
final DataObject methodParameter = DataObject.newOctetStringData(encryptedUserKey);
final MBusClientMethod method = MBusClientMethod.TRANSFER_KEY;
return new MethodParameter(method.getInterfaceClass().id(), OBIS_HASHMAP.get(channel), method.getMethodId(), methodParameter);
}
use of org.opensmartgridplatform.dlms.interfaceclass.method.MBusClientMethod in project open-smart-grid-platform by OSGP.
the class ClearMBusStatusOnAllChannelsCommandExecutor method resetAlarm.
private MethodResult resetAlarm(final DlmsConnectionManager conn, final int channel, final ObisCode obisCode) throws IOException {
final MBusClientMethod method = MBusClientMethod.RESET_ALARM;
final MethodParameter methodParameter = new MethodParameter(method.getInterfaceClass().id(), obisCode, method.getMethodId(), DataObject.newInteger8Data((byte) 0));
conn.getDlmsMessageListener().setDescription("ClearMBusStatusOnAllChannels-resetAlarm for channel" + channel + " - calling client setup: " + JdlmsObjectToStringUtil.describeMethod(methodParameter));
log.info("Calling method RESET_ALARM for channel {} with methodParam: {}.", channel, methodParameter);
return conn.getConnection().action(methodParameter);
}
use of org.opensmartgridplatform.dlms.interfaceclass.method.MBusClientMethod in project open-smart-grid-platform by OSGP.
the class SetEncryptionKeyExchangeOnGMeterCommandExecutor method getSetEncryptionKeyMethodParameter.
private MethodParameter getSetEncryptionKeyMethodParameter(final ObisCode obisCode, final byte[] encryptionKey) {
final DataObject methodParameter = DataObject.newOctetStringData(encryptionKey);
final MBusClientMethod method = MBusClientMethod.SET_ENCRYPTION_KEY;
return new MethodParameter(method.getInterfaceClass().id(), obisCode, method.getMethodId(), methodParameter);
}
Aggregations