Skip to content

Commit

Permalink
Merge branch 'main' into detect-chg
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFil authored Jan 9, 2024
2 parents 6b1d8fe + db9ab30 commit 22efc42
Show file tree
Hide file tree
Showing 72 changed files with 1,123 additions and 244 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ble-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
cd app/tests/ble
export TESTS=$(ls -d * | grep -v central | jq -R -s -c 'split("\n")[:-1]')
echo "::set-output name=test-dirs::${TESTS}"
echo "test-dirs=${TESTS}" > $GITHUB_OUTPUT
run-tests:
needs: collect-tests
strategy:
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Cache west modules
uses: actions/cache@v3.0.2
uses: actions/cache@v3
env:
cache-name: cache-zephyr-modules
with:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
run: BSIM_COMPONENTS_PATH="${GITHUB_WORKSPACE}/tools/bsim/components/" BSIM_OUT_PATH="${GITHUB_WORKSPACE}/tools/bsim/" ./run-ble-test.sh tests/ble/${{ matrix.test }}
- name: Archive artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: "log-files"
name: "${{ matrix.test }}-log-files"
path: app/build/**/*.log
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
cd app/tests/
export TESTS=$(ls -d * | grep -v ble | jq -R -s -c 'split("\n")[:-1]')
echo "::set-output name=test-dirs::${TESTS}"
echo "test-dirs=${TESTS}" >> $GITHUB_OUTPUT
run-tests:
needs: collect-tests
strategy:
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Cache west modules
uses: actions/cache@v3.0.2
uses: actions/cache@v3
env:
cache-name: cache-zephyr-modules
with:
Expand All @@ -65,7 +65,7 @@ jobs:
run: west test tests/${{ matrix.test }}
- name: Archive artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: "log-files"
name: "${{ matrix.test }}-log-files"
path: app/build/**/*.log
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
/zmk-config
/build
*.DS_Store
__pycache__
__pycache__
.python-version
.venv
2 changes: 1 addition & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ target_sources_ifdef(CONFIG_USB_DEVICE_STACK app PRIVATE src/usb.c)
target_sources_ifdef(CONFIG_ZMK_USB app PRIVATE src/usb_hid.c)
target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c)
target_sources_ifdef(CONFIG_ZMK_BACKLIGHT app PRIVATE src/backlight.c)
target_sources(app PRIVATE src/workqueue.c)
target_sources_ifdef(CONFIG_ZMK_LOW_PRIORITY_WORK_QUEUE app PRIVATE src/workqueue.c)
target_sources(app PRIVATE src/main.c)

add_subdirectory(src/display/)
Expand Down
45 changes: 34 additions & 11 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -142,29 +142,43 @@ menuconfig ZMK_BLE

if ZMK_BLE

config ZMK_BLE_EXPERIMENTAL_FEATURES
bool "Experimental: Enable experimental/advanced BLE settings/features"
imply ZMK_BLE_PASSKEY_ENTRY
imply BT_GATT_AUTO_SEC_REQ
config ZMK_BLE_EXPERIMENTAL_CONN
bool "Experimental BLE connection changes"
help
Enables a combination of settings that are planned to be default in future versions of ZMK
to improve connection stability. This includes changes to timing on BLE pairing initation,
restores use of the updated/new LLCP implementation, and disables 2M PHY support.

config ZMK_BLE_EXPERIMENTAL_SEC
bool "Experimental BLE security changes"
imply BT_SMP_ALLOW_UNAUTH_OVERWRITE
help
Enables a combination of settings that are planned to be default in future versions of ZMK.
This includes changes to timing on BLE pairing initation, BT Secure Connection passkey entry,
restores use of the updated/new LLCP implementation, disables 2M PHY support, and allows
overwrite of keys from previously paired hosts.
Enables a combination of settings that are planned to be officially supported in the future.
This includes enabling BT Secure Connection passkey entry, and allows overwrite of keys from
previously paired hosts.

config ZMK_BLE_EXPERIMENTAL_FEATURES
bool "Experimental BLE connection and security settings/features"
select ZMK_BLE_EXPERIMENTAL_CONN
select ZMK_BLE_EXPERIMENTAL_SEC
help
Enables experimental connection changes and security features.

config ZMK_BLE_PASSKEY_ENTRY
bool "Require passkey entry on the keyboard to complete pairing"
default n
select RING_BUFFER

config BT_SMP_ALLOW_UNAUTH_OVERWRITE
imply ZMK_BLE_PASSKEY_ENTRY

