Search in sources :

Example 1 with MBusClientMethod

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) MethodParameter(org.openmuc.jdlms.MethodParameter) MBusClientMethod(org.opensmartgridplatform.dlms.interfaceclass.method.MBusClientMethod)

Example 2 with MBusClientMethod

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);
}
Also used : MethodParameter(org.openmuc.jdlms.MethodParameter) MBusClientMethod(org.opensmartgridplatform.dlms.interfaceclass.method.MBusClientMethod)

Example 3 with MBusClientMethod

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) MethodParameter(org.openmuc.jdlms.MethodParameter) MBusClientMethod(org.opensmartgridplatform.dlms.interfaceclass.method.MBusClientMethod)

Aggregations

MethodParameter (org.openmuc.jdlms.MethodParameter)3 MBusClientMethod (org.opensmartgridplatform.dlms.interfaceclass.method.MBusClientMethod)3 DataObject (org.openmuc.jdlms.datatypes.DataObject)2 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1