微信小程序搜索iBeacon信号实现上班签到

微信小程序开放对iBeacon蓝牙设备通讯的API,百度搜索相关资料,学习研究,终于测试成功!

在手机上打开我们的微信小程序搜索办公室的iBeacon信号,在微信上实现上班电子化签到。

   wx.startBeaconDiscovery({
      uuids: ['修改为自己的设备UUIDS'],
      success: function () {
        console.log("开始扫描设备...");
        // 监听iBeacon信号
        wx.onBeaconUpdate(function (res) {
          if (res && res.beacons && res.beacons.length > 0) {      
            // 此处最好检测rssi是否等于0,等于0的话信号强度等信息不准确。我是5秒内重复扫描排重。
            console.log(res.beacons[0].uuid)
          }
        });
      }
    });
    // 超时停止扫描
    setTimeout(function () {
      wx.stopBeaconDiscovery({
        success: function () {
          console.log("停止扫描设备!");
        }
      });
    }, 5 * 1000);

猜你喜欢

转载自hanbaohong.iteye.com/blog/2400521