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

Add network interface as a parameter for pubsub

parent 4a529174
......@@ -185,22 +185,24 @@ static JSValue js_run_pubsub(JSContext *ctx, JSValueConst this_val,
{
const char *ipv6;
const char *port;
const char *net_iface;
char urlBuffer[44];
int id;
int res;
ipv6 = JS_ToCString(ctx, argv[0]);
port = JS_ToCString(ctx, argv[1]);
net_iface = JS_ToCString(ctx, argv[2]);
UA_snprintf(urlBuffer, sizeof(urlBuffer), "opc.udp://[%s]:%s/", ipv6, port);
UA_String transportProfile =
UA_STRING("http://opcfoundation.org/UA-Profile/Transport/pubsub-udp-uadp");
UA_NetworkAddressUrlDataType networkAddressUrl;
networkAddressUrl.networkInterface = UA_STRING("eth0");
networkAddressUrl.networkInterface = UA_STRING(net_iface);
networkAddressUrl.url = UA_STRING(urlBuffer);
if (JS_ToInt32(ctx, &id, argv[2]))
if (JS_ToInt32(ctx, &id, argv[3]))
return JS_EXCEPTION;
res = runPubsub(&transportProfile, &networkAddressUrl, droneVariableArray,
......@@ -209,6 +211,7 @@ static JSValue js_run_pubsub(JSContext *ctx, JSValueConst this_val,
JS_FreeCString(ctx, ipv6);
JS_FreeCString(ctx, port);
JS_FreeCString(ctx, net_iface);
return JS_NewInt32(ctx, res);
}
......@@ -507,7 +510,7 @@ static const JSCFunctionListEntry js_mavsdk_funcs[] = {
JS_CFUNC_DEF("takeOffAndWait", 0, js_mavsdk_takeOffAndWait ),
JS_CFUNC_DEF("land", 0, js_mavsdk_land ),
JS_CFUNC_DEF("initPubsub", 1, js_init_pubsub ),
JS_CFUNC_DEF("runPubsub", 2, js_run_pubsub ),
JS_CFUNC_DEF("runPubsub", 4, js_run_pubsub ),
JS_CFUNC_DEF("publishCheckpoint", 1, js_publish_checkpoint ),
JS_CFUNC_DEF("stopPubsub", 0, js_stop_pubsub ),
};
......
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