12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <open62541/server.h>
- #include <open62541/server_config_default.h>
- #include <signal.h>
- #include <stdlib.h>
- UA_Boolean running = true;
- static void stopHandler(int sig) {
- running = false;
- }
- int main(void) {
- signal(SIGINT, stopHandler);
- signal(SIGTERM, stopHandler);
- UA_Server *server = UA_Server_new();
- UA_ServerConfig *config = UA_Server_getConfig(server);
- UA_ServerConfig_setDefault(config);
-
-
-
- config->applicationDescription.applicationType = UA_APPLICATIONTYPE_DISCOVERYSERVER;
- UA_String_clear(&config->applicationDescription.applicationUri);
- config->applicationDescription.applicationUri =
- UA_String_fromChars("urn:open62541.example.local_discovery_server");
-
- config->discovery.mdnsEnable = true;
- config->discovery.mdns.mdnsServerName = UA_String_fromChars("LDS");
-
-
-
-
-
-
-
- config->discovery.mdns.serverCapabilitiesSize = 1;
- UA_String *caps = (UA_String *) UA_Array_new(1, &UA_TYPES[UA_TYPES_STRING]);
- caps[0] = UA_String_fromChars("LDS");
- config->discovery.mdns.serverCapabilities = caps;
-
-
- UA_StatusCode retval = UA_Server_run(server, &running);
- UA_Server_delete(server);
- return retval == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE;
- }
|