nRF Desktop - Dongle HID Forward unable to connect "Service not found"

Hello,

I've been trying to get the nRF Desktop Dongle/HID Forwarder to work, ie. I program a nrf52840DK as a HID forwarder, it connects to my bluetooth keyboard, and then the nrf52840 relays the keystrokes from my bluetooth keyboard.

This should somewhat work out of the box, with MINIMAL configuration changes, but I just can't get it to work, it tries to connect, but then just disconnects right after with a `Service not found` log (keep in mind, service discovery seems to work in the Android nRF Connect app, but it uses a database hash?? something?).

[82133036] <inf> app_event_manager: e:ble_peer_search_event inactive
[82133038] <inf> app_event_manager: e:led_event led_id:1 effect:0x5641c
[82133040] <inf> app_event_manager: e:power_manager_restrict_event module "ble_state_pm" restricts to MAX
[82133043] <inf> app_event_manager: e:led_event led_id:1 effect:0x5640c
[82133047] <inf> app_event_manager: e:led_ready_event led_id:1 effect:0x5640c
[82133571] <err> ble_scan: MYDEBUG Peer Name (err Mouse nRF52 Desktop)
[82133572] <err> ble_scan: MYDEBUG Peer Name (err Glove80)
[82133573] <inf> ble_scan: Device name filters added
[82133590] <inf> ble_scan: Scan started
[82133592] <inf> app_event_manager: e:ble_peer_search_event active
[82133594] <inf> app_event_manager: e:led_event led_id:1 effect:0x5641c
[82138495] <inf> ble_scan: Filters matched. C3:04:C8:95:B6:06 (random) connectable
[82138550] <inf> ble_scan: Connecting done
[82145348] <inf> ble_state: Connected to C3:04:C8:95:B6:06 (random)
[82145369] <inf> app_event_manager: e:ble_peer_event id=0x200049d0 CONNECTED reason=0
[82145373] <inf> app_event_manager: e:ble_peer_conn_params_event peer=0x200049d0 min=8 max=8 lat=0 timeout=400 (updated)
[82145373] <inf> ble_conn_params: Conn params for peer: 0x200049d0 updated.
[82145378] <inf> app_event_manager: e:led_event led_id:1 effect:0x5641c
[82145381] <inf> app_event_manager: e:power_manager_restrict_event module "ble_state_pm" restricts to SUSPENDED
[82146179] <err> ble_discovery: Service not found
[82146842] <inf> ble_state: Disconnected from C3:04:C8:95:B6:06 (random) (reason 22)
[82146845] <inf> app_event_manager: e:ble_peer_event id=0x200049d0 DISCONNECTED reason=22
[82146846] <inf> ble_scan: Scan stopped

I've setup the nrf ble sniffer, which seems to indicate that the ble_discovery fails, for some reason with a `Attribute not found`.

I've made two recordings, one where it works, and one where it does not work.

Hopefully someone can help me out.

Changes I've made in the nrf repo, on revision 6266884de899a254b7f09868d6ad4947d0dfc879.

diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/ble_discovery_def.h b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/ble_discovery_def.h
index 62d3c5e3dd..734e1b5030 100644
--- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/ble_discovery_def.h
+++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/ble_discovery_def.h
@@ -20,7 +20,7 @@ struct bt_peripheral {
 	enum peer_type peer_type;
 };
 
-static const uint16_t vendor_vid = 0x1915;
+static const uint16_t vendor_vid = 0x16c0;
 
 /* Peripherals parameters. */
 static const struct bt_peripheral bt_peripherals[] = {
@@ -37,7 +37,7 @@ static const struct bt_peripheral bt_peripherals[] = {
 		.peer_type = PEER_TYPE_MOUSE,
 	},
 	{
-		.pid = 0x52dd,
+		.pid = 0x27db,
 		.peer_type = PEER_TYPE_KEYBOARD,
 	},
 };
diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/ble_scan_def.h b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/ble_scan_def.h
index fd129a6918..f79aeda22c 100644
--- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/ble_scan_def.h
+++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/ble_scan_def.h
@@ -18,4 +18,5 @@ const struct {} ble_scan_include_once;
 static const char *peer_name[] = {
 	[PEER_TYPE_MOUSE] = "Mouse nRF52 Desktop",
 	[PEER_TYPE_KEYBOARD] = "Keyboard nRF52 Desktop",
+	[PEER_TYPE_KEYBOARD] = "Glove80",
 };
diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/prj_dongle.conf b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/prj_dongle.conf
index 9692673554..7724b1420a 100644
--- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/prj_dongle.conf
+++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/prj_dongle.conf
@@ -64,9 +64,9 @@ CONFIG_RESET_ON_FATAL_ERROR=n
 
 CONFIG_GPIO=y
 
-CONFIG_SERIAL=n
-CONFIG_CONSOLE=n
-CONFIG_UART_CONSOLE=n
+CONFIG_SERIAL=y
+CONFIG_CONSOLE=y
+CONFIG_UART_CONSOLE=y
 
 CONFIG_REBOOT=y
 
@@ -97,3 +97,4 @@ CONFIG_ASSERT=y
 CONFIG_ASSERT_LEVEL=2
 
 CONFIG_DESKTOP_LOG=y
+CONFIG_LOG_DEFAULT_LEVEL=3
diff --git a/applications/nrf_desktop/src/modules/ble_scan.c b/applications/nrf_desktop/src/modules/ble_scan.c
index 0e7d471016..b15b9bf7bb 100644
--- a/applications/nrf_desktop/src/modules/ble_scan.c
+++ b/applications/nrf_desktop/src/modules/ble_scan.c
@@ -316,6 +316,7 @@ static int configure_name_filters(uint8_t *filter_mode)
 		}
 
 		err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME, peer_name[i]);
+		LOG_ERR("MYDEBUG Peer Name (err %s)", peer_name[i]);
 		if (err) {
 			LOG_ERR("Name filter cannot be added (err %d)", err);
 			break;

.3225.capture_failure.pcapng

phone-working.pcapng

  • Hello,

    Searching for "Service not found" in ble_discovery.c I can find that it by default will disconnect in service_not_found(). What happens if you simply comment out peer_disconnect(conn)?

    Kenneth

  • That did not work, as it needs the HWID from the first step of the discovery phase, in the hid_forwarder. However, I've skipped that phase, and just hardcoded a HWID, that is now used.

    I can connect, and I can see that they are connected, however, each time I press a key on my keyboard, my mouse just moves X distance to the right, and I get no keypresses.

    I'm investigating further, but I'm not really sure why it would act like that. Any insight is highly appreciated.

    [03151955] <inf> ble_state: Connected to C3:04:C8:95:B6:06 (random)
    [03151977] <inf> app_event_manager: e:ble_peer_event id=0x200139c0 CONNECTED reason=0
    [03151981] <inf> app_event_manager: e:ble_peer_conn_params_event peer=0x200139c0 min=8 max=8 lat=0 timeout=400 (updated)
    [03151981] <inf> ble_conn_params: Conn params for peer: 0x200139c0 updated.
    [03151983] <inf> ble_discovery: MYDEBUG: starting discovery of DIS
    [03151983] <err> ble_discovery: MYDEBUG: starting discovery: discovery_hids: 0
    [03151983] <err> ble_discovery: doing hids discovery
    [03151987] <inf> app_event_manager: e:led_event led_id:1 effect:0x56550
    [03151990] <inf> app_event_manager: e:power_manager_restrict_event module "ble_state_pm" restricts to SUSPENDED
    [03158835] <inf> ble_discovery: VID: 16c0 PID: 27db
    [03158839] <inf> ble_discovery: MYDEBUG: starting discovery of HIDS (BEFORE VERIFY)
    [03158839] <err> ble_discovery: MYDEBUG: verified peer, starting HIDS discovery
    [03158840] <err> ble_discovery: MYDEBUG: starting discovery: discovery_hids: 1
    [03158840] <err> ble_discovery: doing hids discovery
    [03166043] <inf> ble_discovery: HIDS discovery procedure succeeded
    [03166048] <inf> app_event_manager: e: ble_discovery_complete_event
    [03166048] <inf> hid_forward: New subscriber id attached (0)
    [03166385] <inf> hid_forward: Peripheral 0x200032d0 registered and linked to 0x200154dc
    [03166447] <inf> ble_scan: Scan stopped
    [03166455] <inf> app_event_manager: e:ble_peer_search_event inactive
    [03166458] <inf> app_event_manager: e:led_event led_id:1 effect:0x56548
    [03166462] <inf> app_event_manager: e:led_ready_event led_id:1 effect:0x56548
    [03166979] <err> ble_scan: MYDEBUG Peer Name (err Mouse nRF52 Desktop)
    [03166980] <inf> ble_scan: Device name filters added
    [03166999] <inf> ble_scan: Scan started
    [03167001] <inf> app_event_manager: e:ble_peer_search_event active
    [03167003] <inf> app_event_manager: e:led_event led_id:1 effect:0x56550
    [03182501] <inf> ble_state: Security with C3:04:C8:95:B6:06 (random) level 2
    [03182508] <inf> app_event_manager: e:ble_peer_event id=0x200139c0 SECURED reason=0
    [03182514] <inf> app_event_manager: e:led_event led_id:1 effect:0x56550
    [03184395] <inf> ble_state: MTU exchange done
    [03186363] <inf> hid_forward: Subscriber to rep id:1
    [03186365] <inf> hid_forward: Subscriber to rep id:2
    [03186366] <inf> hid_forward: Subscriber to rep id:3
    [03295076] <inf> ble_scan: Scan stopped
    [03295079] <err> ble_scan: MYDEBUG Peer Name (err Mouse nRF52 Desktop)
    [03295079] <inf> ble_scan: Device name filters added
    [03295095] <inf> ble_scan: Scan started
    [03295098] <inf> app_event_manager: e:ble_peer_search_event inactive
    [03295099] <inf> app_event_manager: e:ble_peer_search_event active
    [03295101] <inf> app_event_manager: e:led_event led_id:1 effect:0x56548
    [03295103] <inf> app_event_manager: e:led_event led_id:1 effect:0x56550
    [03316130] <inf> app_event_manager: e:ble_peer_conn_params_event peer=0x200139c0 min=6 max=c lat=30 timeout=400 (required)
    [03316130] <inf> ble_conn_params: Request to update conn: 0x200139c0 latency to: 30
    [03316143] <inf> ble_conn_params: Update conn params for peer: 0x200139c0 (BLE, requested latency: 30, USB suspended: false)
    [03318414] <inf> app_event_manager: e:ble_peer_conn_params_event peer=0x200139c0 min=8 max=8 lat=30 timeout=400 (updated)
    [03318415] <inf> ble_conn_params: Conn params for peer: 0x200139c0 updated.
    [04255114] <inf> ble_scan: Scan stopped
    [04255117] <inf> app_event_manager: e:ble_peer_search_event inactive
    [04255119] <inf> app_event_manager: e:led_event led_id:1 effect:0x56548
    [04255123] <inf> app_event_manager: e:led_ready_event led_id:1 effect:0x56548
    [08739372] <inf> app_event_manager: e:ble_qos_event chmap: 0xff 0xff 0x00 0xfc 0x1f

  • Okay, so for some reason, it seems like the report_id is set to `REPORT_ID_MOUSE`, when it should have been `REPORT_ID_KEYBOARD_KEYS`. If I override it manually, then I can get it to "work", but that does not seem like the best solution.

    	uint8_t report_id = bt_hogp_rep_id(rep);
    	size_t size = bt_hogp_rep_size(rep);
    
    	/* HID boot protocol reports are received with report ID equal 0 (REPORT_ID_RESERVED).
    	 * The report ID must be updated before HID report is forwarded as an Event Manager event.
    	 */
    	if (report_id == REPORT_ID_RESERVED) {
    		if (bt_hogp_rep_boot_kbd_in(hids_c)) {
    			report_id = REPORT_ID_BOOT_KEYBOARD;
    		} else if (bt_hogp_rep_boot_mouse_in(hids_c)) {
    			report_id = REPORT_ID_BOOT_MOUSE;
    		}
    	}
    
        report_id = REPORT_ID_KEYBOARD_KEYS;
    
    	forward_hid_report(per, report_id, data, size);
    

    original source - https://github.com/nrfconnect/sdk-nrf/blob/main/applications/nrf_desktop/src/modules/hid_forward.c#L217-L231

    I also have this HIDS report.

    [00652228] <inf> ble_discovery: HIDS discovery procedure succeeded
    ATT[1]: 	UUID: 0x2803	Handle: 0x001D	Value:
    	Characteristic: 0x2a4a	Properties: 0x0002
    ATT[2]: 	UUID: 0x2a4a	Handle: 0x001E	Value:
    ATT[3]: 	UUID: 0x2803	Handle: 0x001F	Value:
    	Characteristic: 0x2a4b	Properties: 0x0002
    ATT[4]: 	UUID: 0x2a4b	Handle: 0x0020	Value:
    ATT[5]: 	UUID: 0x2803	Handle: 0x0021	Value:
    	Characteristic: 0x2a4d	Properties: 0x0012
    ATT[6]: 	UUID: 0x2a4d	Handle: 0x0022	Value:
    ATT[7]: 	UUID: 0x2902	Handle: 0x0023	Value:
    	CCCD
    ATT[8]: 	UUID: 0x2908	Handle: 0x0024	Value:
    ATT[9]: 	UUID: 0x2803	Handle: 0x0025	Value:
    	Characteristic: 0x2a4d	Properties: 0x0012
    ATT[10]: 	UUID: 0x2a4d	Handle: 0x0026	Value:
    ATT[11]: 	UUID: 0x2902	Handle: 0x0027	Value:
    	CCCD
    ATT[12]: 	UUID: 0x2908	Handle: 0x0028	Value:
    ATT[13]: 	UUID: 0x2803	Handle: 0x0029	Value:
    	Characteristic: 0x2a4d	Properties: 0x0012
    ATT[14]: 	UUID: 0x2a4d	Handle: 0x002A	Value:
    ATT[15]: 	UUID: 0x2902	Handle: 0x002B	Value:
    	CCCD
    ATT[16]: 	UUID: 0x2908	Handle: 0x002C	Value:
    ATT[17]: 	UUID: 0x2803	Handle: 0x002D	Value:
    	Characteristic: 0x2a4d	Properties: 0x000E
    ATT[18]: 	UUID: 0x2a4d	Handle: 0x002E	Value:
    ATT[19]: 	UUID: 0x2908	Handle: 0x002F	Value:
    ATT[20]: 	UUID: 0x2803	Handle: 0x0030	Value:
    	Characteristic: 0x2a4c	Properties: 0x0004
    ATT[21]: 	UUID: 0x2a4c	Handle: 0x0031	Value:
    [00652297] <inf> app_event_manager: e: ble_discovery_complete_event

  • I think I solved it all now. I took the HID desc from ZMK, and threw in instead of the one the nrf_desktop came with. So now keyboard + mouse works + media keys.  :)

Related