From f847017f027eac43dfdfc4d169ba4478bb06d9c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20R=C3=BChl?= Date: Thu, 26 Sep 2024 12:10:03 +0200 Subject: [PATCH] fix(plc4go/opcua): fix remaining compile issues --- plc4go/internal/opcua/Reader.go | 2 +- plc4go/internal/opcua/SecureChannel.go | 34 ++++++++++----------- plc4go/internal/opcua/Subscriber.go | 10 ++++-- plc4go/internal/opcua/SubscriptionHandle.go | 6 ++-- plc4go/internal/opcua/common.go | 2 +- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/plc4go/internal/opcua/Reader.go b/plc4go/internal/opcua/Reader.go index 71230b4d0e3..114a2367e2f 100644 --- a/plc4go/internal/opcua/Reader.go +++ b/plc4go/internal/opcua/Reader.go @@ -102,7 +102,7 @@ func (m *Reader) readSync(ctx context.Context, readRequest apiModel.PlcReadReque nil, nil) - extObject := readWriteModel.NewExtensiblePayload(readWriteModel.NewRootExtensionObject(opcuaReadRequest, expandedNodeId, identifier), nil, 0) + extObject := readWriteModel.NewExtensiblePayload(nil, readWriteModel.NewRootExtensionObject(expandedNodeId, opcuaReadRequest, identifier), 0) buffer := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian)) if err := extObject.SerializeWithWriteBuffer(ctx, buffer); err != nil { diff --git a/plc4go/internal/opcua/SecureChannel.go b/plc4go/internal/opcua/SecureChannel.go index 1159d3881d3..3ca25522f58 100644 --- a/plc4go/internal/opcua/SecureChannel.go +++ b/plc4go/internal/opcua/SecureChannel.go @@ -56,7 +56,7 @@ const ( ) var ( - SECURITY_POLICY_NONE = readWriteModel.NewPascalString(utils.MakePtr("http://opcfoundation.org/UA/SecurityPolicy#None")) + SECURITY_POLICY_NONE = readWriteModel.NewPascalString(utils.ToPtr("http://opcfoundation.org/UA/SecurityPolicy#None")) NULL_STRING = readWriteModel.NewPascalString(nil) NULL_BYTE_STRING = readWriteModel.NewPascalByteString(-1, nil) NULL_EXPANDED_NODEID = readWriteModel.NewExpandedNodeId(false, @@ -73,9 +73,9 @@ var ( INET_ADDRESS_PATTERN = regexp.MustCompile(`(.(?Ptcp))?://(?P[\w.-]+)(:(?P\d*))?`) URI_PATTERN = regexp.MustCompile(`^(?Popc)` + INET_ADDRESS_PATTERN.String() + `(?P[\w/=]*)[?]?`) - APPLICATION_URI = readWriteModel.NewPascalString(utils.MakePtr("urn:apache:plc4x:client")) - PRODUCT_URI = readWriteModel.NewPascalString(utils.MakePtr("urn:apache:plc4x:client")) - APPLICATION_TEXT = readWriteModel.NewPascalString(utils.MakePtr("OPCUA client for the Apache PLC4X:PLC4J project")) + APPLICATION_URI = readWriteModel.NewPascalString(utils.ToPtr("urn:apache:plc4x:client")) + PRODUCT_URI = readWriteModel.NewPascalString(utils.ToPtr("urn:apache:plc4x:client")) + APPLICATION_TEXT = readWriteModel.NewPascalString(utils.ToPtr("OPCUA client for the Apache PLC4X:PLC4J project")) DEFAULT_CONNECTION_LIFETIME = uint32(36000000) ) @@ -381,8 +381,8 @@ func (s *SecureChannel) onConnectOpenSecureChannel(ctx context.Context, connecti ) extObject := readWriteModel.NewRootExtensionObject( - openSecureChannelRequest, expandedNodeId, + openSecureChannelRequest, identifier, ) @@ -505,7 +505,7 @@ func (s *SecureChannel) onConnectCreateSessionRequest(ctx context.Context, conne applicationName := readWriteModel.NewLocalizedText( true, true, - readWriteModel.NewPascalString(utils.MakePtr("en")), + readWriteModel.NewPascalString(utils.ToPtr("en")), APPLICATION_TEXT) var discoveryUrls []readWriteModel.PascalString @@ -539,8 +539,8 @@ func (s *SecureChannel) onConnectCreateSessionRequest(ctx context.Context, conne nil) extObject := readWriteModel.NewRootExtensionObject( - createSessionRequest, expandedNodeId, + createSessionRequest, identifier, ) @@ -653,8 +653,8 @@ func (s *SecureChannel) onConnectActivateSessionRequest(ctx context.Context, con nil) extObject := readWriteModel.NewRootExtensionObject( - activateSessionRequest, expandedNodeId, + activateSessionRequest, identifier, ) @@ -750,8 +750,8 @@ func (s *SecureChannel) onDisconnect(ctx context.Context, connection *Connection true) extObject := readWriteModel.NewRootExtensionObject( - closeSessionRequest, expandedNodeId, + closeSessionRequest, closeSessionRequest.GetExtensionId(), ) @@ -832,8 +832,8 @@ func (s *SecureChannel) onDisconnectCloseSecureChannel(ctx context.Context, conn readWriteModel.NewExtensiblePayload( readWriteModel.NewSequenceHeader(transactionId, transactionId), readWriteModel.NewRootExtensionObject( - closeSecureChannelRequest, expandedNodeId, + closeSecureChannelRequest, identifier, ), 0, @@ -973,8 +973,8 @@ func (s *SecureChannel) onDiscoverOpenSecureChannel(ctx context.Context, codec * ) extObject := readWriteModel.NewRootExtensionObject( - openSecureChannelRequest, expandedNodeId, + openSecureChannelRequest, identifier, ) @@ -1101,8 +1101,8 @@ func (s *SecureChannel) onDiscoverGetEndpointsRequest(ctx context.Context, codec ) extObject := readWriteModel.NewRootExtensionObject( - endpointsRequest, expandedNodeId, + endpointsRequest, identifier, ) @@ -1230,8 +1230,8 @@ func (s *SecureChannel) onDiscoverCloseSecureChannel(ctx context.Context, codec readWriteModel.NewExtensiblePayload( readWriteModel.NewSequenceHeader(transactionId, transactionId), readWriteModel.NewRootExtensionObject( - closeSecureChannelRequest, expandedNodeId, + closeSecureChannelRequest, identifier, ), uint32(0), @@ -1337,8 +1337,8 @@ func (s *SecureChannel) keepAlive() { nil) extObject := readWriteModel.NewRootExtensionObject( - openSecureChannelRequest, expandedNodeId, + openSecureChannelRequest, identifier, ) @@ -1570,9 +1570,9 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType, nil, ) return readWriteModel.NewBinaryExtensionObjectWithMask( - anonymousIdentityToken, extExpandedNodeId, readWriteModel.NewExtensionObjectEncodingMask(false, false, true), + anonymousIdentityToken, anonymousIdentityToken.GetExtensionId(), false, ) @@ -1599,7 +1599,7 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType, readWriteModel.NewPascalString(policyId), readWriteModel.NewPascalString(&s.username), readWriteModel.NewPascalByteString(int32(len(encryptedPassword)), encryptedPassword), - readWriteModel.NewPascalString(utils.MakePtr(PASSWORD_ENCRYPTION_ALGORITHM)), + readWriteModel.NewPascalString(utils.ToPtr(PASSWORD_ENCRYPTION_ALGORITHM)), ) extExpandedNodeId := readWriteModel.NewExpandedNodeId( false, //Namespace Uri Specified @@ -1608,9 +1608,9 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType, nil, nil) return readWriteModel.NewBinaryExtensionObjectWithMask( - userNameIdentityToken, extExpandedNodeId, readWriteModel.NewExtensionObjectEncodingMask(false, false, true), + userNameIdentityToken, userNameIdentityToken.GetExtensionId(), false, ) diff --git a/plc4go/internal/opcua/Subscriber.go b/plc4go/internal/opcua/Subscriber.go index 0ddb8fb8d63..fb58706cb5a 100644 --- a/plc4go/internal/opcua/Subscriber.go +++ b/plc4go/internal/opcua/Subscriber.go @@ -149,9 +149,13 @@ func (s *Subscriber) onSubscribeCreateSubscription(ctx context.Context, cycleTim nil, nil) - extObject := readWriteModel.NewExtensiblePayload(readWriteModel.NewRootExtensionObject( - createSubscriptionRequest, expandedNodeId, createSubscriptionRequest.GetExtensionId(), - ), nil, 0) + extObject := readWriteModel.NewExtensiblePayload( + nil, + readWriteModel.NewRootExtensionObject( + expandedNodeId, createSubscriptionRequest, createSubscriptionRequest.GetExtensionId(), + ), + 0, + ) buffer := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian)) if err := extObject.SerializeWithWriteBuffer(ctx, buffer); err != nil { diff --git a/plc4go/internal/opcua/SubscriptionHandle.go b/plc4go/internal/opcua/SubscriptionHandle.go index b777a6a4b4a..44866f88799 100644 --- a/plc4go/internal/opcua/SubscriptionHandle.go +++ b/plc4go/internal/opcua/SubscriptionHandle.go @@ -143,8 +143,8 @@ func (h *SubscriptionHandle) onSubscribeCreateMonitoredItemsRequest() (readWrite nil) extObject := readWriteModel.NewRootExtensionObject( - createMonitoredItemsRequest, expandedNodeId, + createMonitoredItemsRequest, identifier, ) @@ -273,8 +273,8 @@ func (h *SubscriptionHandle) startSubscriber() { nil) extObject := readWriteModel.NewRootExtensionObject( - publishRequest, extExpandedNodeId, + publishRequest, identifier, ) @@ -384,8 +384,8 @@ func (h *SubscriptionHandle) stopSubscriber() { ) extObject := readWriteModel.NewRootExtensionObject( - deleteSubscriptionrequest, extExpandedNodeId, + deleteSubscriptionrequest, identifier, ) diff --git a/plc4go/internal/opcua/common.go b/plc4go/internal/opcua/common.go index 92716d4342a..a3ad7943e2e 100644 --- a/plc4go/internal/opcua/common.go +++ b/plc4go/internal/opcua/common.go @@ -207,7 +207,7 @@ func readResponse(localLog zerolog.Logger, readRequestIn apiModel.PlcReadRequest array := variant.GetValue() qualifiedNameValues := make([]apiValues.PlcValue, len(array)) for i, t := range array { - qualifiedNameValues[i] = spiValues.NewPlcSTRING(fmt.Sprintf("ns=%d;s=%s", t.GetNamespaceIndex(), t.GetName().GetStringValue())) + qualifiedNameValues[i] = spiValues.NewPlcSTRING(fmt.Sprintf("ns=%d;s=%s", t.GetNamespaceIndex(), *t.GetName().GetStringValue())) } value = spiValues.NewPlcList(qualifiedNameValues) case readWriteModel.VariantExtensionObject: