12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <view class="page">
- <view class="page-description">蓝牙 API</view>
- <view class="page-section">
- <view class="page-section-title">本机蓝牙开关状态</view>
- <view class="page-section-demo">
- <button type="primary" onTap="openBluetoothAdapter">初始化蓝牙</button>
- <button type="primary" onTap="closeBluetoothAdapter">关闭本机蓝牙</button>
- <button type="primary" onTap="getBluetoothAdapterState">获取蓝牙状态</button>
- </view>
- <view class="page-section-title">扫描蓝牙设备</view>
- <view class="page-section-demo">
- <button type="primary" onTap="startBluetoothDevicesDiscovery">开始搜索</button>
- <button type="primary" onTap="getBluetoothDevices">所有搜索到的设备</button>
- <button type="primary" onTap="getConnectedBluetoothDevices">所有已连接的设备</button>
- <button type="primary" onTap="stopBluetoothDevicesDiscovery">停止搜索</button>
- </view>
- <view class="page-section-title">连接设备</view>
- <view class="page-section-demo">
- <input class="input" onInput="bindKeyInput" type="{{text}}" placeholder="输入要连接的设备的deviceId"></input>
- <button type="primary" onTap="connectBLEDevice">连接设备</button>
- <button type="primary" onTap="getBLEDeviceServices">获取设备服务</button>
- <button type="primary" onTap="getBLEDeviceCharacteristics">获取读写特征</button>
- <button type="primary" onTap="disconnectBLEDevice">断开设备连接</button>
- </view>
- <view class="page-section-title">读写数据</view>
- <view class="page-section-demo">
- <button type="primary" onTap="notifyBLECharacteristicValueChange">监听特征值数据变化</button>
- <button type="primary" onTap="readBLECharacteristicValue">读取数据</button>
- <button type="primary" onTap="writeBLECharacteristicValue">写入数据</button>
- <button type="primary" onTap="offBLECharacteristicValueChange">取消特征值监听</button>
- </view>
- <view class="page-section-title">其他事件</view>
- <view class="page-section-demo">
- <button type="primary" onTap="bluetoothAdapterStateChange">本机蓝牙状态变化</button>
- <button type="primary" onTap="offBluetoothAdapterStateChange">取消本机蓝牙状态监听</button>
- <button type="primary" onTap="BLEConnectionStateChanged">蓝牙连接状态变化</button>
- <button type="primary" onTap="offBLEConnectionStateChanged">取消蓝牙连接状态监听</button>
-
- </view>
- </view>
- </view>
|