void on_nble_sm_passkey_disp_evt(const struct nble_sm_passkey_disp_evt *ev) { struct bt_conn *conn; conn = bt_conn_lookup_handle(ev->conn_handle); if (!conn) { BT_ERR("Unable to find conn for handle %u", ev->conn_handle); return; } BT_DBG("conn %p passkey %u", conn, ev->passkey); /* TODO: Check shall we store io_caps globally */ if (get_io_capa() == BT_SMP_IO_DISPLAY_YESNO) { if (nble.auth && nble.auth->passkey_confirm) { nble.auth->passkey_confirm(conn, ev->passkey); } } else { if (nble.auth && nble.auth->passkey_display) { nble.auth->passkey_display(conn, ev->passkey); } } bt_conn_unref(conn); }
void on_nble_sm_pairing_request_evt(const struct nble_sm_pairing_request_evt *evt) { struct bt_conn *conn; struct bt_smp *smp; BT_DBG(""); conn = bt_conn_lookup_handle(evt->conn_handle); if (!conn) { BT_ERR("Unable to find conn for handle %u", evt->conn_handle); return; } smp = smp_chan_get(conn); if (!smp) { BT_ERR("No smp"); bt_conn_unref(conn); return; } atomic_set_bit(&smp->flags, SMP_FLAG_PAIRING); legacy_pairing_req(smp, evt->sec_param.remote_io); bt_conn_unref(conn); }
void on_nble_gap_conn_update_evt(const struct nble_gap_conn_update_evt *evt) { struct bt_conn *conn; uint16_t handle, interval; handle = evt->conn_handle; interval = evt->conn_values.interval; /* BT_DBG("status %u, handle %u", evt->status, handle); */ conn = bt_conn_lookup_handle(handle); if (!conn) { /* BT_ERR("Unable to lookup conn for handle %u", handle); */ return; } /* if (!evt->status) { */ conn->le.interval = interval; conn->le.latency = evt->conn_values.latency; conn->le.timeout = evt->conn_values.supervision_to; notify_le_param_updated(conn); /* } */ bt_conn_unref(conn); }
void on_nble_gap_disconnect_evt(const struct nble_gap_disconnect_evt *evt) { struct bt_conn *conn; #if 0 /* Nordic has no disconnection error */ if (evt->status) { return; } #endif conn = bt_conn_lookup_handle(evt->conn_handle); if (!conn) { BT_DBG("Unable to look up conn with handle %u", evt->conn_handle); return; } #if 0 /* Check stacks usage (no-ops if not enabled) */ stack_analyze("rx stack", rx_fiber_stack, sizeof(rx_fiber_stack)); stack_analyze("cmd rx stack", rx_prio_fiber_stack, sizeof(rx_prio_fiber_stack)); stack_analyze("cmd tx stack", cmd_tx_fiber_stack, sizeof(cmd_tx_fiber_stack)); stack_analyze("conn tx stack", conn->stack, sizeof(conn->stack)); #endif conn->err = evt->hci_reason; bt_conn_set_state(conn, BT_CONN_DISCONNECTED); conn->handle = 0; #if 0 /* Only LE supported */ if (conn->type != BT_CONN_TYPE_LE) { bt_conn_unref(conn); return; } /* TODO enabled when autoconn is supported */ if (atomic_test_bit(conn->flags, BT_CONN_AUTO_CONNECT)) { bt_conn_set_state(conn, BT_CONN_CONNECT_SCAN); bt_le_scan_update(false); } #endif bt_conn_unref(conn); if (atomic_test_bit(bt_dev.flags, BT_DEV_KEEP_ADVERTISING)) { set_advertise_enable(); } }
void on_nble_sm_passkey_req_evt(const struct nble_sm_passkey_req_evt *ev) { struct bt_conn *conn; conn = bt_conn_lookup_handle(ev->conn_handle); if (!conn) { BT_ERR("Unable to find conn for handle %u", ev->conn_handle); return; } if (ev->key_type == NBLE_GAP_SM_PK_PASSKEY) { nble.auth->passkey_entry(conn); } bt_conn_unref(conn); }
void on_nble_gap_conn_update_evt(const struct nble_gap_conn_update_evt *ev) { struct bt_conn *conn; conn = bt_conn_lookup_handle(ev->conn_handle); if (!conn) { BT_ERR("Unable to find conn for handle %u", ev->conn_handle); return; } BT_DBG("conn %p handle %u interval %u latency %u to %u", conn, ev->conn_handle, ev->conn_values.interval, ev->conn_values.latency, ev->conn_values.supervision_to); bt_conn_unref(conn); }
void on_nble_sm_status_evt(const struct nble_sm_status_evt *ev) { struct bt_conn *conn; struct bt_smp *smp; conn = bt_conn_lookup_handle(ev->conn_handle); if (!conn) { BT_ERR("Unable to find conn for handle %u", ev->conn_handle); return; } smp = smp_chan_get(conn); if (!smp) { BT_ERR("No smp for conn %p", conn); return; } BT_DBG("conn %p status %d evt_type %d sec_level %d enc_size %u", conn, ev->status, ev->evt_type, ev->enc_link_sec.sec_level, ev->enc_link_sec.enc_size); switch (ev->evt_type) { case NBLE_GAP_SM_EVT_BONDING_COMPLETE: BT_DBG("Bonding complete"); if (ev->status) { if (nble.auth && nble.auth->cancel) { nble.auth->cancel(conn); } } smp_reset(smp); break; case NBLE_GAP_SM_EVT_LINK_ENCRYPTED: BT_DBG("Link encrypted"); break; case NBLE_GAP_SM_EVT_LINK_SECURITY_CHANGE: BT_DBG("Security change"); break; default: BT_ERR("Unknown event %d", ev->evt_type); break; } bt_conn_unref(conn); }
void on_nble_sm_security_request_evt(const struct nble_sm_security_request_evt *evt) { struct bt_conn *conn; struct bt_smp *smp; BT_DBG(""); conn = bt_conn_lookup_handle(evt->conn_handle); if (!conn) { BT_ERR("Unable to find conn for handle %u", evt->conn_handle); return; } smp = smp_chan_get(conn); if (!smp) { BT_ERR("No smp"); bt_conn_unref(conn); return; } BT_DBG("conn %p remote_io %u mitm %u", conn, evt->sec_param.remote_io, evt->sec_param.mitm); smp->method = legacy_get_pair_method(smp, evt->sec_param.remote_io); if (smp->method == JUST_WORKS && nble.auth && nble.auth->pairing_confirm) { atomic_set_bit(&smp->flags, SMP_FLAG_USER); nble.auth->pairing_confirm(smp->conn); goto done; } if (evt->sec_param.mitm) { bt_conn_security(conn, BT_SECURITY_HIGH); } else { bt_conn_security(conn, BT_SECURITY_MEDIUM); } done: atomic_set_bit(&smp->flags, SMP_FLAG_SEC_REQ); bt_conn_unref(conn); }
void on_nble_gap_disconnect_evt(const struct nble_gap_disconnect_evt *ev) { struct bt_conn *conn; conn = bt_conn_lookup_handle(ev->conn_handle); if (!conn) { BT_ERR("Unable to find conn for handle %u", ev->conn_handle); return; } BT_DBG("conn %p handle %u", conn, ev->conn_handle); conn->state = BT_CONN_DISCONNECTED; notify_disconnected(conn); /* Drop the reference given by lookup_handle() */ bt_conn_unref(conn); /* Drop the initial reference from conn_new() */ bt_conn_unref(conn); }
void on_nble_sm_status_evt(const struct nble_sm_status_evt *ev) { struct bt_conn *conn; if (ev->status) { BT_ERR("SM request failed, status %d", ev->status); return; } conn = bt_conn_lookup_handle(ev->conn_handle); if (!conn) { BT_ERR("Unable to find conn for handle %u", ev->conn_handle); return; } BT_DBG("conn %p status %d evt_type %d", conn, ev->status, ev->evt_type); /* TODO Handle events */ switch (ev->evt_type) { case NBLE_GAP_SM_EVT_START_PAIRING: BT_DBG("Start pairing"); break; case NBLE_GAP_SM_EVT_BONDING_COMPLETE: BT_DBG("Bonding complete"); break; case NBLE_GAP_SM_EVT_LINK_ENCRYPTED: BT_DBG("Link encrypted"); break; case NBLE_GAP_SM_EVT_LINK_SECURITY_CHANGE: BT_DBG("Security change"); break; default: BT_ERR("Unknown event %d", ev->evt_type); break; } bt_conn_unref(conn); }