From dd2d10a4c2d58f64c2eb7631e7429c255a89ae96 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 13 Sep 2018 13:05:50 -0700 Subject: binding: bluetooth: add adapter parameter to JSON output Allow subscribers to get the respective devices adapter from a BlueZ path Bug-AGL: SPEC-1720 Change-Id: Ie7fc43558d386bb010f34e64e967c0bf0f054b45 Signed-off-by: Matt Ranostay --- binding-bluetooth/bluetooth-api.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/binding-bluetooth/bluetooth-api.c b/binding-bluetooth/bluetooth-api.c index 8823b23..dfe946c 100644 --- a/binding-bluetooth/bluetooth-api.c +++ b/binding-bluetooth/bluetooth-api.c @@ -160,13 +160,17 @@ static json_object *new_json_object_from_device(struct btd_device *BDdevice, uns { if (BDdevice->path) { + gchar **str; + jstring = json_object_new_string(BDdevice->path); + json_object_object_add(jresp, "Path", jstring); + + str = g_strsplit(BDdevice->path, "/", 0); + jstring = json_object_new_string(str[3]); + g_strfreev(str); + + json_object_object_add(jresp, "Adapter", jstring); } - else - { - jstring = json_object_new_string(""); - } - json_object_object_add(jresp, "Path", jstring); } if (BD_ADDER & filter) -- cgit 1.2.3-korg