voidonLeScan(finalBluetoothDevice device,intrssi,byte[] scanRecord) {finalIBeaconClass.IBeacon ibeacon = IBeaconClass.fromScanData(device, rssi, scanRecord);if(ibeacon ==null)return;try{
String strTemp = StringUtil.bytesToHexString(scanRecord);
Logger.error(TAG, strTemp.length() +"=长度,回调方法-onLeScan()="+ strTemp);//0201061aff4c000215fda50693a4e24fb1afcfc6eb07647825000a0007c5090942523531343633310b1642523d6400cdff003ab100000000000000000000if(!TextUtils.isEmpty(strTemp)) {
String usefulData = strTemp.substring(86,106);//4252 3d6400cdff003a9eLogger.error(TAG, usefulData.length() +"=长度,回调方法-onLeScan()截取有用数据usefulData="+ usefulData);// String serviceID1 = usefulData.substring(2);// String serviceID = usefulData.substring(2, 4);// if (serviceID.equals("52")) {String strVersion = usefulData.substring(4,6);intintVersion = Integer.parseInt(strVersion,16);
String strPower = usefulData.substring(6,8);intintPower = Integer.parseInt(strPower,16);
Logger.error(TAG, strVersion +"=strVersion回调方法-onLeScan(),版本值intVersion="+ intVersion);
Logger.error(TAG, strPower +"=strPower回调方法-onLeScan(),电量值intPower="+ intPower);if(intPower >0) {
ibeacon.version = intVersion;
ibeacon.power = intPower;
runOnUiThread(newRunnable() {
@Overridepublicvoidrun() {
adapter.addDevice(ibeacon);
}
});
}// }}
}catch(Exception e) {
Logger.error(TAG,"解析蓝牙数据出错="+ e);
}
}