为什么BLEPeripheralServer. startAdvertising()无法发送成功?
发布于 5 年前 作者 zhangmin 14806 次浏览 来自 问答

我使用下面的代码进行广播的发送,尝试过发送data也尝试过发送sendData,都无法发送成功,接收广播的地方接收不到,是否是我传递serverUuids的方式错误了?是否有发送广播的示例代码可以给我看一下,谢谢!

wx.openBluetoothAdapter({
      success: function(res) {
        wx.showToast({
          title: '打开蓝牙成功',
        });

        wx.createBLEPeripheralServer({
          success: function ({ server }){
            const data = ['1111', '1111', '1111', '1111', '1111', '1111', 'A9FF', '54CB', '6F6E', '0BEA', '5173', 'ADEA', '29C6'];
            const sendData = data.map(str => `0000${str}-0000-1000-8000-00805F9B34FB`);
            wx.showToast({
              title: '创建服务对象成功',
            });
            console.log('dsafasdfadsL:',server);
            console.log('dsafasdfadsL:', server.startAdvertising);
            server.startAdvertising({
              advertiseRequest: {
                connectable: false,
                serviceUuids: data,
              }
            });
          }
        });
      },
    })

 

1 回复

你好,麻烦具体描述问题流程,提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部