Skip to content

Commit

Permalink
fix(split): Update events and init function
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFil committed Mar 21, 2024
1 parent 344f5b6 commit 0f09feb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/src/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 5 additions & 9 deletions app/src/split/bluetooth/central.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/src/split/bluetooth/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0f09feb

Please sign in to comment.