From c92eec454ca188229d476483fe99126091527d3e Mon Sep 17 00:00:00 2001 From: Xudong Zheng <7pkvm5aw@slicealias.com> Date: Thu, 9 Nov 2023 10:42:56 -0500 Subject: [PATCH] refactor: address transport switch enumeration warning When building without USB or Bluetooth, the compiler emits a warning due to ZMK_TRANSPORT_USB or ZMK_TRANSPORT_BLE not being handled. --- app/src/endpoints.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/endpoints.c b/app/src/endpoints.c index 138e790fe727..c97a1fa50e75 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -124,26 +124,32 @@ static int send_keyboard_report(void) { struct zmk_hid_keyboard_report *keyboard_report = zmk_hid_get_keyboard_report(); switch (current_instance.transport) { -#if IS_ENABLED(CONFIG_ZMK_USB) case ZMK_TRANSPORT_USB: { +#if IS_ENABLED(CONFIG_ZMK_USB) int err = zmk_usb_hid_send_report((uint8_t *)keyboard_report, sizeof(*keyboard_report)); if (err) { LOG_ERR("FAILED TO SEND OVER USB: %d", err); } return err; - } +#else + LOG_ERR("USB endpoint is not support"); + return -ENOTSUP; #endif /* IS_ENABLED(CONFIG_ZMK_USB) */ + } -#if IS_ENABLED(CONFIG_ZMK_BLE) case ZMK_TRANSPORT_BLE: { +#if IS_ENABLED(CONFIG_ZMK_BLE) int err = zmk_hog_send_keyboard_report(&keyboard_report->body); if (err) { LOG_ERR("FAILED TO SEND OVER HOG: %d", err); } return err; - } +#else + LOG_ERR("BLE HOG endpoint is not support"); + return -ENOTSUP; #endif /* IS_ENABLED(CONFIG_ZMK_BLE) */ } + } LOG_ERR("Unsupported endpoint transport %d", current_instance.transport); return -ENOTSUP; @@ -153,26 +159,26 @@ static int send_consumer_report(void) { struct zmk_hid_consumer_report *consumer_report = zmk_hid_get_consumer_report(); switch (current_instance.transport) { -#if IS_ENABLED(CONFIG_ZMK_USB) case ZMK_TRANSPORT_USB: { +#if IS_ENABLED(CONFIG_ZMK_USB) int err = zmk_usb_hid_send_report((uint8_t *)consumer_report, sizeof(*consumer_report)); if (err) { LOG_ERR("FAILED TO SEND OVER USB: %d", err); } return err; - } #endif /* IS_ENABLED(CONFIG_ZMK_USB) */ + } -#if IS_ENABLED(CONFIG_ZMK_BLE) case ZMK_TRANSPORT_BLE: { +#if IS_ENABLED(CONFIG_ZMK_BLE) int err = zmk_hog_send_consumer_report(&consumer_report->body); if (err) { LOG_ERR("FAILED TO SEND OVER HOG: %d", err); } return err; - } #endif /* IS_ENABLED(CONFIG_ZMK_BLE) */ } + } LOG_ERR("Unsupported endpoint transport %d", current_instance.transport); return -ENOTSUP;