Commit Graph

7 Commits

Author SHA1 Message Date
zhongzhijie1 e52b434172 gattc/feature: add high-level GATT client, local DB, and async ops
bug: v/62106

Add feature-layer GATT client (gatt_client_t) wrapping low-level GATTC callbacks.
Build a local services DB from discovery (service/characteristic/descriptor).
Provide stable UUID handle lookups and helpers (service/char/desc finders).
Implement async read/write for characteristics and descriptors, notify subscribe/unsubscribe, and MTU exchange.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-27 23:14:52 +08:00
haopengxiang 2f3def81fb frameworks/connectivity/bluetooth: fix build error with assert.h exclude from mutex.h
../../frameworks/connectivity/bluetooth/framework/btwrap/async/bt_gatt_feature.c: In function 'create_client_cb':
../../frameworks/connectivity/bluetooth/framework/btwrap/async/bt_gatt_feature.c:750:9: error: implicit declaration of function 'assert' [-Werror=implicit-function-declaration]
  750 |         assert(0);
      |         ^~~~~~
../../frameworks/connectivity/bluetooth/framework/btwrap/async/bt_gatt_feature.c:29:1: note: 'assert' is defined in header '<assert.h>'; did you forget to '#include <assert.h>'?
   28 | #include bt_uuid.h
  +++ |+#include <assert.h>
   29 |

Signed-off-by: haopengxiang <haopengxiang@xiaomi.com>
2026-04-20 14:53:22 +08:00
Lu Jia 0647f85b0f bluetooth: Fix the issue of failed GATTC deletion.
When deleting a GATTC instance, the Advanced API identifies clients based on their device address. If an application creates two GATTC instances with the same device address, and attempts to delete the second instance before the server has returned the asynchronous callback for the first deletion, both deletion operations will effectively target the same underlying GATTC instance due to the identical device address.

Signed-off-by: jialu <jialu@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:52:34 +08:00
zhongzhijie1 d8c0ed8abb Extend feature get-service callback to report service array
The original bt_gattc_feature_get_service_cb_t callback only returned a
single gatt_service_t pointer. This is insufficient for feature-layer
use cases that require receiving all discovered services at once.

This patch updates the callback signature by adding:

- const gatt_service_t *services[] : array of discovered service pointers
- size_t count                     : number of services in the array

This allows the feature layer to receive a batch of services in a single
notification and avoids repeated per-service callbacks.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:34 +08:00
Lu Jia f6fe4d7c3e bluetooth: In the asynchronous callback of GATTC deletion, release resources regardless of the operation status (success or failure).
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:34 +08:00
Lu Jia fee90b0857 bluetooth: Fix the memory leak issue in GATTC.
When deleting GATTC, if the application does not provide a callback, the Bluetooth async API cannot be invoked, leading to the inability to release gattc remote list and causing a memory leak.

Signed-off-by: jialu <jialu@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:52:14 +08:00
zhongzhijie1 747b14d440 gattc/feature: add high-level GATT client, local DB, and async ops
Add feature-layer GATT client (gatt_client_t) wrapping low-level GATTC callbacks.
Build a local services DB from discovery (service/characteristic/descriptor).
Provide stable UUID handle lookups and helpers (service/char/desc finders).
Implement async read/write for characteristics and descriptors, notify subscribe/unsubscribe, and MTU exchange.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:08 +08:00