diff --git a/test/renode/uptime_central/src/discovery.cpp b/test/renode/uptime_central/src/discovery.cpp index 1d27f0b..544902b 100644 --- a/test/renode/uptime_central/src/discovery.cpp +++ b/test/renode/uptime_central/src/discovery.cpp @@ -57,6 +57,11 @@ static uint8_t uptime_notify_cb(bt_conn *conn, bt_gatt_subscribe_params *params, const void *data, uint16_t length) { + LOG_INF("Notification cb"); + if (conn == NULL) { + return BT_GATT_ITER_CONTINUE; + } + if (!data) { LOG_INF("[UNSUBSCRIBED]"); params->value_handle = 0U; @@ -112,19 +117,21 @@ static uint8_t service_discover_cb(bt_conn *conn, device_char_cnt = 0; discover_characteristics(conn, attr, device_char_cnt); } else if(char_found) { + LOG_INF("attr handle %u",attr->handle); if (bt_uuid_cmp(params->uuid, &uptime::uuid::char_notify.uuid) == 0) { - LOG_INF("notify found"); // Subscribe to uptime notification subscribe_params.notify = uptime_notify_cb; subscribe_params.value = BT_GATT_CCC_NOTIFY; - subscribe_params.ccc_handle = attr->handle; + subscribe_params.ccc_handle = attr->handle+2; + subscribe_params.value_handle = bt_gatt_attr_value_handle(attr); const int err = bt_gatt_subscribe(conn, &subscribe_params); if (err != 0 && err != -EALREADY) { LOG_ERR("Subscribe failed (err %d)", err); } else { LOG_INF("[SUBSCRIBED]"); } + return BT_GATT_ITER_STOP; } if (device_char_cnt == TOTAL_CHARACTERISTICS-1) { device_found = true;