choice BT_LL_SW_LLCP_IMPL
default BT_LL_SW_LLCP_LEGACY if !ZMK_BLE_EXPERIMENTAL_FEATURES
default BT_LL_SW_LLCP_LEGACY if !ZMK_BLE_EXPERIMENTAL_CONN

endchoice

config BT_CTLR_PHY_2M
default n if ZMK_BLE_EXPERIMENTAL_FEATURES
default n if ZMK_BLE_EXPERIMENTAL_CONN

# BT_TINYCRYPT_ECC is required for BT_SMP_SC_PAIR_ONLY when using HCI
config BT_TINYCRYPT_ECC
Expand Down Expand Up @@ -203,7 +217,7 @@ config BT_GATT_NOTIFY_MULTIPLE
default n

config BT_GATT_AUTO_SEC_REQ
default n
default (ZMK_SPLIT_BLE && !ZMK_SPLIT_ROLE_CENTRAL)

config BT_DEVICE_APPEARANCE
default 961
Expand Down Expand Up @@ -241,6 +255,7 @@ rsource "src/display/Kconfig"
menuconfig ZMK_RGB_UNDERGLOW
bool "RGB Adressable LED Underglow"
select LED_STRIP
select ZMK_LOW_PRIORITY_WORK_QUEUE

if ZMK_RGB_UNDERGLOW

Expand Down Expand Up @@ -363,6 +378,7 @@ config ZMK_BATTERY_REPORTING
bool "Battery level detection/reporting"
default n
select SENSOR
select ZMK_LOW_PRIORITY_WORK_QUEUE
imply BT_BAS if ZMK_BLE

config ZMK_IDLE_TIMEOUT
Expand Down Expand Up @@ -557,6 +573,11 @@ config ZMK_BATTERY_REPORT_INTERVAL
int "Battery level report interval in seconds"
default 60

config ZMK_LOW_PRIORITY_WORK_QUEUE
bool "Work queue for low priority items"

if ZMK_LOW_PRIORITY_WORK_QUEUE

config ZMK_LOW_PRIORITY_THREAD_STACK_SIZE
int "Low priority thread stack size"
default 768
Expand All @@ -565,6 +586,8 @@ config ZMK_LOW_PRIORITY_THREAD_PRIORITY
int "Low priority thread priority"
default 10

endif

#Advanced
endmenu

Expand Down
4 changes: 3 additions & 1 deletion app/boards/arm/adv360pro/adv360pro.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@

