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