From 0f09feb3f24509058f7d5554c6484261008e32bc Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:44:56 +0000 Subject: [PATCH] fix(split): Update events and init function --- app/src/keymap.c | 2 +- app/src/split/bluetooth/central.c | 14 +++++--------- app/src/split/bluetooth/service.c | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/src/keymap.c b/app/src/keymap.c index c0657e41bc23..a5880f9856e9 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -97,7 +97,7 @@ static inline int set_layer_state(uint8_t layer, bool state) { // Don't send state changes unless there was an actual change if (old_state != _zmk_keymap_layer_state) { LOG_DBG("layer_changed: layer %d state %d", layer, state); - ZMK_EVENT_RAISE(create_layer_state_changed(layer, state)); + raise_layer_state_changed(layer, state); #if ZMK_BLE_IS_CENTRAL int err = zmk_split_central_send_data(DATA_TAG_KEYMAP_STATE, sizeof(uint32_t), (uint8_t *)&_zmk_keymap_layer_state); diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 1046f7aab21a..65cc9be93be4 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -455,10 +455,6 @@ static uint8_t split_central_chrc_discovery_func(struct bt_conn *conn, slot->batt_lvl_read_params.single.offset = 0; bt_gatt_read(conn, &slot->batt_lvl_read_params); #endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING) */ - } - - bool subscribed = slot->run_behavior_handle && slot->subscribe_params.value_handle; - } else if (bt_uuid_cmp(chrc_uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_DATA_XFER_UUID)) == 0) { LOG_DBG("Found data transfer handle"); slot->discover_params.uuid = NULL; @@ -724,8 +720,8 @@ static void split_central_connected(struct bt_conn *conn, uint8_t conn_err) { LOG_DBG("Connected: %s", addr); - ZMK_EVENT_RAISE(new_zmk_split_peripheral_status_changed( - (struct zmk_split_peripheral_status_changed){.connected = true})); + raise_zmk_split_peripheral_status_changed( + (struct zmk_split_peripheral_status_changed){.connected = true}); confirm_peripheral_slot_conn(conn); split_central_process_connection(conn); @@ -745,8 +741,8 @@ static void split_central_disconnected(struct bt_conn *conn, uint8_t reason) { k_msgq_put(&peripheral_batt_lvl_msgq, &ev, K_NO_WAIT); k_work_submit(&peripheral_batt_lvl_work); #endif // IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING) - ZMK_EVENT_RAISE(new_zmk_split_peripheral_status_changed( - (struct zmk_split_peripheral_status_changed){.connected = false})); + raise_zmk_split_peripheral_status_changed( + (struct zmk_split_peripheral_status_changed){.connected = false}); err = release_peripheral_slot_for_conn(conn); @@ -919,7 +915,7 @@ int zmk_split_central_send_data(enum data_tag tag, uint8_t size, uint8_t *data) return split_bt_data_xfer_payload(payload); } -int zmk_split_bt_central_init(const struct device *_arg) { +int zmk_split_bt_central_init(void) { k_work_queue_start(&split_central_split_run_q, split_central_split_run_q_stack, K_THREAD_STACK_SIZEOF(split_central_split_run_q_stack), CONFIG_ZMK_BLE_THREAD_PRIORITY, NULL); diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index 461ee185b943..b162348c6346 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -103,7 +103,7 @@ static void split_svc_data_xfer_callback(struct k_work *work) { LOG_DBG("Size correct, raising event"); struct zmk_split_data_xfer_event event; memcpy(&event.data_xfer, &data_xfer_payload, sizeof(struct zmk_split_data_xfer_data)); - ZMK_EVENT_RAISE(new_zmk_split_data_xfer_event(event)); + raise_zmk_split_data_xfer_event(event); } static K_WORK_DEFINE(split_svc_data_xfer_work, split_svc_data_xfer_callback);