Heart Rate measuring using Xiaomi MiBand and BLE

后端 未结 2 523
梦谈多话
梦谈多话 2021-02-05 17:22

I\'m trying to implement simple sdk for working with fitness tracker Xiaomi Mi Band. Currently I can track steps, actuate the vibration, handle the sensor touch but I have a pro

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 18:00

    Im working with BLE A&D , to obatin the iformation i use:

    To find UUID

      @SuppressLint("NewApi")
    private void displayGattServicesService(List gattServices) {
        //  salida.append("Buscando servicio");
        if (gattServices == null)
            return;
        for (BluetoothGattService gattService : gattServices) {
    
            String uuid = gattService.getUuid().toString();
    
            List gattCharacteristics = gattService
                    .getCharacteristics();
            if (uuid.equals("00001810-0000-1000-8000-00805f9b34fb")) {
                //  salida.append("Ecnontro");
                for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
                    String uuid1 = gattCharacteristic.getUuid().toString();
                    if (uuid1.equals("00002a35-0000-1000-8000-00805f9b34fb")) {
                        //     salida.append("Envio caracterisitca");
                        mensaje(getResources().getString(R.string.Espere_res));
                        mBluetoothLeService.setCharacteristicNotification(
                                gattCharacteristic, true);
                    }
                }
            }
        }
    }
    

    To set UUID

    BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
    
                // Show all the supported services and characteristics on the user interface.
                displayGattServicesService(mBluetoothLeService.getSupportedGattServices());
    

    Use BleGatt Example https://github.com/googlesamples/android-BluetoothLeGatt

提交回复
热议问题