Open yemh111 opened 3 years ago
Yes, it also happens to me, I found the same thing with a data logger ble device, in the end I scan all the peripherals and read all the scan records one by one; if the peripherial scan record 'matches' desired value call my function...
U use delegate onScanning instead onScanFinisced, in this way you see the peripherals as they are found and not all together at the end;
My example ...
@Override
public void onScanning(BleDevice bleDevice) {
byte[] scanRecord = bleDevice.getScanRecord();
byte[] Manufacturingdataversion = {scanRecord[2]};
....
if(Manufacturingdataversion == Costant.manufacturer) {
add_device(bleDevice)
}
}
}
always in my case ... Adverstising string have precise lenght ( 26 bytes for me ) and start at byte with certain value '-1' (128 decimal)
int lenghtadvstring = 26;
private byte[] getAdvRecord(byte[] scanrecord) {
int counter = 0;
for(byte singlebyte: scanrecord) {
counter ++;
if(singlebyte == -1) {
return Arrays.copyOfRange(scanrecord,counter,counter + lenghtadvstring);
}
}
return new byte[] {};
}
写入以下内容有的设备报错 byte[] data = new byte[10]; Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); data[0] = (byte)year; data[1] = (byte)((year >> 8) & 0xFF); data[2] = (byte)(cal.get(Calendar.MONTH) + 1); data[3] = (byte)cal.get(Calendar.DAY_OF_MONTH); data[4] = (byte)cal.get(Calendar.HOUR_OF_DAY); data[5] = (byte)cal.get(Calendar.MINUTE); data[6] = (byte)cal.get(Calendar.SECOND); data[7] = (byte)((cal.get(Calendar.DAY_OF_WEEK) + 5) % 7 + 1); // Rotate data[8] = (byte)(cal.get(Calendar.MILLISECOND)*256/1000); // Fractions256 data[9] = 0x01;
GattException{gattStatus=128} BleException { code=101, description='Gatt Exception Occurred! '}