Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

bluetooth.connect with autoDiscoverAll hangs on iOS for BT Assigned Numbers

Đang mở
#256 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
mobile-dev

Hướng nghiên cứu

Bắt đầu trong src/bluetooth.ios.ts tại discoverCharacteristics, sau đó lần theo cách decorator prepareArgs thay đổi args.serviceUUID. Tái hiện trường hợp Assigned Numbers khi autoDiscoverAll được bật và xác minh rằng việc so sánh UUID hoàn tất quá trình discovery và gọi onConnected thay vì để promise không được resolve.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I'm investigating an issue where bluetooth.connect() fails to resolve the promise when a serviceUUID falls under the Bluetooth Assigned Numbers list:

my project versions:

{
        "@nativescript/core": "^8.4.1",
        "@nativescript-community/ble": "^3.1.11",
}

the call to bluetooth.connect():

            await this.bluetooth.connect({
                UUID: deviceUuid,
                // autoDiscoverAll causes the hang... but only for those Assigned Number serviceUUIDs (link above)
                autoDiscoverAll: true, 
                onConnected: (peripheral) => {
                    // the onConnected() callback is never called... 
                },
                onDisconnected: function (peripheral) {
                    // onDisconnected IS called, on disconnect
                }
            });

I have tracked the problem down to:
https://github.com/nativescript-community/ble/blob/master/src/bluetooth.ios.ts#L1643-L1644

    @bluetoothEnabled
    @prepareArgs
    public discoverCharacteristics(args: DiscoverCharacteristicsOptions) {
        // ...
                    const sUUID = CBUUIDToString(service.UUID);
                    if (UUID === pUUID && sUUID === args.serviceUUID) {
                        // ...
                    }
        // ...
    }

the issue is the following comparison fails:

# "0000181a-0000-1000-8000-00805f9b34fb" == "181a"
sUUID === args.serviceUUID

args.serviceUUID is being be modified by the decorator prepareArgs() to a "Short UUID", if the service's UUID matches a Bluetooth Assigned Number of the form

const pattern = /0000(.{4})-0000-1000-8000-00805f9b34fb/;

however, sUUID returned by CBUUIDToString(service.UUID) is a "Long UUID"

Long vs Short UUIDs:

I'll work on a fix and submit a PR today hopefully...

Ngôn ngữ chính
TypeScript
Star
202
Fork
79
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nativescript-community/ble

Tất cả issue của nativescript-community/ble

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.