diff --git a/sample_app/src/uk/co/alt236/btlescan/activities/DeviceControlActivity.java b/sample_app/src/uk/co/alt236/btlescan/activities/DeviceControlActivity.java index b33e6c6..d18d16b 100644 --- a/sample_app/src/uk/co/alt236/btlescan/activities/DeviceControlActivity.java +++ b/sample_app/src/uk/co/alt236/btlescan/activities/DeviceControlActivity.java @@ -20,9 +20,9 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import uk.co.alt236.bluetoothlelib.resolvers.GattAttributeResolver; import uk.co.alt236.btlescan.R; import uk.co.alt236.btlescan.services.BluetoothLeService; -import uk.co.alt236.btlescan.util.SampleGattAttributes; import android.app.Activity; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; @@ -262,7 +262,7 @@ public class DeviceControlActivity extends Activity { HashMap currentServiceData = new HashMap(); uuid = gattService.getUuid().toString(); currentServiceData.put( - LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString)); + LIST_NAME, GattAttributeResolver.getAttributeName(uuid, unknownServiceString)); currentServiceData.put(LIST_UUID, uuid); gattServiceData.add(currentServiceData); @@ -279,7 +279,7 @@ public class DeviceControlActivity extends Activity { HashMap currentCharaData = new HashMap(); uuid = gattCharacteristic.getUuid().toString(); currentCharaData.put( - LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString)); + LIST_NAME, GattAttributeResolver.getAttributeName(uuid, unknownCharaString)); currentCharaData.put(LIST_UUID, uuid); gattCharacteristicGroupData.add(currentCharaData); } diff --git a/sample_app/src/uk/co/alt236/btlescan/services/BluetoothLeService.java b/sample_app/src/uk/co/alt236/btlescan/services/BluetoothLeService.java index f1d4829..d5fb0b6 100644 --- a/sample_app/src/uk/co/alt236/btlescan/services/BluetoothLeService.java +++ b/sample_app/src/uk/co/alt236/btlescan/services/BluetoothLeService.java @@ -19,7 +19,7 @@ package uk.co.alt236.btlescan.services; import java.util.List; import java.util.UUID; -import uk.co.alt236.btlescan.util.SampleGattAttributes; +import uk.co.alt236.bluetoothlelib.resolvers.GattAttributeResolver; import android.app.Service; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; @@ -65,7 +65,7 @@ public class BluetoothLeService extends Service { "com.example.bluetooth.le.EXTRA_DATA"; public final static UUID UUID_HEART_RATE_MEASUREMENT = - UUID.fromString(SampleGattAttributes.HEART_RATE_MEASUREMENT); + UUID.fromString(GattAttributeResolver.HEART_RATE_MEASUREMENT); // Implements callback methods for GATT events that the app cares about. For example, // connection change and services discovered. @@ -300,7 +300,7 @@ public class BluetoothLeService extends Service { // This is specific to Heart Rate Measurement. if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) { BluetoothGattDescriptor descriptor = characteristic.getDescriptor( - UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG)); + UUID.fromString(GattAttributeResolver.CLIENT_CHARACTERISTIC_CONFIG)); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); } diff --git a/sample_app/src/uk/co/alt236/btlescan/util/SampleGattAttributes.java b/sample_app/src/uk/co/alt236/btlescan/util/SampleGattAttributes.java deleted file mode 100644 index 42919c7..0000000 --- a/sample_app/src/uk/co/alt236/btlescan/util/SampleGattAttributes.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package uk.co.alt236.btlescan.util; - -import java.util.HashMap; - -/** - * This class includes a small subset of standard GATT attributes for demonstration purposes. - */ -public class SampleGattAttributes { - private static HashMap attributes = new HashMap(); - public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb"; - public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb"; - - static { - // Sample Services. - attributes.put("0000180d-0000-1000-8000-00805f9b34fb", "Heart Rate Service"); - attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information Service"); - // Sample Characteristics. - attributes.put(HEART_RATE_MEASUREMENT, "Heart Rate Measurement"); - attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String"); - } - - public static String lookup(String uuid, String defaultName) { - String name = attributes.get(uuid); - return name == null ? defaultName : name; - } -} \ No newline at end of file