Explorar el Código

cosmetic improvements

Julius Pfrommer hace 8 años
padre
commit
a9329112c1
Se han modificado 2 ficheros con 65 adiciones y 57 borrados
  1. 60 54
      include/ua_server.h
  2. 5 3
      src/server/ua_services_discovery.c

+ 60 - 54
include/ua_server.h

@@ -603,34 +603,33 @@ UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
                                UA_NodeIteratorCallback callback, void *handle);
 
 #ifdef UA_ENABLE_DISCOVERY
- /**
+
+/**
  * Discovery
  * --------- */
- /* Register the given server instance at the discovery server.
-  * This should be called periodically.
-  * The semaphoreFilePath is optional. If the given file is deleted,
-  * the server will automatically be unregistered. This could be
-  * for example a pid file which is deleted if the server crashes.
-  *
-  * When the server shuts down you need to call unregister.
-  *
-  * @param server
-  * @param discoveryServerUrl if set to NULL, the default value
-  *        'opc.tcp://localhost:4840' will be used
-  * @param semaphoreFilePath optional parameter pointing to semaphore file.
-  */
- UA_StatusCode UA_EXPORT
- UA_Server_register_discovery(UA_Server *server, const char* discoveryServerUrl,
-                              const char* semaphoreFilePath);
-
- /* Unregister the given server instance from the discovery server.
-  * This should only be called when the server is shutting down.
-  * @param server
-  * @param discoveryServerUrl if set to NULL, the default value
-  *        'opc.tcp://localhost:4840' will be used
-  */
- UA_StatusCode UA_EXPORT
- UA_Server_unregister_discovery(UA_Server *server, const char* discoveryServerUrl);
+/* Register the given server instance at the discovery server.
+ * This should be called periodically.
+ * The semaphoreFilePath is optional. If the given file is deleted,
+ * the server will automatically be unregistered. This could be
+ * for example a pid file which is deleted if the server crashes.
+ *
+ * When the server shuts down you need to call unregister.
+ *
+ * @param server
+ * @param discoveryServerUrl if set to NULL, the default value
+ *        'opc.tcp://localhost:4840' will be used
+ * @param semaphoreFilePath optional parameter pointing to semaphore file. */
+UA_StatusCode UA_EXPORT
+UA_Server_register_discovery(UA_Server *server, const char* discoveryServerUrl,
+                             const char* semaphoreFilePath);
+
+/* Unregister the given server instance from the discovery server.
+ * This should only be called when the server is shutting down.
+ * @param server
+ * @param discoveryServerUrl if set to NULL, the default value
+ *        'opc.tcp://localhost:4840' will be used */
+UA_StatusCode UA_EXPORT
+UA_Server_unregister_discovery(UA_Server *server, const char* discoveryServerUrl);
 
  /* Adds a periodic job to register the server with the LDS (local discovery server)
   * periodically. The interval between each register call is given as second parameter.
@@ -644,17 +643,20 @@ UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
   * otherwise it will be automatically be registered again.
   *
   * @param server
-  * @param discoveryServerUrl if set to NULL, the default value 'opc.tcp://localhost:4840' will be used
+  * @param discoveryServerUrl if set to NULL, the default value
+  *        'opc.tcp://localhost:4840' will be used
   * @param intervalMs
   * @param delayFirstRegisterMs
   * @param periodicJobId */
- UA_StatusCode UA_EXPORT
+UA_StatusCode UA_EXPORT
 UA_Server_addPeriodicServerRegisterJob(UA_Server *server, const char* discoveryServerUrl,
-                                       const UA_UInt32 intervalMs, const UA_UInt32 delayFirstRegisterMs,
+                                       const UA_UInt32 intervalMs,
+                                       const UA_UInt32 delayFirstRegisterMs,
                                        UA_Guid* periodicJobId);
 
 /* Callback for RegisterServer. Data is passed from the register call */
-typedef void (*UA_Server_registerServerCallback)(const UA_RegisteredServer *registeredServer, void* data);
+typedef void (*UA_Server_registerServerCallback)(const UA_RegisteredServer *registeredServer,
+                                                 void* data);
 
 /* Set the callback which is called if another server registeres or unregisteres
  * with this instance. If called multiple times, previous data will be
@@ -663,39 +665,43 @@ typedef void (*UA_Server_registerServerCallback)(const UA_RegisteredServer *regi
  * @param server
  * @param cb the callback
  * @param data data passed to the callback
- * @return UA_STATUSCODE_SUCCESS on success
- */
+ * @return UA_STATUSCODE_SUCCESS on success */
 void UA_EXPORT
