public BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
// Called when new BLE device is discovered
// Broadcast intent is sent with following extras: device , rssi,
// additional advertise data
@Override
public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
Log.w("MPC-100", "CALL back lescan ..... >>>>>>>>> ......");
Intent broadcastIntent = new Intent(BluetoothLeServiceNew.ACTION_DEVICE_DISCOVERED);
broadcastIntent.putExtra(BluetoothLeServiceNew.DISCOVERED_DEVICE, device);
broadcastIntent.putExtra(BluetoothLeServiceNew.RSSI, rssi);
broadcastIntent.putExtra(BluetoothLeServiceNew.SCAN_RECORD, scanRecord);
sendBroadcast(broadcastIntent);
Log.i("MPC-100", "onLeScan - device: " + device.getName() + " / " + device.getAddress() + " - rssi: " + rssi);
if(device.getName().equals("mPM-100B")) {
mLeDeviceListAdapter.addDevice(device);
mLeDeviceListAdapter.notifyDataSetChanged();
}
}
};
ble통신 중입니다.. 장치 스캔시 특정이름만 검색해서 리스트뷰에 뿌릴려고 하는데요...
위처럼 하지 않으면 쓸데없는 장치까지 다 검색이 돼서요.ㅠㅠ
위에처럼 코딩하니 장치가 하나도 검색이 되질 않습니다.
if문을 제거하면 제대로 검색이 진행됩니다..^^
디바이스 이름은 "mPM-100B"가 맞습니다..
device는 BluetoothDevice 입니다.