BLE APIs在真机上获取不到advertisData
发布于 7 年前 作者 ming71 558 次浏览 来自 问答

wx.openBluetoothAdapter({

    success: function () {

    var scaning = true;

    wx.onBluetoothDeviceFound(function (res) {

        console.log(res)

        for (var d in res.devices) {

            console.log(‘advertisData:’+d.advertisData)

            console.log(typeof d.advertisData)

        }

    });

    

    setTimeout(function () {

        if (scaning) {

            console.warn(“ble搜索超时,停止搜索”)

            wx.stopBluetoothDevicesDiscovery()

            fail()

        }

    }, 10 * 1000);

    

    wx.startBluetoothDevicesDiscovery({

        services: [‘18EE’],

        allowDuplicatesKey: true,

        success: function (res) {

            console.log(res)

        }

        })

    }, fail: function (e) {

        fail(e)

    }

})

用第三方工具扫描蓝牙,是能看到广播数据的(第二张图);

分别使用Android和iOS测试过小程序,都获取不到;

1 回复

有人遇到相同的问题吗?

回到顶部