diff --git a/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/BatteryServiceFragment.java b/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/BatteryServiceFragment.java index 6db7563..c8e4173 100644 --- a/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/BatteryServiceFragment.java +++ b/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/BatteryServiceFragment.java @@ -20,6 +20,7 @@ import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; import android.os.Bundle; +import android.os.ParcelUuid; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; @@ -155,6 +156,11 @@ public BluetoothGattService getBluetoothGattService() { return mBatteryService; } + @Override + public ParcelUuid getServiceUUID() { + return new ParcelUuid(BATTERY_SERVICE_UUID); + } + private void setBatteryLevel(int newBatteryLevel, View source) { mBatteryLevelCharacteristic.setValue(newBatteryLevel, BluetoothGattCharacteristic.FORMAT_UINT8, /* offset */ 0); diff --git a/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/HeartRateServiceFragment.java b/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/HeartRateServiceFragment.java index ec781d4..8ed63e5 100644 --- a/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/HeartRateServiceFragment.java +++ b/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/HeartRateServiceFragment.java @@ -21,6 +21,7 @@ import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; import android.os.Bundle; +import android.os.ParcelUuid; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -216,6 +217,11 @@ public BluetoothGattService getBluetoothGattService() { return mHeartRateService; } + @Override + public ParcelUuid getServiceUUID() { + return new ParcelUuid(HEART_RATE_SERVICE_UUID); + } + private void setHeartRateMeasurementValue(int heartRateMeasurementValue, int expendedEnergy) { Log.d(TAG, Arrays.toString(mHeartRateMeasurementCharacteristic.getValue())); diff --git a/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/Peripheral.java b/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/Peripheral.java index 5a1b223..4d7903f 100644 --- a/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/Peripheral.java +++ b/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/Peripheral.java @@ -206,6 +206,7 @@ protected void onCreate(Bundle savedInstanceState) { mAdvData = new AdvertiseData.Builder() .setIncludeDeviceName(true) .setIncludeTxPowerLevel(true) + .addServiceUuid(mCurrentServiceFragment.getServiceUUID()) .build(); } diff --git a/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/ServiceFragment.java b/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/ServiceFragment.java index bd5695b..44b2e6e 100644 --- a/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/ServiceFragment.java +++ b/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/ServiceFragment.java @@ -19,9 +19,11 @@ import android.app.Fragment; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; +import android.os.ParcelUuid; public abstract class ServiceFragment extends Fragment{ public abstract BluetoothGattService getBluetoothGattService(); + public abstract ParcelUuid getServiceUUID(); /** * Function to communicate to the ServiceFragment that a device wants to write to a