欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

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

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

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

 

Js代码  收藏代码
  1. wx.startBeaconDiscovery({  

  2.    uuids: ['修改为自己的设备UUIDS'],  

  3.    success: function () {  

  4.      console.log("开始扫描设备...");  

  5.      // 监听iBeacon信号  

  6.      wx.onBeaconUpdate(function (res) {  

  7.        if (res && res.beacons && res.beacons.length > 0) {        

  8.          // 此处最好检测rssi是否等于0,等于0的话信号强度等信息不准确。我是5秒内重复扫描排重。  

  9.          console.log(res.beacons[0].uuid)  

  10.        }  

  11.      });  

  12.    }  

  13.  });  

  14.  // 超时停止扫描  

  15.  setTimeout(function () {  

  16.    wx.stopBeaconDiscovery({  

  17.      success: function () {  

  18.        console.log("停止扫描设备!");  

  19.      }  

  20.    });  

  21.  }, 5 * 1000);  

 

来自  http://hanbaohong.iteye.com/blog/2400521

普通分类: