Commit fcc254d1 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Redirect pubsub logs for subscriber

parent bf812553
...@@ -89,4 +89,7 @@ VariableStruct subscriberVariables = { ...@@ -89,4 +89,7 @@ VariableStruct subscriberVariables = {
.variableArray = subscriberVariableArray, .variableArray = subscriberVariableArray,
}; };
void Subscriber_log(void *context, UA_LogLevel level, UA_LogCategory category,
const char *msg, va_list args);
#endif /* __DRONEDGE_H__ */ #endif /* __DRONEDGE_H__ */
...@@ -59,7 +59,7 @@ typedef struct { ...@@ -59,7 +59,7 @@ typedef struct {
void (*init_node_id)(UA_UInt32 id, UA_UInt32 nb, UA_UInt32 magic); void (*init_node_id)(UA_UInt32 id, UA_UInt32 nb, UA_UInt32 magic);
} InstanceData; } InstanceData;
int runPubsub(UA_String *transportProfile, int runPubsub(const UA_Logger *logger, UA_String *transportProfile,
UA_NetworkAddressUrlDataType *networkAddressUrl, UA_NetworkAddressUrlDataType *networkAddressUrl,
VariableStruct variables, UA_UInt32 id, VariableStruct variables, UA_UInt32 id,
InstanceData *readerArray, UA_UInt32 nbReader, InstanceData *readerArray, UA_UInt32 nbReader,
......
...@@ -11,6 +11,8 @@ UA_NodeId connectionIdent, publishedDataSetIdent, writerGroupIdent, ...@@ -11,6 +11,8 @@ UA_NodeId connectionIdent, publishedDataSetIdent, writerGroupIdent,
UA_DataSetReaderConfig readerConfig; UA_DataSetReaderConfig readerConfig;
const UA_Logger *pubsubLogger;
VariableData (*pubsubGetValue)(UA_String identifier); VariableData (*pubsubGetValue)(UA_String identifier);
static void (*callbackUpdate)(UA_UInt32, const UA_DataValue*, bool print); static void (*callbackUpdate)(UA_UInt32, const UA_DataValue*, bool print);
...@@ -90,7 +92,7 @@ readVariable(UA_Server *server, ...@@ -90,7 +92,7 @@ readVariable(UA_Server *server,
} }
if(retval != UA_STATUSCODE_GOOD) if(retval != UA_STATUSCODE_GOOD)
UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "read returned value %d", retval); UA_LOG_ERROR(pubsubLogger, UA_LOGCATEGORY_USERLAND, "read returned value %d", retval);
dataValue->hasValue = true; dataValue->hasValue = true;
return retval; return retval;
} }
...@@ -100,7 +102,7 @@ writeVariable(UA_Server *server, ...@@ -100,7 +102,7 @@ writeVariable(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) { const UA_NumericRange *range, const UA_DataValue *data) {
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, UA_LOG_INFO(pubsubLogger, UA_LOGCATEGORY_USERLAND,
"Updating variables manually is not implemented"); "Updating variables manually is not implemented");
return UA_STATUSCODE_BADINTERNALERROR; return UA_STATUSCODE_BADINTERNALERROR;
} }
...@@ -360,7 +362,7 @@ static void fillDataSetMetaData(UA_DataSetMetaDataType *pMetaData, ...@@ -360,7 +362,7 @@ static void fillDataSetMetaData(UA_DataSetMetaDataType *pMetaData,
/* Definition of number of fields sizeto create different /* Definition of number of fields sizeto create different
* targetVariables of distinct datatype */ * targetVariables of distinct datatype */
pMetaData->fieldsSize = variables.nbVariable; pMetaData->fieldsSize = variables.nbVariable;
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "fieldsSize %d", (int) pMetaData->fieldsSize); UA_LOG_INFO(pubsubLogger, UA_LOGCATEGORY_USERLAND, "fieldsSize %d", (int) pMetaData->fieldsSize);
pMetaData->fields = (UA_FieldMetaData*)UA_Array_new (pMetaData->fieldsSize, pMetaData->fields = (UA_FieldMetaData*)UA_Array_new (pMetaData->fieldsSize,
&UA_TYPES[UA_TYPES_FIELDMETADATA]); &UA_TYPES[UA_TYPES_FIELDMETADATA]);
...@@ -406,7 +408,7 @@ setVariableType(UA_Server *server, VariableStruct variables) { ...@@ -406,7 +408,7 @@ setVariableType(UA_Server *server, VariableStruct variables) {
break; break;
default: default:
UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Valuerank not handled"); UA_LOG_ERROR(pubsubLogger, UA_LOGCATEGORY_USERLAND, "Valuerank not handled");
break; break;
} }
} }
...@@ -470,7 +472,7 @@ subscribe(UA_Server *server, InstanceData *instanceArray, UA_UInt32 id, ...@@ -470,7 +472,7 @@ subscribe(UA_Server *server, InstanceData *instanceArray, UA_UInt32 id,
return retval; return retval;
} }
int runPubsub(UA_String *transportProfile, int runPubsub(const UA_Logger *logger, UA_String *transportProfile,
UA_NetworkAddressUrlDataType *networkAddressUrl, UA_NetworkAddressUrlDataType *networkAddressUrl,
VariableStruct variables, UA_UInt32 id, VariableStruct variables, UA_UInt32 id,
InstanceData *readerArray, UA_UInt32 nbReader, InstanceData *readerArray, UA_UInt32 nbReader,
...@@ -481,6 +483,7 @@ int runPubsub(UA_String *transportProfile, ...@@ -481,6 +483,7 @@ int runPubsub(UA_String *transportProfile,
UA_Boolean *running) { UA_Boolean *running) {
UA_Server *server; UA_Server *server;
UA_StatusCode retval; UA_StatusCode retval;
pubsubLogger = logger;
server = setServer(transportProfile, networkAddressUrl, id); server = setServer(transportProfile, networkAddressUrl, id);
setVariableType(server, variables); setVariableType(server, variables);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment