0
我有一个问题,Android的BLE扫描,我没有得到扫描设备找到的全名,我只得到第一个字母,你有任何想法如何解决这个问题?扫描Ble Android/getName()或设备不完整或无效
我与它支持BLE
这是一个7.0牛轧设备的工作是我的代码的一部分:
mBluetoothScanner = mBluetoothAdapter.getBluetoothLeScanner();
settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER)
.build();
if (Build.VERSION.SDK_INT >= 21) {
mScanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
messageLog.error("onScanResult");
BluetoothDevice btDevice = null;
if (Build.VERSION.SDK_INT >= 21) {
btDevice = result.getDevice();
messageLog.error("btDevice : " + btDevice.getName() + "|" + btDevice.getAddress() + "|" + Arrays.toString(btDevice.getUuids()));
}
if (btDevice != null && btDevice.getName() != null && !isInDeviceList(btDevice))
mDeviceList.add(btDevice);
}
@Override
public void onBatchScanResults(List<ScanResult> results) {
}
@Override
public void onScanFailed(int errorCode) {
Log.e("Scan Failed", "Error Code: " + errorCode);
}
};
}
随着btDevice.getName()我只得到的第一个字母设备扫描,这是我的错,还是来自Android BLE API?
谢谢,我会尝试更改固件中的名称,我会告诉你它是否正常工作。我试过了“result.getScanRecord()”,我已经设法得到8个第一个字母,你认为它是固定的字节数? – dabbu
谢谢先生:)我已经使用result.getScanRecord()而不是getName并在固件中更改名称,祝您有美好的一天! – dabbu