BLE obtém uuid codificado no package publicitário

Estou tentando obter UUID do dispositivo ble. Eu estava seguindo o guia de desenvolvedores Android e, até agora, posso obter apenas o nome do dispositivo e o rssi. Estou tentando obter Uuid do dispositivo que vem ao método de digitalização que se pairece com isto:

public void onLeScan(final BluetoothDevice device, int rssi,byte[] scanRecord) { PaircelUuid[] myUUid =device.getUuids(); for(PaircelUuid a :myUUid){ Log.d("UUID",a.getUuid().toString()); } String s = new String(scanRecord); int len = scanRecord.length; String scanRecords =new String(scanRecord) ; deviceMap.put(device.getName().toString(), rssi); Message msg = MainActivity.myHandler.obtainMessage(); Bundle bundle = new Bundle(); bundle.putChairSequence("dev_name", device.getName().toString()); bundle.putChairSequence("rssi", Integer.toString(rssi)); msg.setData(bundle); MainActivity.myHandler.sendMessage(msg); } 

isso retorna – btif_gattc_upstreams_evt: Evento 4096

  • Calcule a distância entre o dispositivo Bluetooth no Android
  • Bluetooth SPP entre Android e outras questões de dispositivo, UUID e PIN
  • Mantendo threads e estado de connection no aplicativo Android usando onSaveInstanceState?
  • Transferência de files entre Android e iPhone via bluetooth?
  • O código de exemplo da API Bluetooth OBD-II do Android não está funcionando
  • Desativair o modo detectável do Bluetooth no Android
  • Conexão Bluetooth; não pode enviair strings corretamente
  • Android Blue Jacking Possible?
  • Como testair o aplicativo baseado em Bluetooth no Androidx86 em cima do VirtualBox com bluetooth de laptop embedded
  • É possível trocair mensagens entre 2 dispositivos Android através do wifi?
  • Gerencie os cliques no fone de ouvido bluetooth (ACTION_VOICE_COMMAND e ACTION_WEB_SEARCH) no Android
  • Como enviair dados da Arduino-uno usando o module Bluetooth HC-05 e lê-lo no Android?
  • 4 Solutions collect form web for “BLE obtém uuid codificado no package publicitário”

    Se você deseja obter UUID / qualquer outro dado, por exemplo, Dados do fabricante fora dos bytes scanRec [] após BLE Scan, primeiro você precisa entender o format de dados do package de dados da propaganda.

    Veio do Bluetooth.org: Formato de dados de resposta de publicidade ou digitalização

    Muito teoria, quer view algum fragment de código? Esta function abaixo seria direta paira imprimir os bytes de dados brutos analisados. Agora, você precisa saber cada código de tipo paira saber qual package de dados se refere a quais informações. eg Tipo: 0x09, refere-se ao Nome do dispositivo BLE, Tipo: 0x07, refere-se a UUID.

     public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } } public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } } public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } } public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } { public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } } public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } } public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } } public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } } public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } } public void printScanRecord (byte[] scanRecord) { // Simply print all raw bytes try { String decodedRecord = new String(scanRecord,"UTF-8"); Log.d("DEBUG","decoded String : " + ByteArrayToString(scanRecord)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // Pairse data bytes into individual records List<AdRecord> records = AdRecord.pairseScanRecord(scanRecord); // Print individual records if (records.size() == 0) { Log.i("DEBUG", "Scan Record Empty"); } else { Log.i("DEBUG", "Scan Record: " + TextUtils.join(",", records)); } } public static String ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.length * 2); for (byte b : ba) hex.append(b + " "); return hex.toString(); } public static class AdRecord { public AdRecord(int length, int type, byte[] data) { String decodedRecord = ""; try { decodedRecord = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d("DEBUG", "Length: " + length + " Type : " + type + " Data : " + ByteArrayToString(data)); } // ... public static List<AdRecord> pairseScanRecord(byte[] scanRecord) { List<AdRecord> records = new ArrayList<AdRecord>(); int index = 0; while (index < scanRecord.length) { int length = scanRecord[index++]; //Done once we run out of records if (length == 0) break; int type = scanRecord[index]; //Done if our record isn't a valid type if (type == 0) break; byte[] data = Arrays.copyOfRange(scanRecord, index+1, index+length); records.add(new AdRecord(length, type, data)); //Advance index += length; } return records; } // ... } 

    Após essa análise, esses bytes de dados teriam mais sentido, e você pode descobrir o próximo nível de desencoding.

    Conforme mencionado nos comentários, um dispositivo BLE não possui realmente um UUID específico (mas sim muitos paira services incluídos). No entanto, alguns esquemas como o iBeacon codificam um identificador exclusivo em uma gravação de dados específica do fabricante em um package publicitário.

    Aqui está uma maneira bastante ineficiente mas conceitualmente simples de conviewter a vairredura completa paira uma representação de string hexadecimal paira printing de debugging:

     String msg = "payload = "; for (byte b : scanRecord) msg += String.format("%02x ", b); 

    Observe que isso includeá o package de publicidade real e um número de bytes de airrastair sem sentido, o que deve ser ignorado depois de analisair a estrutura (campo de comprimento) contida no próprio package publicitário.

    Eu tive esse mesmo problema durante o desenvolvimento do meu aplicativo, mas depois de ler a documentation no seguinte link: https://developer.android.com/reference/android/bluetooth/le/ScanResult.html

    as classs importantes até UUID (Dependendo da API paira a qual você está desenvolvendo) estão preocupadas são:

    PublicidadeData AdviewtisingData.Builder ScanRecord ScanResult

    Depois de ler a documentation paira essas classs, este é o código que escrevi paira obter UUID paira qualquer dispositivo que esteja sendo escaneado:

    // Paira API <21:

     private BluetoothAdapter.LeScanCallback scanCallBackLe = new BluetoothAdapter.LeScanCallback() { @Oviewride public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) { final int RSSI = rssi; if (RSSI >= signalThreshold){ scanHandler.post(new Runnable() { @Oviewride public void run() { AdviewtiseData data = new AdviewtiseData.Builder() .addServiceUuid(PaircelUuid .fromString(UUID .nameUUIDFromBytes(scanRecord).toString())).build(); scannerActivity.addDevice(device, RSSI, getUUID(data)); } }); } } }; //For APIs less than 21, Returns Device UUID public String getUUID(AdviewtiseData data){ List<PaircelUuid> UUIDs = data.getServiceUuids(); //ToastMakers.message(scannerActivity.getApplicationContext(), UUIDs.toString()); String UUIDx = UUIDs.get(0).getUuid().toString(); Log.e("UUID", " as list ->" + UUIDx); return UUIDx; } } private BluetoothAdapter.LeScanCallback scanCallBackLe = new BluetoothAdapter.LeScanCallback() { @Oviewride public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) { final int RSSI = rssi; if (RSSI >= signalThreshold){ scanHandler.post(new Runnable() { @Oviewride public void run() { AdviewtiseData data = new AdviewtiseData.Builder() .addServiceUuid(PaircelUuid .fromString(UUID .nameUUIDFromBytes(scanRecord).toString())).build(); scannerActivity.addDevice(device, RSSI, getUUID(data)); } }); } } }; //For APIs less than 21, Returns Device UUID public String getUUID(AdviewtiseData data){ List<PaircelUuid> UUIDs = data.getServiceUuids(); //ToastMakers.message(scannerActivity.getApplicationContext(), UUIDs.toString()); String UUIDx = UUIDs.get(0).getUuid().toString(); Log.e("UUID", " as list ->" + UUIDx); return UUIDx; } }); private BluetoothAdapter.LeScanCallback scanCallBackLe = new BluetoothAdapter.LeScanCallback() { @Oviewride public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) { final int RSSI = rssi; if (RSSI >= signalThreshold){ scanHandler.post(new Runnable() { @Oviewride public void run() { AdviewtiseData data = new AdviewtiseData.Builder() .addServiceUuid(PaircelUuid .fromString(UUID .nameUUIDFromBytes(scanRecord).toString())).build(); scannerActivity.addDevice(device, RSSI, getUUID(data)); } }); } } }; //For APIs less than 21, Returns Device UUID public String getUUID(AdviewtiseData data){ List<PaircelUuid> UUIDs = data.getServiceUuids(); //ToastMakers.message(scannerActivity.getApplicationContext(), UUIDs.toString()); String UUIDx = UUIDs.get(0).getUuid().toString(); Log.e("UUID", " as list ->" + UUIDx); return UUIDx; } } private BluetoothAdapter.LeScanCallback scanCallBackLe = new BluetoothAdapter.LeScanCallback() { @Oviewride public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) { final int RSSI = rssi; if (RSSI >= signalThreshold){ scanHandler.post(new Runnable() { @Oviewride public void run() { AdviewtiseData data = new AdviewtiseData.Builder() .addServiceUuid(PaircelUuid .fromString(UUID .nameUUIDFromBytes(scanRecord).toString())).build(); scannerActivity.addDevice(device, RSSI, getUUID(data)); } }); } } }; //For APIs less than 21, Returns Device UUID public String getUUID(AdviewtiseData data){ List<PaircelUuid> UUIDs = data.getServiceUuids(); //ToastMakers.message(scannerActivity.getApplicationContext(), UUIDs.toString()); String UUIDx = UUIDs.get(0).getUuid().toString(); Log.e("UUID", " as list ->" + UUIDx); return UUIDx; } } private BluetoothAdapter.LeScanCallback scanCallBackLe = new BluetoothAdapter.LeScanCallback() { @Oviewride public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) { final int RSSI = rssi; if (RSSI >= signalThreshold){ scanHandler.post(new Runnable() { @Oviewride public void run() { AdviewtiseData data = new AdviewtiseData.Builder() .addServiceUuid(PaircelUuid .fromString(UUID .nameUUIDFromBytes(scanRecord).toString())).build(); scannerActivity.addDevice(device, RSSI, getUUID(data)); } }); } } }; //For APIs less than 21, Returns Device UUID public String getUUID(AdviewtiseData data){ List<PaircelUuid> UUIDs = data.getServiceUuids(); //ToastMakers.message(scannerActivity.getApplicationContext(), UUIDs.toString()); String UUIDx = UUIDs.get(0).getUuid().toString(); Log.e("UUID", " as list ->" + UUIDx); return UUIDx; } }; private BluetoothAdapter.LeScanCallback scanCallBackLe = new BluetoothAdapter.LeScanCallback() { @Oviewride public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) { final int RSSI = rssi; if (RSSI >= signalThreshold){ scanHandler.post(new Runnable() { @Oviewride public void run() { AdviewtiseData data = new AdviewtiseData.Builder() .addServiceUuid(PaircelUuid .fromString(UUID .nameUUIDFromBytes(scanRecord).toString())).build(); scannerActivity.addDevice(device, RSSI, getUUID(data)); } }); } } }; //For APIs less than 21, Returns Device UUID public String getUUID(AdviewtiseData data){ List<PaircelUuid> UUIDs = data.getServiceUuids(); //ToastMakers.message(scannerActivity.getApplicationContext(), UUIDs.toString()); String UUIDx = UUIDs.get(0).getUuid().toString(); Log.e("UUID", " as list ->" + UUIDx); return UUIDx; } 

    Paira APIs> 21:

     private ScanCallback mScanCallback = new ScanCallback() { @Oviewride public void onScanResult(int callbackType, final ScanResult result) { Log.i("callbackType", String.valueOf(callbackType)); Log.i("result", result.toString()); final int RSSI = result.getRssi(); if (RSSI>=signalThreshold) { scanHandler.post( new Runnable() { @Oviewride public void run() { BluetoothDevice device = result.getDevice(); scannerActivity.addDevice(device, result.getRssi(), getUUID(result)); } }); } } ...} //For APIs greater than 21, Returns Device UUID public String getUUID(ScanResult result){ String UUIDx = UUID .nameUUIDFromBytes(result.getScanRecord().getBytes()).toString(); ToastMakers.message(scannerActivity.getApplicationContext(), UUIDx); Log.e("UUID", " as String ->>" + UUIDx); return UUIDx; } } private ScanCallback mScanCallback = new ScanCallback() { @Oviewride public void onScanResult(int callbackType, final ScanResult result) { Log.i("callbackType", String.valueOf(callbackType)); Log.i("result", result.toString()); final int RSSI = result.getRssi(); if (RSSI>=signalThreshold) { scanHandler.post( new Runnable() { @Oviewride public void run() { BluetoothDevice device = result.getDevice(); scannerActivity.addDevice(device, result.getRssi(), getUUID(result)); } }); } } ...} //For APIs greater than 21, Returns Device UUID public String getUUID(ScanResult result){ String UUIDx = UUID .nameUUIDFromBytes(result.getScanRecord().getBytes()).toString(); ToastMakers.message(scannerActivity.getApplicationContext(), UUIDx); Log.e("UUID", " as String ->>" + UUIDx); return UUIDx; } }); private ScanCallback mScanCallback = new ScanCallback() { @Oviewride public void onScanResult(int callbackType, final ScanResult result) { Log.i("callbackType", String.valueOf(callbackType)); Log.i("result", result.toString()); final int RSSI = result.getRssi(); if (RSSI>=signalThreshold) { scanHandler.post( new Runnable() { @Oviewride public void run() { BluetoothDevice device = result.getDevice(); scannerActivity.addDevice(device, result.getRssi(), getUUID(result)); } }); } } ...} //For APIs greater than 21, Returns Device UUID public String getUUID(ScanResult result){ String UUIDx = UUID .nameUUIDFromBytes(result.getScanRecord().getBytes()).toString(); ToastMakers.message(scannerActivity.getApplicationContext(), UUIDx); Log.e("UUID", " as String ->>" + UUIDx); return UUIDx; } } private ScanCallback mScanCallback = new ScanCallback() { @Oviewride public void onScanResult(int callbackType, final ScanResult result) { Log.i("callbackType", String.valueOf(callbackType)); Log.i("result", result.toString()); final int RSSI = result.getRssi(); if (RSSI>=signalThreshold) { scanHandler.post( new Runnable() { @Oviewride public void run() { BluetoothDevice device = result.getDevice(); scannerActivity.addDevice(device, result.getRssi(), getUUID(result)); } }); } } ...} //For APIs greater than 21, Returns Device UUID public String getUUID(ScanResult result){ String UUIDx = UUID .nameUUIDFromBytes(result.getScanRecord().getBytes()).toString(); ToastMakers.message(scannerActivity.getApplicationContext(), UUIDx); Log.e("UUID", " as String ->>" + UUIDx); return UUIDx; } 

    Consegui obter um UUID de 128 bits de qualquer dispositivo usando este código. 🙂

    Você pode usair o padrão Android BluetoothGattCairacteristic apis como getFloatValue (int formatType, int offset), getIntValue (int formatType, int offset), getStringValue (int offset) ..refero muito bom tutorial do site do desenvolvedor Android aqui

      if (UUID_HEART_RATE_MEASUREMENT.equals(chairacteristic.getUuid())) { int flag = chairacteristic.getProperties(); int format = -1; if ((flag & 0x01) != 0) { format = BluetoothGattChairacteristic.FORMAT_UINT16; Log.d(TAG, "Heairt rate format UINT16."); } else { format = BluetoothGattChairacteristic.FORMAT_UINT8; Log.d(TAG, "Heairt rate format UINT8."); } final int heairtRate = chairacteristic.getIntValue(format, 1); Log.d(TAG, "Received heairt rate: " + heairtRate); intent.putExtra(EXTRA_DATA, String.valueOf(heairtRate)); } }  if (UUID_HEART_RATE_MEASUREMENT.equals(chairacteristic.getUuid())) { int flag = chairacteristic.getProperties(); int format = -1; if ((flag & 0x01) != 0) { format = BluetoothGattChairacteristic.FORMAT_UINT16; Log.d(TAG, "Heairt rate format UINT16."); } else { format = BluetoothGattChairacteristic.FORMAT_UINT8; Log.d(TAG, "Heairt rate format UINT8."); } final int heairtRate = chairacteristic.getIntValue(format, 1); Log.d(TAG, "Received heairt rate: " + heairtRate); intent.putExtra(EXTRA_DATA, String.valueOf(heairtRate)); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.