コード例 #1
0
 public boolean deregisterWatcher() {
   if (watcherRegistered == true) {
     watcherRegistered = false;
     return mHelper.deregisterCharacteristicsWatcher();
   }
   return true;
 }
コード例 #2
0
  public ParcelUuid[] getCharacteristicUuids() {

    ArrayList<ParcelUuid> uuidList = new ArrayList<ParcelUuid>();

    if (!discoveryDone) mHelper.waitDiscoveryDone();

    if (characteristicPaths == null) return null;

    int count = characteristicPaths.length;

    for (int i = 0; i < count; i++) {

      String value = getCharacteristicProperty(characteristicPaths[i], "UUID");

      if (value != null) uuidList.add(ParcelUuid.fromString(value));

      Log.d(TAG, "Characteristic UUID: " + value);
    }

    ParcelUuid[] uuids = new ParcelUuid[count];

    uuidList.toArray(uuids);

    return uuids;
  }
コード例 #3
0
 public boolean registerWatcher() {
   if (watcherRegistered == false) {
     watcherRegistered = mHelper.registerCharacteristicsWatcher();
     return watcherRegistered;
   } else {
     return true;
   }
 }
コード例 #4
0
  public String readCharacteristicString(String path) {
    if (!discoveryDone) mHelper.waitDiscoveryDone();

    if (characteristicPaths == null) return null;

    String value = (String) getCharacteristicProperty(path, "Representation");

    return value;
  }
コード例 #5
0
  public byte[] readCharacteristicRaw(String path) {
    if (!discoveryDone) mHelper.waitDiscoveryDone();

    if (characteristicPaths == null) return null;

    String value = getCharacteristicProperty(path, "Value");

    byte[] ret = value.getBytes();

    return ret;
  }
コード例 #6
0
  public BluetoothGattService(BluetoothDevice device, ParcelUuid uuid, String path) {
    mDevice = device;
    mUuid = uuid;
    mObjPath = path;
    mName = getServiceName();

    mCharacteristicProperties = new HashMap<String, Map<String, String>>();
    mHelper = new CharacteristicHelper();

    // Start characteristic discovery right away
    mHelper.doDiscovery();
  }
コード例 #7
0
  public ParcelUuid getCharacteristicUuid(String path) {

    ParcelUuid uuid = null;

    if (!discoveryDone) mHelper.waitDiscoveryDone();

    String value = getCharacteristicProperty(path, "UUID");

    if (value != null) {
      uuid = ParcelUuid.fromString(value);

      Log.d(TAG, "Characteristic UUID: " + value);
    }
    return uuid;
  }
コード例 #8
0
 public String[] getCharacteristics() {
   if (!discoveryDone) mHelper.waitDiscoveryDone();
   return characteristicPaths;
 }
コード例 #9
0
 public String getCharacteristicDescription(String path) {
   if (!discoveryDone) mHelper.waitDiscoveryDone();
   return getCharacteristicProperty(path, "Description");
 }