Skip to content

Commit da904b9

Browse files
committed
zephyr: Send BLE notifications/indications even if not subscribed.
This is now possible with CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n Signed-off-by: Daniel Campora <[email protected]>
1 parent 4ba094d commit da904b9

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

ports/zephyr/boards/nrf52840dk_nrf52840.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CONFIG_BT_CENTRAL=y
77
CONFIG_BT_GATT_CLIENT=y
88
CONFIG_BT_L2CAP_TX_MTU=252
99
CONFIG_BT_BUF_ACL_RX_SIZE=256
10+
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n
1011

1112
CONFIG_MICROPY_HEAP_SIZE=98304
1213
CONFIG_MAIN_STACK_SIZE=8192

ports/zephyr/modbluetooth_zephyr.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -764,24 +764,19 @@ int mp_bluetooth_gatts_notify_indicate(uint16_t conn_handle, uint16_t value_hand
764764
if (attr_val) {
765765
switch (gatts_op) {
766766
case MP_BLUETOOTH_GATTS_OP_NOTIFY: {
767-
err = 0;
768-
if (entry && (entry->data[0] == BT_GATT_CCC_NOTIFY)) { // if the characteristic has been subscribed for notifications
769-
err = bt_gatt_notify(connection->conn, attr_val, value, value_len);
770-
}
767+
err = bt_gatt_notify(connection->conn, attr_val, value, value_len);
771768
break;
772769
}
773770
case MP_BLUETOOTH_GATTS_OP_INDICATE: {
774-
if (entry && (entry->data[0] == BT_GATT_CCC_INDICATE)) { // if the characteristic has been subscribed for indications
775-
struct bt_gatt_indicate_params params = {
776-
.uuid = NULL,
777-
.attr = attr_val,
778-
.func = mp_bt_zephyr_gatt_indicate_done,
779-
.destroy = NULL,
780-
.data = value,
781-
.len = value_len
782-
};
783-
err = bt_gatt_indicate(connection->conn, &params);
784-
}
771+
struct bt_gatt_indicate_params params = {
772+
.uuid = NULL,
773+
.attr = attr_val,
774+
.func = mp_bt_zephyr_gatt_indicate_done,
775+
.destroy = NULL,
776+
.data = value,
777+
.len = value_len
778+
};
779+
err = bt_gatt_indicate(connection->conn, &params);
785780
break;
786781
}
787782
}

0 commit comments

Comments
 (0)