- UA_Server_setRegisterServerCallback(UA_Server *server,
-                                     UA_Server_registerServerCallback cb,
-                                     void* data);
+UA_Server_setRegisterServerCallback(UA_Server *server, UA_Server_registerServerCallback cb,
+                                    void* data);
 
 #ifdef UA_ENABLE_DISCOVERY_MULTICAST
 
-/**
- * Callback for server detected through mDNS. Data is passed from the register call
- * @param isServerAnnounce indicates if the server has just been detected. If set to false, this means the server is shutting down.
- * @param isTxtReceived indicates if we already received the corresponding TXT record with the path and caps data
- **/
-typedef void (*UA_Server_serverOnNetworkCallback)(const UA_ServerOnNetwork *serverOnNetwork, UA_Boolean isServerAnnounce, UA_Boolean isTxtReceived, void* data);
-
-/**
- * Set the callback which is called if another server is found through mDNS or deleted.
- * It will be called for any mDNS message from the remote server, thus it may be called multiple times for the same instance.
- * Also the SRV and TXT records may arrive later, therefore for the first call the server capabilities may not be set yet.
- * If called multiple times, previous data will be overwritten.
+/* Callback for server detected through mDNS. Data is passed from the register
+ * call
+ *
+ * @param isServerAnnounce indicates if the server has just been detected. If
+ *        set to false, this means the server is shutting down.
+ * @param isTxtReceived indicates if we already received the corresponding TXT
+ *        record with the path and caps data */
+typedef void (*UA_Server_serverOnNetworkCallback)(const UA_ServerOnNetwork *serverOnNetwork,
+                                                  UA_Boolean isServerAnnounce,
+                                                  UA_Boolean isTxtReceived, void* data);
+
+/* Set the callback which is called if another server is found through mDNS or
+ * deleted. It will be called for any mDNS message from the remote server, thus
+ * it may be called multiple times for the same instance. Also the SRV and TXT
+ * records may arrive later, therefore for the first call the server
+ * capabilities may not be set yet. If called multiple times, previous data will
+ * be overwritten.
+ *
  * @param server
  * @param cb the callback
  * @param data data passed to the callback
- * @return UA_STATUSCODE_SUCCESS on success
- */
+ * @return UA_STATUSCODE_SUCCESS on success */
 void UA_EXPORT
-        UA_Server_setServerOnNetworkCallback(UA_Server *server,
-                                             UA_Server_serverOnNetworkCallback cb,
-                                             void* data);
-#endif
+UA_Server_setServerOnNetworkCallback(UA_Server *server,
+                                     UA_Server_serverOnNetworkCallback cb,
+                                     void* data);
 
-#endif
+#endif /* UA_ENABLE_DISCOVERY_MULTICAST */
+
+#endif /* UA_ENABLE_DISCOVERY */
 
 /**
  * Method Call

+ 5 - 3
src/server/ua_services_discovery.c

@@ -298,7 +298,8 @@ void Service_GetEndpoints(UA_Server *server, UA_Session *session,
         for(size_t j = 0; j < server->endpointDescriptionsSize; ++j) {
             if(!relevant_endpoints[j])
                 continue;
-            retval |= UA_EndpointDescription_copy(&server->endpointDescriptions[j], &response->endpoints[k]);
+            retval |= UA_EndpointDescription_copy(&server->endpointDescriptions[j],
+                                                  &response->endpoints[k]);
             retval |= UA_String_copy(endpointUrl, &response->endpoints[k].endpointUrl);
             ++k;
         }
@@ -345,7 +346,7 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
         *responseConfigurationResults =
             (UA_StatusCode *)UA_Array_new(requestDiscoveryConfigurationSize,
                                           &UA_TYPES[UA_TYPES_STATUSCODE]);
-        for(size_t i =0; i<requestDiscoveryConfigurationSize; i++) {
+        for(size_t i = 0; i < requestDiscoveryConfigurationSize; i++) {
             const UA_ExtensionObject *object = &requestDiscoveryConfiguration[i];
             if(!mdnsConfig && (object->encoding == UA_EXTENSIONOBJECT_DECODED ||
                                object->encoding == UA_EXTENSIONOBJECT_DECODED_NODELETE) &&
@@ -386,7 +387,8 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
         free(filePath);
 #else
         UA_LOG_WARNING(server->config.logger, UA_LOGCATEGORY_CLIENT,
-                       "Ignoring semaphore file path. open62541 not compiled with UA_ENABLE_DISCOVERY_SEMAPHORE=ON");
+                       "Ignoring semaphore file path. open62541 not compiled "
+                       "with UA_ENABLE_DISCOVERY_SEMAPHORE=ON");
 #endif
     }