Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 2273038

Browse files
Jimmy Huanggrgustaf
authored andcommitted
[ble] Fixed regression the UUIDs were not found (#1880)
This was caused by the bt_uuid struct was not properly allocated memory to store the bits. Fixes #1869 Signed-off-by: Jimmy Huang <[email protected]>
1 parent 82662d6 commit 2273038

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/zjs_ble.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ typedef struct zjs_ble_handle {
8484
ble_connection_t *connections;
8585
} ble_handle_t;
8686

87+
static struct bt_uuid *gatt_primary_service_uuid = BT_UUID_GATT_PRIMARY;
88+
static struct bt_uuid *gatt_characteristic_uuid = BT_UUID_GATT_CHRC;
89+
static struct bt_uuid *gatt_cud_uuid = BT_UUID_GATT_CUD;
90+
static struct bt_uuid *gatt_ccc_uuid = BT_UUID_GATT_CCC;
91+
8792
static struct k_sem ble_sem;
8893

8994
static ble_handle_t *ble_handle = NULL;
@@ -1032,7 +1037,7 @@ static bool zjs_ble_register_service(ble_service_t *service)
10321037
memset(bt_attrs, 0, sizeof(struct bt_gatt_attr) * num_of_entries);
10331038

10341039
// GATT Primary Service
1035-
bt_attrs[entry_index].uuid = BT_UUID_GATT_PRIMARY;
1040+
bt_attrs[entry_index].uuid = gatt_primary_service_uuid;
10361041
bt_attrs[entry_index].perm = BT_GATT_PERM_READ;
10371042
bt_attrs[entry_index].read = bt_gatt_attr_read_service;
10381043
bt_attrs[entry_index].user_data = service->uuid;
@@ -1052,7 +1057,7 @@ static bool zjs_ble_register_service(ble_service_t *service)
10521057

10531058
chrc_user_data->uuid = ch->uuid;
10541059
chrc_user_data->properties = ch->flags;
1055-
bt_attrs[entry_index].uuid = BT_UUID_GATT_CHRC;
1060+
bt_attrs[entry_index].uuid = gatt_characteristic_uuid;
10561061
bt_attrs[entry_index].perm = BT_GATT_PERM_READ;
10571062
bt_attrs[entry_index].read = bt_gatt_attr_read_chrc;
10581063
bt_attrs[entry_index].user_data = chrc_user_data;
@@ -1089,7 +1094,7 @@ static bool zjs_ble_register_service(ble_service_t *service)
10891094
// FIXME: cud_buffer should be freed later if no longer needed, but
10901095
// doesn't seem to be
10911096

1092-
bt_attrs[entry_index].uuid = BT_UUID_GATT_CUD;
1097+
bt_attrs[entry_index].uuid = gatt_cud_uuid;
10931098
bt_attrs[entry_index].perm = BT_GATT_PERM_READ;
10941099
bt_attrs[entry_index].read = bt_gatt_attr_read_cud;
10951100
bt_attrs[entry_index].user_data = cud_buffer;
@@ -1111,7 +1116,7 @@ static bool zjs_ble_register_service(ble_service_t *service)
11111116
ccc_user_data->cfg = ble_handle->blvl_ccc_cfg;
11121117
ccc_user_data->cfg_len = ARRAY_SIZE(ble_handle->blvl_ccc_cfg);
11131118
ccc_user_data->cfg_changed = zjs_ble_blvl_ccc_cfg_changed;
1114-
bt_attrs[entry_index].uuid = BT_UUID_GATT_CCC;
1119+
bt_attrs[entry_index].uuid = gatt_ccc_uuid;
11151120
bt_attrs[entry_index].perm = BT_GATT_PERM_READ | BT_GATT_PERM_WRITE;
11161121
bt_attrs[entry_index].read = bt_gatt_attr_read_ccc;
11171122
bt_attrs[entry_index].write = bt_gatt_attr_write_ccc;

0 commit comments

Comments
 (0)