ElinkThings小程序蓝牙插件SDK集合:aifresh、ailink http://doc.elinkthings.com/web/#/36?page_id=127
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. </wxs>
  10. <view class="container">
  11. <view class="header">
  12. <button bindtap="openBluetoothAdapter" style="font-size: 32rpx;line-height:100rpx;width: 100%;">开始扫描</button>
  13. <button bindtap="stopBluetoothDevicesDiscovery" style="font-size: 32rpx;line-height:100rpx;width: 100%;">停止扫描</button>
  14. <button bindtap="closeBluetoothAdapter" style="font-size: 32rpx;line-height:100rpx;width: 100%;">结束流程</button>
  15. </view>
  16. <view class="devices_summary">已发现 {{devices.length}} 个外围设备:</view>
  17. <scroll-view class="device_list" scroll-y scroll-with-animation>
  18. <view wx:for="{{devices}}" wx:key="index"
  19. data-device-id="{{item.deviceId}}"
  20. data-name="{{item.name || item.localName}}"
  21. data-mac="{{item.mac}}"
  22. data-index="{{index}}"
  23. bindtap="createBLEConnection"
  24. class="device_item"
  25. hover-class="device_item_hover">
  26. <view style="font-size: 32rpx;">
  27. <text style="color:#000;font-weight:bold">{{item.name}}</text>
  28. <text style="font-size:26rpx">(信号强度: {{item.RSSI}}dBm)</text>
  29. </view>
  30. <view style="font-size: 26rpx">mac地址: {{item.macAddr || item.deviceId}}</view>
  31. <!-- <view style="font-size: 10px">Service数量: {{utils.len(item.advertisServiceUUIDs)}}</view> -->
  32. <view style="font-size: 26rpx">广播数据:{{item.analyzeDataText}}</view>
  33. </view>
  34. </scroll-view>
  35. <view class="connected_info" wx:if="{{connected}}">
  36. <view>
  37. <text>已连接到 {{name}}</text>
  38. <view class="operation">
  39. <!-- <button wx:if="{{canWrite}}" size="mini" bindtap="writeBLECharacteristicValue">写数据</button> -->
  40. <button size="mini" bindtap="showWriteInputView" style="line-height:54rpx; font-size:28rpx;padding:0 20rpx;margin-right:10rpx">写入指令</button>
  41. <button size="mini" bindtap="closeBLEConnection" style="line-height:54rpx; font-size:28rpx;padding:0 20rpx;">断开连接</button>
  42. </view>
  43. </view>
  44. <view wx:for="{{chs}}" wx:key="index" style="font-size: 26rpx; margin-top: 20rpx;">
  45. <view>特性值: {{item.value}}</view>
  46. </view>
  47. </view>
  48. <view class="writeInputView" wx:if="{{showWriteInput}}">
  49. <view class="writeInput">
  50. <input type="text" model:value="{{cmd}}"></input>
  51. </view>
  52. <view class="hint">请输入16进制数,Byte之间用空格或英文逗号分隔</view>
  53. <view class="btns">
  54. <button bindtap="submitCmd" style="line-height:70rpx; font-size:30rpx;padding:0 50rpx;margin-right:30rpx;">发送</button>
  55. <button bindtap="hideWriteInputView" style="line-height:70rpx; font-size:30rpx;padding:0 50rpx;">取消</button>
  56. </view>
  57. <view class="history">
  58. <view class="history_title">历史记录:</view>
  59. <scroll-view class="history_wrap" scroll-y="true">
  60. <view class="history_item" wx:for="{{historyList}}" wx:key="index">
  61. <view class="history_cmd">{{item.cmd}}</view>
  62. <view class="history_btns">
  63. <button size="mini" bindtap="history_send" data-index="{{index}}" style="line-height:54rpx; font-size:24rpx;padding:0 30rpx;">发送</button>
  64. <button size="mini" bindtap="history_delete" data-index="{{index}}" style="line-height:54rpx; font-size:24rpx;padding:0 30rpx;margin-left:20rpx">删除</button>
  65. </view>
  66. </view>
  67. </scroll-view>
  68. </view>
  69. </view>
  70. </view>