How to send command to BLE device and show result

◇◆丶佛笑我妖孽 提交于 2019-12-08 07:18:59

问题


@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
        }
    }
}

I am able to connect with BLE device and I am getting all services and characteristics, now I have send some commands, like to turn on LED light I have to send "read slonn:" command and in response light will be ON, so how to do that and some time I also have to show current on my UI show for that command is like "read batti:", show how can I get current value and show my UI dashboard.

Please, help me I am totally do not know how to proceed.

Thanks in advance.

来源:https://stackoverflow.com/questions/38935479/how-to-send-command-to-ble-device-and-show-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!