android - BLE Scan Record Explaination -


i trying uuid, major, minor ids ble advertisement received in form of byte[]. have used suggested code here unable understand output of parser. here output 1 of ble devices

length: 2 type : 1 data : 6,    length: 26 type : -1 data : 76 0 2 21 -9 -126 109 -90 79 -94 78 -104 -128 36 -68 91 113 -32 -119 62 12 -121 -79 52 -77,   length: 8 type : 9 data : 75 111 110 116 97 107 116,   length: 2 type : 10 data : -12,   length: 10 type : 22 data : 13 -48 117 76 106 98 50 55 100 

how understand field contains uuid , major , minor ids? . read same post on stackoverflow 0x07 indicates uuid, how understand how type 0x07 above data.

this first question here apologies mistakes in way question asked.

here code in case:

public void printscanrecord (byte[] scanrecord) {     // print raw bytes        try {         string decodedrecord = new string(scanrecord,"utf-8");         log.d("debug","decoded string : " + bytearraytostring(scanrecord));     } catch (unsupportedencodingexception e) {         e.printstacktrace();     }      // parse data bytes individual records     list<adrecord> records = adrecord.parsescanrecord(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);   (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> parsescanrecord(byte[] scanrecord) {         list<adrecord> records = new arraylist<adrecord>();          int index = 0;         while (index < scanrecord.length) {             int length = scanrecord[index++];             //done once run out of records             if (length == 0) break;              int type = scanrecord[index];             //done if our record isn't 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;     }      // ... } 

i suppose type values explained in: generic access profile web page

i made parser code find bottom of mybletest/blebase.java file.


Comments