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

dronedge.h: stop hardcoding variables number

Define the number of OPC-UA variables of each entity (drone or subscriber) in a
global value.
parent 238006e9
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include "autopilot_wrapper.h" #include "autopilot_wrapper.h"
#include "pubsub.h" #include "pubsub.h"
#define MAX_VARIABLE_NB 3 #define DRONE_VARIABLE_NB 3
#define SUBSCRIBER_VARIABLE_NB 1
struct messageNode { struct messageNode {
char *message; char *message;
struct messageNode *next; struct messageNode *next;
...@@ -66,7 +66,7 @@ VariableData droneVariableArray[] = { ...@@ -66,7 +66,7 @@ VariableData droneVariableArray[] = {
}; };
VariableStruct droneVariables = { VariableStruct droneVariables = {
.nbVariable = 3, .nbVariable = DRONE_VARIABLE_NB,
.variableArray = droneVariableArray, .variableArray = droneVariableArray,
}; };
...@@ -85,7 +85,7 @@ VariableData subscriberVariableArray[] = { ...@@ -85,7 +85,7 @@ VariableData subscriberVariableArray[] = {
}; };
VariableStruct subscriberVariables = { VariableStruct subscriberVariables = {
.nbVariable = 1, .nbVariable = SUBSCRIBER_VARIABLE_NB,
.variableArray = subscriberVariableArray, .variableArray = subscriberVariableArray,
}; };
......
#include <math.h>
#include <pthread.h> #include <pthread.h>
#include "dronedge.h" #include "dronedge.h"
...@@ -516,7 +517,8 @@ static JSValue js_run_pubsub(JSContext *ctx, JSValueConst this_val, ...@@ -516,7 +517,8 @@ static JSValue js_run_pubsub(JSContext *ctx, JSValueConst this_val,
pubsubExited = false; pubsubExited = false;
res = runPubsub(logger, &transportProfile, &networkAddressUrl, variables, res = runPubsub(logger, &transportProfile, &networkAddressUrl, variables,
id, instanceArray, nbPeer, MAX_VARIABLE_NB, interval, id, instanceArray, nbPeer,
fmax(DRONE_VARIABLE_NB, SUBSCRIBER_VARIABLE_NB), interval,
get_drone_id, pubsub_get_value, pubsub_update_variables, get_drone_id, pubsub_get_value, pubsub_update_variables,
&pubsubShouldRun); &pubsubShouldRun);
pubsubExited = true; pubsubExited = true;
......
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