summaryrefslogtreecommitdiffstats
path: root/binding/bluetooth-agent.c
diff options
context:
space:
mode:
authorsaman <mahmoudi.saman1@gmail.com>2020-09-19 08:07:38 +0430
committerSaman Mahmoodi <mahmoudi.saman1@gmail.com>2020-10-06 05:12:22 +0000
commit7a2bf13a66a868157722a06bcf259f94ed6441b5 (patch)
tree3f1b04c42610de5b93d1900f95913f83f7130d96 /binding/bluetooth-agent.c
parent8ba3e0d2ffe62c2c94844d8b536c1d49e12e35dd (diff)
Adding pairing request with authentication as "RequestPinCode"
Adding outgoing pairing request with another BT device when we call pair verb. "RequestPinCode" is handled as xml into bluetooth-agent.c to confirm a pincode and send it to BT device when we call pair request from AGL device to other device. Bug-AGL: SPEC-3610 Signed-off-by: saman <mahmoudi.saman1@gmail.com> Change-Id: I4fa8c9ab5d3bbf323cee7645f217bb1056d93b65
Diffstat (limited to 'binding/bluetooth-agent.c')
-rw-r--r--binding/bluetooth-agent.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/binding/bluetooth-agent.c b/binding/bluetooth-agent.c
index a942baa..3783b3f 100644
--- a/binding/bluetooth-agent.c
+++ b/binding/bluetooth-agent.c
@@ -41,6 +41,10 @@
static const gchar introspection_xml[] =
"<node>"
" <interface name='org.bluez.Agent1'>"
+" <method name='RequestPinCode'>"
+" <arg name='device' direction='in' type='o'/>"
+" <arg name='pincode' direction='out' type='s'/>"
+" </method>"
" <method name='RequestConfirmation'>"
" <arg name='device' direction='in' type='o'/>"
" <arg name='passkey' direction='in' type='u'/>"
@@ -69,7 +73,7 @@ static void handle_method_call(
GError *error = NULL;
json_object *jev = NULL;
const gchar *path = NULL;
-
+ char *device = NULL;
/* AFB_INFO("sender=%s", sender_name);
AFB_INFO("object_path=%s", object_path);
AFB_INFO("interface=%s", interface_name);
@@ -114,6 +118,23 @@ static void handle_method_call(
afb_event_push(ns->agent_event, jev);
return;
+
+ } else if (!g_strcmp0(method_name, "RequestPinCode")) {
+
+ g_variant_get(parameters, "(o)", &device);
+
+ call_work_lock(ns);
+ cw = call_work_lookup_unlocked(ns, BLUEZ_AT_DEVICE, device, "pair_device");
+
+ if (!cw)
+ g_dbus_method_invocation_return_dbus_error(invocation, "org.bluez.Error.Rejected", "No connection pending");
+ else
+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", cw->agent_data.fixed_pincode));
+
+ call_work_unlock(ns);
+
+ return;
+
} else if (!g_strcmp0(method_name, "AuthorizeService")) {
/* g_variant_get(parameters, "(os)", &path, &service);