androidbluetooth-lowenergyandroid-ble

how to define SampleGattAttributes in the following code?


public final static UUID UUID_HEART_RATE_MEASUREMENT =
                UUID.fromString(SampleGattAttributes.HEART_RATE_MEASUREMENT);

SampleGattAttributes, appears in red colour,means unresolved symbol. How to define this?


Solution

  • I hope this will work for you.

    Add SampleGattAttributes class in your package given below and import class.

    import java.util.HashMap;
    
        public class SampleGattAttributes {
            private static HashMap<String, String> attributes = new HashMap();
            public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
           static {
                // Sample Services.
                attributes.put("0000180d-0000-1000-8000-00805f9b34fb", "Heart Rate Service");
                // Sample Characteristics.
                attributes.put(HEART_RATE_MEASUREMENT, "Heart Rate Measurement");
            }
        }