如何向 BLE 设备发送命令并显示结果

2023-12-22

@Override
public void onServicesDiscovered(final BluetoothGatt gatt, int status) {
    super.onServicesDiscovered(gatt, status);
    if (status == BluetoothGatt.GATT_SUCCESS) {
        List<BluetoothGattCharacteristic> characteristics = null;
        List<BluetoothGattService> services = gatt.getServices();
        //I am getting all services
        for (final BluetoothGattService service : services) {
            characteristics = service.getCharacteristics();
            //I am getting all characteristics for each services
        }
    }
}

我能够连接 BLE 设备,并且获得所有服务和特性,现在我已经发送了一些命令,例如打开 LED 灯,我必须发送“read slonn:”命令,并且响应灯将亮起,那么如何为此,有时我还必须在 UI 显示上显示当前命令,该命令类似于“read batti:”,显示如何获取当前值并显示我的 UI 仪表板。

请帮助我,我完全不知道如何继续。

提前致谢。


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何向 BLE 设备发送命令并显示结果 的相关文章

随机推荐