ElinkThings小程序蓝牙插件SDK集合:aifresh、ailink http://doc.elinkthings.com/web/#/36?page_id=127
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <wxs module="utils">
  2. module.exports.max = function(n1, n2) {
  3. return Math.max(n1, n2)
  4. }
  5. module.exports.len = function(arr) {
  6. arr = arr || []
  7. return arr.length
  8. }
  9. module.exports.fill0 = function(num) {
  10. if (!num) {
  11. return '00'
  12. }
  13. return ('00' + num).slice(-2)
  14. }
  15. </wxs>
  16. <block wx:if="{{!connected}}">
  17. <button bindtap="openBluetoothAdapter">开始扫描</button>
  18. <button bindtap="stopBluetoothDevicesDiscovery">停止扫描</button>
  19. <button bindtap="closeBluetoothAdapter">结束流程</button>
  20. <button bindtap="clearDevices">清空列表</button>
  21. <view class="devices_summary">已发现 {{devices.length}} 个外围设备:</view>
  22. <view class="device_list">
  23. <view wx:for="{{devices}}" wx:key="index"
  24. class="device_item">
  25. <view style="font-size: 16px; color: #333;">{{item.name || item.localName}}</view>
  26. <view style="font-size: 10px">信号强度: {{item.RSSI}}dBm ({{utils.max(0, item.RSSI + 100)}}%)</view>
  27. <view style="font-size: 10px">mac地址: {{item.deviceId}}</view>
  28. <view
  29. class="device_item_btn"
  30. hover-class="btn_hover"
  31. data-device-id="{{item.deviceId}}"
  32. data-name="{{item.name || item.localName}}"
  33. data-index="{{index}}"
  34. bindtap="createBLEConnection"
  35. >连接</view>
  36. </view>
  37. </view>
  38. </block>
  39. <view class="wrap" wx:else>
  40. <view class="stopConnect">
  41. <view>{{mac}}</view>
  42. <view class="btn_connect" hover-class="btn_hover" bindtap="closeBLEConnection">断开连接</view>
  43. </view>
  44. <view class="weight_wrap">
  45. <view class="weight_title">WEIGHT</view>
  46. <view class="weight_value">
  47. <view class="value_item">{{weight}}</view>
  48. <view class="value_item">{{unit}}</view>
  49. </view>
  50. </view>
  51. <view class="timer_wrap">
  52. <view class="timer_title">TIMER</view>
  53. <view class="timer_value">
  54. <view class="value_item">{{utils.fill0(min)}}</view>
  55. <view>:</view>
  56. <view class="value_item">{{utils.fill0(second)}}</view>
  57. </view>
  58. </view>
  59. <view class="btn_wrap">
  60. <button bindtap="tare">TARE(去皮)</button>
  61. <button bindtap="getUnits">获取设备支持的单位</button>
  62. <button bindtap="countUp">正计时开始</button>
  63. <button bindtap="countUpPause">正计时暂停</button>
  64. <button bindtap="countDown">倒计时开始</button>
  65. <button bindtap="countDownPause">倒计时暂停</button>
  66. <button bindtap="resetTime">重置时间</button>
  67. <view class="btn_unitList_title">切换单位</view>
  68. <view class="btn_unitList">
  69. <view class="btn_unit" hover-class="btn_hover" wx:for="{{unitList}}" wx:key="index" bindtap="selectUnit" data-unit="{{item}}" data-index="{{index}}">{{item}}</view>
  70. </view>
  71. </view>
  72. <view class="btn_unitList_title">{{text}}</view>
  73. </view>