Skip to content

Commit 6e69496

Browse files
MarekPietakapi-no
authored andcommitted
applications: nrf_desktop: Allow disabling config channel on dongles
Change improves HID forward module to allow using the module when configuration channel support is disabled in the configuration. Jira: NCSDK-35938 Signed-off-by: Marek Pieta <[email protected]> Signed-off-by: Pekka Niskanen <[email protected]>
1 parent ae5d3bb commit 6e69496

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

applications/nrf_desktop/src/modules/hid_forward.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,11 @@ static int register_peripheral(struct bt_gatt_dm *dm, const uint8_t *hwid,
334334
__ASSERT_NO_MSG(hwid_len == HWID_LEN);
335335
memcpy(per->hwid, hwid, hwid_len);
336336

337-
peripheral_cache[per_id]++;
338-
/* An odd number is assigned to a connected peripheral. */
339-
__ASSERT_NO_MSG(peripheral_cache[per_id] & 0x01);
337+
if (IS_ENABLED(CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE)) {
338+
peripheral_cache[per_id]++;
339+
/* An odd number is assigned to a connected peripheral. */
340+
__ASSERT_NO_MSG(peripheral_cache[per_id] & 0x01);
341+
}
340342

341343
LOG_INF("Peripheral %p registered and linked to %p", (void *)per,
342344
(void *)get_subscriber(per));
@@ -774,20 +776,23 @@ static void disconnect_peripheral(struct hids_peripheral *per)
774776

775777
bt_hogp_release(&per->hogp);
776778

777-
/* Cancel cannot fail if executed from another work's context. */
778-
(void)k_work_cancel_delayable(&per->read_rsp);
779779
memset(per->hwid, 0, sizeof(per->hwid));
780-
per->cur_poll_cnt = 0;
781-
per->cfg_chan_id = CFG_CHAN_UNUSED_PEER_ID;
782-
if (per->cfg_chan_rsp) {
783-
submit_forward_error_rsp(per, CONFIG_STATUS_WRITE_FAIL);
784-
}
785780

786-
size_t per_id = per - &peripherals[0];
781+
if (IS_ENABLED(CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE)) {
782+
/* Cancel cannot fail if executed from another work's context. */
783+
(void)k_work_cancel_delayable(&per->read_rsp);
784+
per->cur_poll_cnt = 0;
785+
per->cfg_chan_id = CFG_CHAN_UNUSED_PEER_ID;
786+
if (per->cfg_chan_rsp) {
787+
submit_forward_error_rsp(per, CONFIG_STATUS_WRITE_FAIL);
788+
}
789+
790+
size_t per_id = per - &peripherals[0];
787791

788-
peripheral_cache[per_id]++;
789-
/* An even number is assigned to a disconnected peripheral. */
790-
__ASSERT_NO_MSG(!(peripheral_cache[per_id] & 0x01));
792+
peripheral_cache[per_id]++;
793+
/* An even number is assigned to a disconnected peripheral. */
794+
__ASSERT_NO_MSG(!(peripheral_cache[per_id] & 0x01));
795+
}
791796
}
792797

793798
static void hogp_ready(struct bt_hogp *hids_c)
@@ -882,10 +887,13 @@ static void init(void)
882887
struct hids_peripheral *per = &peripherals[i];
883888

884889
bt_hogp_init(&per->hogp, &params);
885-
k_work_init_delayable(&per->read_rsp, read_rsp_fn);
886-
per->cfg_chan_id = CFG_CHAN_UNUSED_PEER_ID;
887890

888891
per->enqueued_out_reports_bm = 0;
892+
893+
if (IS_ENABLED(CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE)) {
894+
k_work_init_delayable(&per->read_rsp, read_rsp_fn);
895+
per->cfg_chan_id = CFG_CHAN_UNUSED_PEER_ID;
896+
}
889897
}
890898

891899
reset_peripheral_address();
@@ -1242,10 +1250,9 @@ static bool app_event_handler(const struct app_event_header *aeh)
12421250
return false;
12431251
}
12441252

1245-
if (IS_ENABLED(CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE)) {
1246-
if (is_config_event(aeh)) {
1247-
return handle_config_event(cast_config_event(aeh));
1248-
}
1253+
if (IS_ENABLED(CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE)
1254+
&& is_config_event(aeh)) {
1255+
return handle_config_event(cast_config_event(aeh));
12491256
}
12501257

12511258
/* If event is unhandled, unsubscribe. */

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ nRF Desktop
404404
The previously used Kconfig option value of ``11`` leads to using the same priority for the mentioned preemptive contexts as the lowest available application thread priority (used for example, by the log processing thread).
405405
* Application image configurations to explicitly specify the LED driver used by the :ref:`nrf_desktop_leds` (:kconfig:option:`CONFIG_CAF_LEDS_GPIO` or :kconfig:option:`CONFIG_CAF_LEDS_PWM`).
406406
Also, disabled unused LED drivers enabled by default to reduce memory footprint.
407+
* The :ref:`nrf_desktop_hid_forward` to allow using the module when configuration channel support (:ref:`CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE <config_desktop_app_options>`) is disabled in the application configuration.
407408

408409
nRF Machine Learning (Edge Impulse)
409410
-----------------------------------

0 commit comments

Comments
 (0)