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

Add timestamp to JSDroneData

Include timestamp into position array
parent fdde4519
...@@ -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;
......
...@@ -183,6 +183,8 @@ static JSValue js_drone_get(JSContext *ctx, JSValueConst thisVal, int magic) ...@@ -183,6 +183,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;
} }
...@@ -261,6 +263,7 @@ static const JSCFunctionListEntry js_drone_proto_funcs[] = { ...@@ -261,6 +263,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),
}; };
...@@ -370,6 +373,7 @@ static void pubsub_update_variables(UA_UInt32 id, const UA_DataValue *var, bool ...@@ -370,6 +373,7 @@ static void pubsub_update_variables(UA_UInt32 id, const UA_DataValue *var, bool
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 (print) { if (print) {
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