Commit Graph

20 Commits

Author SHA1 Message Date
liuxiang18 2244e388f7 aync adv/scan: fix build error
bug: v/83666

The callback macro `CALLBACK_REMOTE` currently used in gatts/gattc employs the member variable `callbacks`. For enhanced versatility, the callback member variables in adv and scan have been modified from `callback` to `callbacks`.

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:54 +08:00
Lu Jia e0699b4797 bluetooth: Before releasing the IPC pending_queue, invoke the asynchronous callbacks for all messages contained within it.
bug: v/77564

When deleting the Bluetooth asynchronous instance, the IPC cached messages are directly released, and their asynchronous callbacks will not be invoked. This could lead to memory leaks if resources are released within the callbacks.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-27 23:14:52 +08:00
Lu Jia 6ab8107575 ipc: gattc async api
bug: v/62106

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-27 23:14:52 +08:00
Lu Jia f5965d1303 bluetooth: Add initialization for local variables.
When passed to bt_socket_client_send_with_reply , it may contain undefined values, leading to unpredictable behavior. Initialize packet explicitly before using it.

Signed-off-by: jialu <jialu@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:53:21 +08:00
Lu Jia 05614c8747 bluetooth: Add initialization for local variables.
When passed to bt_socket_client_send_with_reply , it may contain undefined values, leading to unpredictable behavior. Initialize packet explicitly  before using it.

Signed-off-by: jialu <jialu@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:53:21 +08:00
zhangyuan20 155520406c fix problem that pair pin command do not send accept
Rootcause: Pair pin command do not send accept, The default value is 0, thus rejecting the pair process, So add accept when send to socket.

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:53:05 +08:00
Lu Jia 08b110ac5c bluetooth: Using macros to reduce boilerplate code in asynchronous callbacks.
Some processing logic in asynchronous callbacks is identical; extract this common code into a macro.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:34 +08:00
Lu Jia 7818c54bb0 bluetooth: Release resources within the callback during deletion of the GATTC asynchronous instance.
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:33 +08:00
Lu Jia 4b66d260fd bluetooth: Before releasing the IPC pending_queue, invoke the asynchronous callbacks for all messages contained within it.
When deleting the Bluetooth asynchronous instance, the IPC cached messages are directly released, and their asynchronous callbacks will not be invoked. This could lead to memory leaks if resources are released within the callbacks.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:33 +08:00
Lu Jia 778c625e42 bluetooth: Fix compilation errors
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:13 +08:00
Lu Jia 0cca14cced ipc: trace async api
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:09 +08:00
Lu Jia cf1f9b4220 ipc: gattc async api
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:08 +08:00
Lu Jia 7af64278ec bluetooth: Add instance in the handle returned by the callback in scan.
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:08 +08:00
Lu Jia 69334cb53e ipc: le scan async api
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:08 +08:00
Lu Jia 1fa9f974bc bluetooth: Add instance in the handle returned by the callback in adv.
Root cause: The interface handle and other information of the feature exist on the instance of Bluetooth. If the callback does not have instance information, it cannot obtain feature-related information, resulting in the JavaScript application not receiving the callback.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:08 +08:00
Lu Jia 295db704ae bluetooth: Fix compilation errors when calling Bluetooth in C++ files.
Root Cause: When a C++ file references a Bluetooth file, compilation errors occur due to the Bluetooth file using C++ keywords.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:07 +08:00
Lu Jia 0e070754c0 ipc: le advertiser async api
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:00 +08:00
Lu Jia 3b4c8cb29f bluetooth: Fix bugs in asynchronous API.
Root cause:
1. The application does not pass asynchronous callback when it should directly return an error code. The message should not be sent to the server, and the entire callback list should not be freed.
2. The application registers multiple callbacks, but it should not return the asynchronous callback first and then return the return value of the asynchronous call. This behavior is inconsistent for the application between the first registration of a callback and subsequent registrations. When the application registers multiple callbacks, the message can be sent to the server, and the server will handle duplicate registrations.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:51:58 +08:00
fangzhenwei 2550f8a068 ipc: device async api
Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2026-04-20 14:51:32 +08:00
fangzhenwei 62c281090d ipc: adapter async api
Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2026-04-20 14:51:32 +08:00