summaryrefslogtreecommitdiff
path: root/app/src/split
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/split')
-rw-r--r--app/src/split/bluetooth/central.c25
-rw-r--r--app/src/split/bluetooth/service.c16
2 files changed, 21 insertions, 20 deletions
diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c
index 2d4d1ed..f3c860f 100644
--- a/app/src/split/bluetooth/central.c
+++ b/app/src/split/bluetooth/central.c
@@ -33,11 +33,12 @@ static struct bt_uuid_128 uuid = BT_UUID_INIT_128(ZMK_SPLIT_BT_SERVICE_UUID);
static struct bt_gatt_discover_params discover_params;
static struct bt_gatt_subscribe_params subscribe_params;
-static u8_t split_central_notify_func(struct bt_conn *conn, struct bt_gatt_subscribe_params *params,
- const void *data, u16_t length) {
- static u8_t position_state[POSITION_STATE_DATA_LEN];
+static uint8_t split_central_notify_func(struct bt_conn *conn,
+ struct bt_gatt_subscribe_params *params, const void *data,
+ uint16_t length) {
+ static uint8_t position_state[POSITION_STATE_DATA_LEN];
- u8_t changed_positions[POSITION_STATE_DATA_LEN];
+ uint8_t changed_positions[POSITION_STATE_DATA_LEN];
if (!data) {
LOG_DBG("[UNSUBSCRIBED]");
@@ -48,14 +49,14 @@ static u8_t split_central_notify_func(struct bt_conn *conn, struct bt_gatt_subsc
LOG_DBG("[NOTIFICATION] data %p length %u", data, length);
for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) {
- changed_positions[i] = ((u8_t *)data)[i] ^ position_state[i];
- position_state[i] = ((u8_t *)data)[i];
+ changed_positions[i] = ((uint8_t *)data)[i] ^ position_state[i];
+ position_state[i] = ((uint8_t *)data)[i];
}
for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) {
for (int j = 0; j < 8; j++) {
if (changed_positions[i] & BIT(j)) {
- u32_t position = (i * 8) + j;
+ uint32_t position = (i * 8) + j;
bool pressed = position_state[i] & BIT(j);
struct position_state_changed *pos_ev = new_position_state_changed();
pos_ev->position = position;
@@ -91,8 +92,8 @@ static int split_central_subscribe(struct bt_conn *conn) {
return 0;
}
-static u8_t split_central_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr,
- struct bt_gatt_discover_params *params) {
+static uint8_t split_central_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr,
+ struct bt_gatt_discover_params *params) {
int err;
if (!attr) {
@@ -245,7 +246,7 @@ static bool split_central_eir_found(struct bt_data *data, void *user_data) {
return true;
}
-static void split_central_device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t type,
+static void split_central_device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
struct net_buf_simple *ad) {
char dev[BT_ADDR_LE_STR_LEN];
@@ -272,7 +273,7 @@ static int start_scan(void) {
return 0;
}
-static void split_central_connected(struct bt_conn *conn, u8_t conn_err) {
+static void split_central_connected(struct bt_conn *conn, uint8_t conn_err) {
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
@@ -292,7 +293,7 @@ static void split_central_connected(struct bt_conn *conn, u8_t conn_err) {
split_central_process_connection(conn);
}
-static void split_central_disconnected(struct bt_conn *conn, u8_t reason) {
+static void split_central_disconnected(struct bt_conn *conn, uint8_t reason) {
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c
index 86af685..4839084 100644
--- a/app/src/split/bluetooth/service.c
+++ b/app/src/split/bluetooth/service.c
@@ -18,21 +18,21 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/split/bluetooth/uuid.h>
#include <zmk/split/bluetooth/service.h>
-static u8_t num_of_positions = ZMK_KEYMAP_LEN;
-static u8_t position_state[16];
+static uint8_t num_of_positions = ZMK_KEYMAP_LEN;
+static uint8_t position_state[16];
static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
- void *buf, u16_t len, u16_t offset) {
+ void *buf, uint16_t len, uint16_t offset) {
return bt_gatt_attr_read(conn, attrs, buf, len, offset, &position_state,
sizeof(position_state));
}
static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
- void *buf, u16_t len, u16_t offset) {
- return bt_gatt_attr_read(conn, attrs, buf, len, offset, attrs->user_data, sizeof(u8_t));
+ void *buf, uint16_t len, uint16_t offset) {
+ return bt_gatt_attr_read(conn, attrs, buf, len, offset, attrs->user_data, sizeof(uint8_t));
}
-static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) {
+static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, uint16_t value) {
LOG_DBG("value %d", value);
}
@@ -45,12 +45,12 @@ BT_GATT_SERVICE_DEFINE(
BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, split_svc_num_of_positions, NULL,
&num_of_positions), );
-int zmk_split_bt_position_pressed(u8_t position) {
+int zmk_split_bt_position_pressed(uint8_t position) {
WRITE_BIT(position_state[position / 8], position % 8, true);
return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state));
}
-int zmk_split_bt_position_released(u8_t position) {
+int zmk_split_bt_position_released(uint8_t position) {
WRITE_BIT(position_state[position / 8], position % 8, false);
return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state));
} \ No newline at end of file