diff --git a/README.md b/README.md index 48a0337..a9bb360 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Lily58 -These are my configuration and notes for my Lily58 bought from https://typeractive.xyz/ (highly recommended!) +This is my configuration and notes for my Lily58 bought from https://typeractive.xyz/ (highly recommended!) ![Lily58 Kailh Choc with a Framework 13](images/typeractive-lily-58-with-framework-13-min.jpg) @@ -34,4 +34,105 @@ cp build/zephyr/zmk.uf2 ../lily58-wireless-zmk-config/build/lily58_right-nice_na Note: sometimes Nautilus won't allow writing apparently after reconnecting or connecting the other side after, I think because it wasn't properly ejected. So just eject and reconnect, and writing will work again. +## Get peripheral battery level + +Ensure these are set in the config: + +```text +CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING=y +CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_PROXY=y +``` + +https://github.com/zmkfirmware/zmk/pull/2045#issue-2017569922 + +> Confirmed that using bluetoothctl I can subscribe to notifications on the other Battery Level service on a split central, and properly receive notifications it has "proxied" from the split peripheral. + +```sh +$ bluetoothctl +``` + +If not already connected to the Lily58, list with `devices` and connect to it with `connect XX:XX:XX:XX:XX:XX`. + +Then find the general attribute for `Battery Level`: + +```text +[Lily58]# menu gatt +[Lily58]# list-attributes +``` + +Find the primary and secondary `Battery Service` with its `Battery Level` characteristic sections. After enabling peripheral battery level, there will be two of them instead of one. + +```text +Primary Service (Handle 0x0000) + /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0010 + 0000180f-0000-1000-8000-00805f9b34fb + Battery Service +Characteristic (Handle 0x0000) + /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0010/char0011 + 00002a19-0000-1000-8000-00805f9b34fb + Battery Level +... +Secondary Service (Handle 0x0000) + /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0015 + 0000180f-0000-1000-8000-00805f9b34fb + Battery Service +Characteristic (Handle 0x0000) + /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0015/char0016 + 00002a19-0000-1000-8000-00805f9b34fb + Battery Level +``` + +Since the UUIDs are identical, we `select-attribute` using the service value instead. + +The `Battery Level` characteristic under `Primary Service` is for the main (left) side, shown in hexadecimal: + +```text +[Lily58]# select-attribute /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0010/char0011 + +[Lily58:/service0010/char0011]# attribute-info +Characteristic - Battery Level + UUID: 00002a19-0000-1000-8000-00805f9b34fb + Service: /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0010 + Value: + 5a Z + Notifying: no + Flags: read + Flags: notify + MTU: 0x0041 (65) + +[Lily58:/service0010/char0011]# read +Attempting to read /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0010/char0011 +[Lily58:/service0010/char0011]# [CHG] Attribute /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0010/char0011 Value: +[Lily58:/service0010/char0011]# 5b [ +[Lily58:/service0010/char0011]# 5b [ +[Lily58:/service0010/char0011]# +``` + +While under `Secondary Service` is for the secondary/peripheral (right) side, shown in hexadecimal: + +```text +[Lily58]# select-attribute /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0015/char0016 + +[Lily58:/service0015/char0016]# attribute-info +Characteristic - Battery Level + UUID: 00002a19-0000-1000-8000-00805f9b34fb + Service: /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0015 + Value: + 54 T + Notifying: no + Flags: read + Flags: notify + MTU: 0x0041 (65) + +[Lily58:/service0015/char0016]# read +Attempting to read /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0015/char0016 +[Lily58:/service0015/char0016]# [CHG] Attribute /org/bluez/hci0/dev_FC_A3_7B_3A_27_4F/service0015/char0016 Value: +[Lily58:/service0015/char0016]# 54 T +[Lily58:/service0015/char0016]# 54 T +``` + +To turn notify on: + +``` +[Lily58:/service..../char....]# notify on ``` diff --git a/build/lily58_left-nice_nano_v2-zmk.uf2 b/build/lily58_left-nice_nano_v2-zmk.uf2 index 63c2aaa..6c9e2c3 100644 Binary files a/build/lily58_left-nice_nano_v2-zmk.uf2 and b/build/lily58_left-nice_nano_v2-zmk.uf2 differ diff --git a/config/lily58.conf b/config/lily58.conf index 85118fb..07386c6 100644 --- a/config/lily58.conf +++ b/config/lily58.conf @@ -10,6 +10,12 @@ CONFIG_ZMK_IDLE_SLEEP_TIMEOUT=600000 # Uncomment the following line to increase the keyboard's wireless range CONFIG_BT_CTLR_TX_PWR_PLUS_8=y +# https://zmk.dev/docs/features/battery +# Enable peripheral battery monitoring +# https://zmk.dev/docs/config/battery#peripheral-battery-monitoring +CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING=y +CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_PROXY=y + # Enable eager debouncing CONFIG_ZMK_KSCAN_DEBOUNCE_PRESS_MS=1 CONFIG_ZMK_KSCAN_DEBOUNCE_RELEASE_MS=7