>;
};
ext-power {

// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
control-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
};
Expand Down
2 changes: 1 addition & 1 deletion app/boards/arm/corneish_zen/widgets/battery_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void battery_status_update_cb(struct battery_status_state state) {

static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) {
return (struct battery_status_state) {
.level = bt_bas_get_battery_level(),
.level = zmk_battery_state_of_charge(),
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
.usb_present = zmk_usb_is_powered(),
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */
Expand Down
21 changes: 20 additions & 1 deletion app/boards/seeeduino_xiao_ble.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,24 @@
};

&qspi {
status = "disabled";
status = "okay";
pinctrl-0 = <&qspi_default>;
pinctrl-1 = <&qspi_sleep>;
pinctrl-names = "default", "sleep";
p25q16h: p25q16h@0 {
compatible = "nordic,qspi-nor";
reg = <0>;
sck-frequency = <104000000>;
quad-enable-requirements = "S2B1v1";
jedec-id = [85 60 15];
sfdp-bfp = [
e5 20 f1 ff ff ff ff 00 44 eb 08 6b 08 3b 80 bb
ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52
10 d8 08 81
];
size = <16777216>;
has-dpd;
t-enter-dpd = <3000>;
t-exit-dpd = <8000>;
};
};
14 changes: 0 additions & 14 deletions app/boards/shields/Kconfig.defconfig

This file was deleted.

5 changes: 0 additions & 5 deletions app/boards/shields/Kconfig.shield

This file was deleted.

2 changes: 1 addition & 1 deletion app/boards/shields/nice_view/widgets/peripheral_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static void battery_status_update_cb(struct battery_status_state state) {

static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) {
return (struct battery_status_state) {
.level = bt_bas_get_battery_level(),
.level = zmk_battery_state_of_charge(),
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
.usb_present = zmk_usb_is_powered(),
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */
Expand Down
2 changes: 1 addition & 1 deletion app/boards/shields/nice_view/widgets/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static void battery_status_update_cb(struct battery_status_state state) {

static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) {
return (struct battery_status_state) {
.level = bt_bas_get_battery_level(),
.level = zmk_battery_state_of_charge(),
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
.usb_present = zmk_usb_is_powered(),
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */
Expand Down
3 changes: 2 additions & 1 deletion app/include/dt-bindings/zmk/bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define BT_NXT_CMD 1
#define BT_PRV_CMD 2
#define BT_SEL_CMD 3
// #define BT_FULL_RESET_CMD 4
#define BT_CLR_ALL_CMD 4
#define BT_DISC_CMD 5

/*
Expand All @@ -20,4 +20,5 @@ defines these aliases up front.
#define BT_NXT BT_NXT_CMD 0
#define BT_PRV BT_PRV_CMD 0
#define BT_SEL BT_SEL_CMD
#define BT_CLR_ALL BT_CLR_ALL_CMD 0
#define BT_DISC BT_DISC_CMD
2 changes: 1 addition & 1 deletion app/include/zmk/activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

enum zmk_activity_state { ZMK_ACTIVITY_ACTIVE, ZMK_ACTIVITY_IDLE, ZMK_ACTIVITY_SLEEP };

enum zmk_activity_state zmk_activity_get_state();
enum zmk_activity_state zmk_activity_get_state(void);
12 changes: 6 additions & 6 deletions app/include/zmk/backlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

#pragma once

int zmk_backlight_on();
int zmk_backlight_off();
int zmk_backlight_toggle();
bool zmk_backlight_is_on();
int zmk_backlight_on(void);
int zmk_backlight_off(void);
int zmk_backlight_toggle(void);
bool zmk_backlight_is_on(void);

int zmk_backlight_set_brt(uint8_t brightness);
uint8_t zmk_backlight_get_brt();
uint8_t zmk_backlight_get_brt(void);
uint8_t zmk_backlight_calc_brt(int direction);
uint8_t zmk_backlight_calc_brt_cycle();
uint8_t zmk_backlight_calc_brt_cycle(void);
4 changes: 2 additions & 2 deletions app/include/zmk/battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

#pragma once

uint8_t zmk_battery_state_of_charge();
bool zmk_battery_charging();
uint8_t zmk_battery_state_of_charge(void);
bool zmk_battery_charging(void);
19 changes: 10 additions & 9 deletions app/include/zmk/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@
#define ZMK_BLE_PROFILE_COUNT CONFIG_BT_MAX_PAIRED
#endif

int zmk_ble_clear_bonds();
int zmk_ble_prof_next();
int zmk_ble_prof_prev();
void zmk_ble_clear_bonds(void);
int zmk_ble_prof_next(void);
int zmk_ble_prof_prev(void);
int zmk_ble_prof_select(uint8_t index);
void zmk_ble_clear_all_bonds(void);
int zmk_ble_prof_disconnect(uint8_t index);

int zmk_ble_active_profile_index();
int zmk_ble_active_profile_index(void);
int zmk_ble_profile_index(const bt_addr_le_t *addr);
bt_addr_le_t *zmk_ble_active_profile_addr();
bool zmk_ble_active_profile_is_open();
bool zmk_ble_active_profile_is_connected();
char *zmk_ble_active_profile_name();
bt_addr_le_t *zmk_ble_active_profile_addr(void);
bool zmk_ble_active_profile_is_open(void);
bool zmk_ble_active_profile_is_connected(void);
char *zmk_ble_active_profile_name(void);

int zmk_ble_unpair_all();
int zmk_ble_unpair_all(void);

#if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
int zmk_ble_put_peripheral_addr(const bt_addr_le_t *addr);
Expand Down
6 changes: 3 additions & 3 deletions app/include/zmk/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

#pragma once

struct k_work_q *zmk_display_work_q();
struct k_work_q *zmk_display_work_q(void);

bool zmk_display_is_initialized();
int zmk_display_init();
bool zmk_display_is_initialized(void);
int zmk_display_init(void);

/**
* @brief Macro to define a ZMK event listener that handles the thread safety of fetching
Expand Down
10 changes: 9 additions & 1 deletion app/include/zmk/events/battery_state_changed.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ struct zmk_battery_state_changed {
uint8_t state_of_charge;
};

ZMK_EVENT_DECLARE(zmk_battery_state_changed);
ZMK_EVENT_DECLARE(zmk_battery_state_changed);

struct zmk_peripheral_battery_state_changed {
uint8_t source;
// TODO: Other battery channels
uint8_t state_of_charge;
};

ZMK_EVENT_DECLARE(zmk_peripheral_battery_state_changed);
Loading

0 comments on commit 22efc42

Please sign in to comment.