You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/10/25 12:31:07 UTC

[GitHub] [mynewt-nimble] andrzej-kaczmarek commented on a change in pull request #540: nimble/host: Add support to accept or reject pairing request through GAP event

andrzej-kaczmarek commented on a change in pull request #540: nimble/host: Add support to accept or reject pairing request through GAP event
URL: https://github.com/apache/mynewt-nimble/pull/540#discussion_r339027388
 
 

 ##########
 File path: nimble/host/src/ble_gap.c
 ##########
 @@ -5309,6 +5309,29 @@ ble_gap_identity_event(uint16_t conn_handle)
     ble_gap_call_conn_event_cb(&event, conn_handle);
 }
 
+int
+ble_gap_pairing_req_event(const struct ble_gap_pairing_req *req)
+{
+#if !NIMBLE_BLE_SM
+    return 0;
+#endif
+
+    struct ble_gap_event event;
+    int rc;
+
+    memset(&event, 0, sizeof event);
+    event.type = BLE_GAP_EVENT_PAIRING_REQUEST;
+    event.pairing_req.io_cap = req->io_cap;
+    event.pairing_req.oob_data_flag = req->oob_data_flag;
+    event.pairing_req.authreq = req->authreq;
+    event.pairing_req.max_enc_key_size = req->max_enc_key_size;
+    event.pairing_req.init_key_dist = req->init_key_dist;
+    event.pairing_req.resp_key_dist = req->resp_key_dist;
+
+    rc = ble_gap_call_conn_event_cb(&event, req->conn_handle);
 
 Review comment:
   there is already API which allows for asynchronous replies for pairing (`ble_sm_inject_io`) and it should be reused here. we had offline discussion about this and reasonable way to do this would be to add two extra actions to inject: `BLE_SM_IOACT_JUSTWORKS` and `BLE_SM_IOACT_REJECT`. the former would be used to accept just works and the latter to reject any pairing (we do not have option to reject other pairing methods now, but if just works can be rejected then all other methods should be also "rejectable"). to ensure compatiblility with existing app, pairing event should assume just works to be automatically accepted if handler returned 0 and wait for inject io only in case of e.g. non-zero return value.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services