diff --git a/Documentation/card10-cfg.rst b/Documentation/card10-cfg.rst index c96a9a0dd865299776f9640c02d44f76884075c9..d37bedca43a49eec53be6a23e2383127a485c903 100644 --- a/Documentation/card10-cfg.rst +++ b/Documentation/card10-cfg.rst @@ -47,6 +47,8 @@ Option name Type Description ------------------ ---------- ----------- ``ble_mac`` Boolean MAC address used for BLE. Format: ``ca:4d:10:xx:xx:xx``. ------------------ ---------- ----------- +``ble_hid_enable`` Boolean Enable the Human Interface Device (HID) characteristics on BLE. +------------------ ---------- ----------- ``ble_log_enable`` Boolean Activate HCI level logging of BLE data. Creates a new btsnoop compatible log file named ``ble.log`` in the ``logs`` folder after each boot if BLE is activated. Keeps the last 10 files. ------------------ ---------- ----------- ``right_scroll`` Boolean Use both right buttons to scroll up and down. Lower left button is SELECT. diff --git a/epicardium/ble/ble_main.c b/epicardium/ble/ble_main.c index b6d662bed65704cc500d00f9df8ab712ad67aa10..bd2f9948201243e63e6a6e48228640c0b58b6154 100644 --- a/epicardium/ble/ble_main.c +++ b/epicardium/ble/ble_main.c @@ -42,11 +42,13 @@ #include "profiles/gap_api.h" #include "cccd.h" #include "ess.h" +#include "hid.h" #include "ble_api.h" #include "epicardium.h" #include "api/interrupt-sender.h" #include "modules/log.h" +#include "modules/config.h" #define SCAN_REPORTS_NUM 16 @@ -973,8 +975,6 @@ static void BleHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) } } -void hid_init(void); - /*************************************************************************************************/ /*! * \brief Start the application. @@ -1003,7 +1003,9 @@ void BleStart(void) SvcBattCbackRegister(BasReadCback, NULL); SvcBattAddGroup(); - hid_init(); + if(config_get_boolean_with_default("ble_hid_enable", false)) { + hid_init(); + } /* Reset the device */ DmDevReset(); } diff --git a/epicardium/ble/hid.h b/epicardium/ble/hid.h index 6edd627a1770589ae3d20bee49057fd399fc7fd9..639ef6d5aeaca9bb4a127219220b23702133875c 100644 --- a/epicardium/ble/hid.h +++ b/epicardium/ble/hid.h @@ -12,3 +12,5 @@ #define HIDAPP_KEYBOARD_REPORT_ID 1 #define HIDAPP_MOUSE_REPORT_ID 2 #define HIDAPP_CONSUMER_REPORT_ID 3 + +void hid_init(void); diff --git a/epicardium/ble/hid_work.c b/epicardium/ble/hid_work.c index 406f8bd0a9c37d05c6cb8b1134f1b10f4d5b8b63..268fa3d9abae09dcf29d6bf6dcd820343dee5bdf 100644 --- a/epicardium/ble/hid_work.c +++ b/epicardium/ble/hid_work.c @@ -196,6 +196,10 @@ void hidAppInfoCback(dmConnId_t connId, uint8_t type, uint8_t value) void HidProcMsg(wsfMsgHdr_t *pMsg) { + if (!queue) { + /* Not initialized (yet). */ + return; + } if (pMsg->event == ATTS_HANDLE_VALUE_CNF) { if (pMsg->status == ATT_SUCCESS) { hidAppCb.txFlags |= HIDAPP_TX_FLAGS_READY;