diff options
author | saman <mahmoudi.saman1@gmail.com> | 2020-09-19 08:07:38 +0430 |
---|---|---|
committer | Saman Mahmoodi <mahmoudi.saman1@gmail.com> | 2020-10-06 05:12:22 +0000 |
commit | 7a2bf13a66a868157722a06bcf259f94ed6441b5 (patch) | |
tree | 3f1b04c42610de5b93d1900f95913f83f7130d96 /binding/bluetooth-api.c | |
parent | 8ba3e0d2ffe62c2c94844d8b536c1d49e12e35dd (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-api.c')
-rw-r--r-- | binding/bluetooth-api.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c index 876f546..85bd672 100644 --- a/binding/bluetooth-api.c +++ b/binding/bluetooth-api.c @@ -1200,6 +1200,8 @@ static void bluetooth_pair_device(afb_req_t request) cw->request = request; afb_req_addref(request); + cw->agent_data.fixed_pincode = get_pincode(afb_req_get_api(request)); + cw->cpw = bluez_call_async(ns, BLUEZ_AT_DEVICE, device, "Pair", NULL, &error, pair_service_callback, cw); @@ -1392,6 +1394,24 @@ out_success: afb_req_success(request, NULL, "Bluetooth - AVRCP controls"); } +static void bluetooth_pincode(afb_req_t request) +{ + char *error = NULL; + const char *pincode; + int rc; + + pincode = afb_req_value(request, "pincode"); + rc = set_pincode(afb_req_get_api(request), pincode, &error); + + if (rc) { + afb_req_fail(request, "failed", error); + return; + } + + afb_req_success(request, NULL, "Bluetooth - pincode"); + return; +} + static const afb_verb_t bluetooth_verbs[] = { { .verb = "subscribe", @@ -1453,7 +1473,11 @@ static const afb_verb_t bluetooth_verbs[] = { .session = AFB_SESSION_NONE, .callback = bluetooth_avrcp_controls, .info = "AVRCP controls" - }, + }, { + .verb = "set_pincode", + .session = AFB_SESSION_NONE, + .callback = bluetooth_pincode, + .info = "Set pincode for outgoing pairing"}, { } /* marker for end of the array */ }; |