Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why it is not returns the battery value ? #1

Open
shankarpilli opened this issue Jul 12, 2017 · 0 comments
Open

Why it is not returns the battery value ? #1

shankarpilli opened this issue Jul 12, 2017 · 0 comments

Comments

@shankarpilli
Copy link

Hi

public void displayGattServices(List gattServices) {
if (gattServices == null) return;
String uuid;
String unknownServiceString;
unknownServiceString = getResources().getString(string.unknown_service);
String unknownCharaString;
unknownCharaString = getResources().getString(string.unknown_characteristic);
ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<>();
ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData
= new ArrayList<>();
ArrayList<ArrayList> mGattCharacteristics = new ArrayList<>();

    // Loops through available GATT Services.

    for (BluetoothGattService gattService : gattServices) {
        HashMap<String, String> currentServiceData = new HashMap<>();
        uuid = gattService.getUuid().toString();

        String LIST_NAME = "NAME";
        currentServiceData.put(
                LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));
        String LIST_UUID = "UUID";
        currentServiceData.put(LIST_UUID, uuid);
        gattServiceData.add(currentServiceData);

        ArrayList<HashMap<String, String>> gattCharacteristicGroupData =
                new ArrayList<>();
        List<BluetoothGattCharacteristic> gattCharacteristics =
                gattService.getCharacteristics();
        ArrayList<BluetoothGattCharacteristic> charas =
                new ArrayList<>();

        // Loops through available Characteristics.
        for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
            charas.add(gattCharacteristic);
            HashMap<String, String> currentCharaData = new HashMap<>();
            uuid = gattCharacteristic.getUuid().toString();

            String gattInfo = SampleGattAttributes.lookup(uuid, unknownCharaString);
            if (gattInfo.equalsIgnoreCase("Heart Rate Measurement")) {
                currentCharaData.put(
                        LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));
                currentCharaData.put(LIST_UUID, uuid);
                Utility.showLog("loop", uuid);
                mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true);
            }
            gattCharacteristicGroupData.add(currentCharaData);
        }
        mGattCharacteristics.add(charas);
        gattCharacteristicData.add(gattCharacteristicGroupData);
    }
}

It will not give Battery value. If i want battery and heart rate same time what i have to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant