I am trying to acquire server capability information of a server, without using multicast Extension(no MDNS). As FindServers method, works on applicationDescription and UA_registeredServer structure, I have modified the structure by adding the two fields needed to accomodate the capability information.
typedef struct {
UA_String serverUri;
UA_String productUri;
size_t serverNamesSize;
UA_LocalizedText *serverNames;
UA_ApplicationType serverType;
UA_String gatewayServerUri;
size_t discoveryUrlsSize;
UA_String *discoveryUrls;
UA_String semaphoreFilePath;
UA_Boolean isOnline;
//ADDED
size_t serverCapabilitiesSize;
UA_String *serverCapabilities;
} UA_RegisteredServer;
typedef struct {
UA_String applicationUri;
UA_String productUri;
UA_LocalizedText applicationName;
UA_ApplicationType applicationType;
UA_String gatewayServerUri;
UA_String discoveryProfileUri;
size_t discoveryUrlsSize;
UA_String *discoveryUrls;
//ADDED
size_t serverCapabilitiesSize;
UA_String *serverCapabilities;
} UA_ApplicationDescription;
Initial configuration of the LDS would be something like this:
config->applicationDescription.serverCapabilitiesSize= 2;
UA_String *caps = (UA_String *) UA_Array_new(2, &UA_TYPES[UA_TYPES_STRING]);
caps[0]=UA_String_fromChars("LDS");
caps[1]=UA_String_fromChars("TEST");
config->applicationDescription.serverCapabilities = caps;
UA_StatusCode retval = UA_Server_run(server, &running);
Within the register_server_with_discoveryServer, I have added the functionality
request.server.serverCapabilitiesSize=server->config.applicationDescription.serverCapabilitiesSize;
size_t temp_size = server->config.applicationDescription.serverCapabilitiesSize;
request.server.serverCapabilities = (UA_String*)
UA_Array_new(temp_size, &UA_TYPES[UA_TYPES_STRING]);
if(!request.server.serverCapabilities)
return UA_STATUSCODE_BADOUTOFMEMORY;
for(size_t i = 0; i < temp_size; ++i)
request.server.serverCapabilities[i]=server->config.applicationDescription.serverCapabilities[i];
Now when I run the findServers.c code, I expect the value of the serverCapabilities to be shown, when I go into the applicationDescription details. But I do not get the result. Inside the FindServers.c code, I print the size of the capabilities. It shows to be 0, But while the server registers it is 2.
for(size_t i = 0; i < applicationDescriptionArraySize; i++) {
UA_ApplicationDescription *description = &applicationDescriptionArray[i];
printf("\n The size: %ld",description->serverCapabilitiesSize);
}
And the o/p is:
Server[0]: urn:open62541.example.local_discovery_server
Name: open62541-based OPC UA Application
Application URI: urn:open62541.example.local_discovery_server
Product URI: http://open62541.org
Type: Discovery Server
Discovery URL:opc.tcp://o755-gksr:4840/
The size: 0
Is it the case that serverCapabililty Identifier is only used with mDNS and cannot be modified to use in cases without mDNS?
[ x] open62541 Version (release number or git tag): v1.2-119-g7bde5f2b
Build option: cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_NAMESPACE_ZERO=FULL UA_ENABLE_DISCOVER = ON UA_ENABLE_DISCOVERY_MULTICAST = ON UA_ENABLE_AMALGAMATION = ON ..