binding: bluetooth: report connection events 47/9747/2
authorMatt Ranostay <matt.ranostay@konsulko.com>
Thu, 15 Jun 2017 23:41:09 +0000 (16:41 -0700)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tue, 20 Jun 2017 09:49:02 +0000 (09:49 +0000)
Subscribers to the bluetooth binding need to get reports of
connection and disconnections.

Bug-AGL: SPEC-669
Change-Id: I061fd7088a3a198d8004feaf594abc44c3a43f4f
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
binding-bluetooth/bluetooth-api.c

index 04fb259..3c8d86f 100644 (file)
@@ -497,6 +497,16 @@ static void bt_connect (struct afb_req request)
 
     if (0 == ret)
     {
+        json_object *jresp = json_object_new_object();
+        json_object *jstring;
+
+        jstring = json_object_new_string("connected");
+        json_object_object_add(jresp, "Status", jstring);
+
+        jstring = json_object_new_string(value);
+        json_object_object_add(jresp, "Address", jstring);
+
+        event_push(jresp, "connection");
         afb_req_success (request, NULL, NULL);
     }
     else
@@ -523,6 +533,16 @@ static void bt_disconnect (struct afb_req request)
     ret = device_disconnect(value, NULL);
     if (0 == ret)
     {
+        json_object *jresp = json_object_new_object();
+        json_object *jstring;
+
+        jstring = json_object_new_string("disconnected");
+        json_object_object_add(jresp, "Status", jstring);
+
+        jstring = json_object_new_string(value);
+        json_object_object_add(jresp, "Address", jstring);
+
+        event_push(jresp, "connection");
         afb_req_success (request, NULL, NULL);
     }
     else