Skip to content

Commit

Permalink
fix(plc4j): OPCUA more fixes for optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
hutcheb committed May 18, 2022
1 parent 9a7a42c commit b3dcb67
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Expand Up @@ -526,7 +526,7 @@ private void onConnectActivateSessionRequest(ConversationContext<OpcuaAPU> conte
expandedNodeId,
null,
activateSessionRequest,
false);
true);

try {
WriteBufferByteBased buffer = new WriteBufferByteBased(extObject.getLengthInBytes(), org.apache.plc4x.java.spi.generation.ByteOrder.LITTLE_ENDIAN);
Expand Down Expand Up @@ -618,7 +618,7 @@ public void onDisconnect(ConversationContext<OpcuaAPU> context) {
expandedNodeId,
null,
closeSessionRequest,
false);
true);

try {
WriteBufferByteBased buffer = new WriteBufferByteBased(extObject.getLengthInBytes(), org.apache.plc4x.java.spi.generation.ByteOrder.LITTLE_ENDIAN);
Expand Down Expand Up @@ -702,7 +702,7 @@ private void onDisconnectCloseSecureChannel(ConversationContext<OpcuaAPU> contex
expandedNodeId,
null,
closeSecureChannelRequest,
false));
true));

Consumer<Integer> requestConsumer = t -> {
context.sendRequest(new OpcuaAPU(closeRequest, false))
Expand Down Expand Up @@ -775,7 +775,7 @@ public void onDiscoverOpenSecureChannel(ConversationContext<OpcuaAPU> context, O
expandedNodeId,
null,
openSecureChannelRequest,
false).serialize(buffer);
true).serialize(buffer);

OpcuaOpenRequest openRequest = new OpcuaOpenRequest(FINAL_CHUNK,
0,
Expand Down Expand Up @@ -858,7 +858,7 @@ public void onDiscoverGetEndpointsRequest(ConversationContext<OpcuaAPU> context,
expandedNodeId,
null,
endpointsRequest,
false).serialize(buffer);
true).serialize(buffer);

OpcuaMessageRequest messageRequest = new OpcuaMessageRequest(FINAL_CHUNK,
channelId.get(),
Expand Down Expand Up @@ -940,7 +940,7 @@ private void onDiscoverCloseSecureChannel(ConversationContext<OpcuaAPU> context,
expandedNodeId,
null,
closeSecureChannelRequest,
false));
true));

Consumer<Integer> requestConsumer = t -> context.sendRequest(new OpcuaAPU(closeRequest, false))
.expectResponse(OpcuaAPU.class, REQUEST_TIMEOUT)
Expand Down Expand Up @@ -1208,7 +1208,7 @@ private ExtensionObject getIdentityToken(UserTokenType tokenType, String securit
return new ExtensionObject(
extExpandedNodeId,
new ExtensionObjectEncodingMask(false, false, true),
new UserIdentityToken(new PascalString(securityPolicy), anonymousIdentityToken), false);
new UserIdentityToken(new PascalString(securityPolicy), anonymousIdentityToken), true);
case userTokenTypeUserName:
//Encrypt the password using the server nonce and server public key
byte[] passwordBytes = this.password == null ? new byte[0] : this.password.getBytes();
Expand Down Expand Up @@ -1237,7 +1237,7 @@ private ExtensionObject getIdentityToken(UserTokenType tokenType, String securit
return new ExtensionObject(
extExpandedNodeId,
new ExtensionObjectEncodingMask(false, false, true),
new UserIdentityToken(new PascalString(securityPolicy), userNameIdentityToken), false);
new UserIdentityToken(new PascalString(securityPolicy), userNameIdentityToken), true);
}
return null;
}
Expand Down
Expand Up @@ -280,7 +280,7 @@ public void startSubscriber() {
} else {
serviceFault = (ServiceFault) unknownExtensionObject;
ResponseHeader header = (ResponseHeader) serviceFault.getResponseHeader();
LOGGER.error("Subscription ServiceFault returned from server with error code, '{}'", header.getServiceResult().toString());
LOGGER.debug("Subscription ServiceFault returned from server with error code, '{}', ignoring as it is probably just a result of a Delete Subscription Request", header.getServiceResult().toString());
//plcSubscriber.onDisconnect(context);
}
} catch (ParseException e) {
Expand Down Expand Up @@ -389,7 +389,7 @@ public void stopSubscriber() {
} else {
ServiceFault serviceFault = (ServiceFault) unknownExtensionObject;
ResponseHeader header = (ResponseHeader) serviceFault.getResponseHeader();
LOGGER.error("Fault when deleteing Subscription ServiceFault return from server with error code, '{}'", header.getServiceResult().toString());
LOGGER.debug("Fault when deleting Subscription ServiceFault return from server with error code, '{}', ignoring as it is probably just a result of a Delete Subscription Request", header.getServiceResult().toString());
}
} catch (ParseException e) {
LOGGER.error("Unable to parse the returned Delete Subscriptions Response", e);
Expand Down
Expand Up @@ -32,6 +32,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assumptions.assumeTrue;

Expand Down Expand Up @@ -108,6 +109,11 @@ public static void setup() {
assert opcuaConnection.isConnected();
} catch (Exception e) {
e.printStackTrace();
try {
exampleServer.shutdown().get();
} catch (Exception j) {
j.printStackTrace();
}
}
}

Expand Down

0 comments on commit b3dcb67

Please sign in to comment.