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

Add timestamp to position array

parent 8922946b
...@@ -25,6 +25,7 @@ typedef struct { ...@@ -25,6 +25,7 @@ typedef struct {
UA_Double longitude; UA_Double longitude;
UA_Double altitudeAbs; UA_Double altitudeAbs;
UA_Double altitudeRel; UA_Double altitudeRel;
UA_Double timestamp;
UA_Float yaw; UA_Float yaw;
UA_Float speed; UA_Float speed;
UA_Float climbRate; UA_Float climbRate;
......
...@@ -185,6 +185,8 @@ static JSValue js_drone_get(JSContext *ctx, JSValueConst thisVal, int magic) ...@@ -185,6 +185,8 @@ static JSValue js_drone_get(JSContext *ctx, JSValueConst thisVal, int magic)
pthread_cond_signal(&threadCond); pthread_cond_signal(&threadCond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return res; return res;
case 9:
return JS_NewFloat64(ctx, s->timestamp);
default: default:
return JS_EXCEPTION; return JS_EXCEPTION;
} }
...@@ -263,6 +265,7 @@ static const JSCFunctionListEntry js_drone_proto_funcs[] = { ...@@ -263,6 +265,7 @@ static const JSCFunctionListEntry js_drone_proto_funcs[] = {
JS_CGETSET_MAGIC_DEF("speed", js_drone_get, NULL, 6), JS_CGETSET_MAGIC_DEF("speed", js_drone_get, NULL, 6),
JS_CGETSET_MAGIC_DEF("climbRate", js_drone_get, NULL, 7), JS_CGETSET_MAGIC_DEF("climbRate", js_drone_get, NULL, 7),
JS_CGETSET_MAGIC_DEF("message", js_drone_get, NULL, 8), JS_CGETSET_MAGIC_DEF("message", js_drone_get, NULL, 8),
JS_CGETSET_MAGIC_DEF("timestamp", js_drone_get, NULL, 9),
JS_CFUNC_DEF("init", 1, js_drone_init), JS_CFUNC_DEF("init", 1, js_drone_init),
}; };
...@@ -372,6 +375,7 @@ static void pubsub_update_variables(UA_UInt32 id, const UA_DataValue *var) ...@@ -372,6 +375,7 @@ static void pubsub_update_variables(UA_UInt32 id, const UA_DataValue *var)
s->longitude = positionArray[1]; s->longitude = positionArray[1];
s->altitudeAbs = positionArray[2]; s->altitudeAbs = positionArray[2];
s->altitudeRel = positionArray[3]; s->altitudeRel = positionArray[3];
s->timestamp = positionArray[4];
if (!isADrone) { if (!isADrone) {
UA_LOG_INFO(logger, UA_LOGCATEGORY_CLIENT, UA_LOG_INFO(logger, UA_LOGCATEGORY_CLIENT,
......
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