FYI: seems like it works fine if you enter passkey with leading zeroes in Android (e.g. "001234" instead of "1234"). Not sure why it works like this as passkey is handled as integer value during pairing process, but Android is apparently full of surprises ;-)
Best, Andrzej On Mon, Jul 9, 2018 at 11:49 PM Andrzej Kaczmarek <andrzej.kaczma...@codecoup.pl> wrote: > > Hi, > > You code looks ok. However, I noticed strange thing when testing with > Android phone on my side: pairing fails if specified passkey has less > than 6 digits (i.e. <100000). This does not seem to be issue in NimBLE > since the same happens when trying to pair Android with BlueZ while > pairing between NimBLE and BlueZ works just fine. Looks like some > issue in Android LE SC implementation tbh... > > So please try with 6 digits passkey (i.e. >=100000) and it should work. > > Best, > Andrzej > > > On Mon, Jul 9, 2018 at 12:08 PM Amr Bekhit <amrbek...@gmail.com> wrote: > > > > Hi Andrzej, > > > > Below is my GAP event callback function and the console output when I > > attempt to bond with my device (I'm using the Nordic nRF Connect app > > on my phone to interact with the device): > > > > static int bleprph_gap_event(struct ble_gap_event *event, void *arg) { > > int rc = 0; > > > > switch(event->type) { > > case BLE_GAP_EVENT_CONNECT: > > console_printf("Connected\n"); > > break; > > > > case BLE_GAP_EVENT_DISCONNECT: > > console_printf("Disconnected\n"); > > ble_advertise(); > > break; > > > > case BLE_GAP_EVENT_CONN_UPDATE: > > console_printf("Connection updated\n"); > > break; > > > > case BLE_GAP_EVENT_CONN_UPDATE_REQ: > > console_printf("Connection update requested\n"); > > break; > > > > case BLE_GAP_EVENT_PASSKEY_ACTION: { > > console_printf("Passkey Request. Action: %d, Numcmp: %lu\n", > > event->passkey.params.action, > > event->passkey.params.numcmp); > > > > if (event->passkey.params.action == BLE_SM_IOACT_DISP) { > > struct ble_sm_io pk; > > pk.action = event->passkey.params.action; > > pk.passkey = 4539; > > rc = ble_sm_inject_io(event->passkey.conn_handle, &pk); > > console_printf("ble_sm_inject_io result: %d\n", rc); > > } > > break; > > } > > > > default: > > console_printf("GAP Event: %i\n", event->type); > > } > > > > return rc; > > } > > > > 001039 Passkey Request. Action: 3, Numcmp: 0 > > 001040 ble_sm_inject_io result: 0 > > 001639 GAP Event: 10 > > 002037 Connection updated > > 002037 Disconnected > > > > On the phone, I get requested for a pin number and I enter 4539. After > > that, the end device just disconnects from the bluetooth.