android.bluetooth.le.ScanResult Java Examples
The following examples show how to use
android.bluetooth.le.ScanResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From Mi365Locker with GNU General Public License v3.0 | 9 votes |
@Override public void onScanResult(int callbackType, ScanResult result) { super.onScanResult(callbackType, result); BluetoothDevice newDevice = result.getDevice(); int newRssi = result.getRssi(); String device_name = newDevice.getName(); String device_address = newDevice.getAddress(); if(device_name == null) { return; } DeviceConnection dev = devices_connections.get(device_address); if(dev != null) { devicesAdapter.update(newDevice, newRssi, dev.getState()); } else { devicesAdapter.update(newDevice, newRssi, RxBleConnection.RxBleConnectionState.DISCONNECTED); } String mDeviceAddress = newDevice.getAddress(); add_device_to_attack(mDeviceAddress); }
Example #2
Source File: PeripheralScannerTest.java From bitgatt with Mozilla Public License 2.0 | 8 votes |
@Test public void testConnectionAlreadyInMapDisconnectedScanResult() { MockScanResultProvider provider = new MockScanResultProvider(10, -167, -40); peripheralScanner.addRssiFilter(-10); ScanResult result = provider.getAllResults().get(0); FitbitBluetoothDevice device = new FitbitBluetoothDevice(result.getDevice()); GattConnection conn = new GattConnection(device, mockLooper); conn.setMockMode(true); conn.setState(GattState.DISCONNECTED); gatt.getConnectionMap().put(device, conn); NoOpGattCallback cb = new NoOpGattCallback() { @Override public void onBluetoothPeripheralDiscovered(@NonNull GattConnection connection) { Assert.assertEquals(conn, connection); gatt.unregisterGattEventListener(this); } }; gatt.registerGattEventListener(cb); peripheralScanner.populateMockScanResultIndividualValue(ScanSettings.CALLBACK_TYPE_FIRST_MATCH, result); }
Example #3
Source File: RileyLinkBLEScanActivity.java From AndroidAPS with GNU Affero General Public License v3.0 | 8 votes |
private boolean addDevice(ScanResult result) { BluetoothDevice device = result.getDevice(); List<ParcelUuid> serviceUuids = result.getScanRecord().getServiceUuids(); if (serviceUuids == null || serviceUuids.size() == 0) { Log.v(TAG, "Device " + device.getAddress() + " has no serviceUuids (Not RileyLink)."); } else if (serviceUuids.size() > 1) { Log.v(TAG, "Device " + device.getAddress() + " has too many serviceUuids (Not RileyLink)."); } else { String uuid = serviceUuids.get(0).getUuid().toString().toLowerCase(); if (uuid.equals(GattAttributes.SERVICE_RADIO)) { Log.i(TAG, "Found RileyLink with address: " + device.getAddress()); mLeDeviceListAdapter.addDevice(result); return true; } else { Log.v(TAG, "Device " + device.getAddress() + " has incorrect uuid (Not RileyLink)."); } } return false; }
Example #4
Source File: ScanResultAdapter.java From connectivity-samples with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View view, ViewGroup parent) { // Reuse an old view if we can, otherwise create a new one. if (view == null) { view = mInflater.inflate(R.layout.listitem_scanresult, null); } TextView deviceNameView = (TextView) view.findViewById(R.id.device_name); TextView deviceAddressView = (TextView) view.findViewById(R.id.device_address); TextView lastSeenView = (TextView) view.findViewById(R.id.last_seen); ScanResult scanResult = mArrayList.get(position); String name = scanResult.getDevice().getName(); if (name == null) { name = mContext.getResources().getString(R.string.no_name); } deviceNameView.setText(name); deviceAddressView.setText(scanResult.getDevice().getAddress()); lastSeenView.setText(getTimeSinceString(mContext, scanResult.getTimestampNanos())); return view; }
Example #5
Source File: BluetoothCentralTest.java From blessed-android with MIT License | 6 votes |
@Test public void scanForPeripheralsTest() throws Exception { application.grantPermissions(Manifest.permission.ACCESS_COARSE_LOCATION); central.scanForPeripherals(); verify(scanner).startScan(anyList(), any(ScanSettings.class), any(ScanCallback.class)); // Grab the scan callback that is used Field field = BluetoothCentral.class.getDeclaredField("scanByServiceUUIDCallback"); field.setAccessible(true); ScanCallback scanCallback = (ScanCallback) field.get(central); // Fake scan result ScanResult scanResult = mock(ScanResult.class); BluetoothDevice device = mock(BluetoothDevice.class); when(device.getAddress()).thenReturn("00:00:00:00"); when(scanResult.getDevice()).thenReturn(device); scanCallback.onScanResult(CALLBACK_TYPE_ALL_MATCHES, scanResult); // See if we get it back ArgumentCaptor<BluetoothPeripheral> bluetoothPeripheralCaptor = ArgumentCaptor.forClass(BluetoothPeripheral.class); ArgumentCaptor<ScanResult> scanResultCaptor = ArgumentCaptor.forClass(ScanResult.class); verify(callback).onDiscoveredPeripheral(bluetoothPeripheralCaptor.capture(), scanResultCaptor.capture()); assertEquals(scanResultCaptor.getValue(), scanResult); assertEquals(bluetoothPeripheralCaptor.getValue().getAddress(), "00:00:00:00"); }
Example #6
Source File: MockLollipopScanner.java From bitgatt with Mozilla Public License 2.0 | 6 votes |
/** * Callback reporting an LE scan result. */ public void onScanResult(final ScanResult scanResult) { if (VDBG) Log.d(TAG, "onScanResult() - " + scanResult.toString()); // Check null in case the scan has been stopped synchronized (this) { if (mScannerId <= 0) return; } Handler handler = mHandler; handler.post(new Runnable() { @Override public void run() { mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES, scanResult); } }); }
Example #7
Source File: MockLollipopScanner.java From bitgatt with Mozilla Public License 2.0 | 6 votes |
public void onFoundOrLost(final boolean onFound, final ScanResult scanResult) { if (VDBG) { Log.d(TAG, "onFoundOrLost() - onFound = " + onFound + " " + scanResult.toString()); } // Check null in case the scan has been stopped synchronized (this) { if (mScannerId <= 0) { return; } } Handler handler = mHandler; handler.post(new Runnable() { @Override public void run() { if (onFound) { mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_FIRST_MATCH, scanResult); } else { mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_MATCH_LOST, scanResult); } } }); }
Example #8
Source File: MockScanResultProvider.java From bitgatt with Mozilla Public License 2.0 | 6 votes |
MockScanResultProvider(int numberOfMockResults, int minRssi, int maxRssi){ rnd = new Random(System.currentTimeMillis()); scanResults = new ArrayList<>(numberOfMockResults); serviceDataMap = new HashMap<>(); byte[] randomData = new byte[16]; rnd.nextBytes(randomData); serviceDataMap.put(new ParcelUuid(UUID.fromString("adabfb00-6e7d-4601-bda2-bffaa68956ba")), randomData); for(int i=0; i < numberOfMockResults; i++) { ScanResult result = Mockito.mock(ScanResult.class); BluetoothDevice device = Mockito.mock(BluetoothDevice.class); ScanRecord record = Mockito.mock(ScanRecord.class); Mockito.when(device.getAddress()).thenReturn(randomMACAddress()); Mockito.when(device.getName()).thenReturn("foobar-" + String.valueOf(i)); Mockito.when(result.getDevice()).thenReturn(device); Mockito.when(result.getRssi()).thenReturn(-1 * (rnd.nextInt(Math.abs(minRssi) + 1 - Math.abs(maxRssi)) + Math.abs(maxRssi))); Assert.assertTrue("Rssi is less than zero", result.getRssi() < 0); Mockito.when(record.getDeviceName()).thenReturn("foobar-" + String.valueOf(i)); Mockito.when(record.getServiceData()).thenReturn(serviceDataMap); scanResults.add(result); } }
Example #9
Source File: BluetoothLeDeviceFilter.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** @hide */ @Override @Nullable public String getDeviceDisplayName(ScanResult sr) { if (mRenameBytesFrom < 0 && mRenameNameFrom < 0) { return getDeviceDisplayNameInternal(sr.getDevice()); } final StringBuilder sb = new StringBuilder(TextUtils.emptyIfNull(mRenamePrefix)); if (mRenameBytesFrom >= 0) { final byte[] bytes = sr.getScanRecord().getBytes(); int startInclusive = mRenameBytesFrom; int endInclusive = mRenameBytesFrom + mRenameBytesLength -1; int initial = mRenameBytesReverseOrder ? endInclusive : startInclusive; int step = mRenameBytesReverseOrder ? -1 : 1; for (int i = initial; startInclusive <= i && i <= endInclusive; i += step) { sb.append(Byte.toHexString(bytes[i], true)); } } else { sb.append( getDeviceDisplayNameInternal(sr.getDevice()) .substring(mRenameNameFrom, mRenameNameFrom + mRenameNameLength)); } return sb.append(TextUtils.emptyIfNull(mRenameSuffix)).toString(); }
Example #10
Source File: DiscoverFragment.java From bluetooth with Apache License 2.0 | 6 votes |
@Override public void onScanResult(int callbackType, ScanResult result) { super.onScanResult(callbackType, result); if (result == null || result.getDevice() == null) { logthis("The data result is empty or no data"); } else { //should have useful info. //name StringBuilder builder = new StringBuilder("Name: ").append(result.getDevice().getName()); //address builder.append("\n").append("address: ").append(result.getDevice().getAddress()); //data builder.append("\n").append("data: ").append(new String(result.getScanRecord().getServiceData(result.getScanRecord().getServiceUuids().get(0)), Charset.forName("UTF-8"))); logthis(builder.toString()); } }
Example #11
Source File: BleScanner.java From EasyBle with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private boolean hasResultByFilterUuids(ScanResult result) { if (mServiceUuids == null || mServiceUuids.length <= 0) {//no filtered uuids return true; } ScanRecord scanRecord = result.getScanRecord(); if (scanRecord == null) { return false; } List<ParcelUuid> serviceUuidList = new ArrayList<>(); for (UUID uuid : mServiceUuids) { serviceUuidList.add(new ParcelUuid(uuid)); } List<ParcelUuid> scanServiceUuids = result.getScanRecord().getServiceUuids(); return scanServiceUuids != null && scanServiceUuids.containsAll(serviceUuidList); }
Example #12
Source File: ScanResultAdapter.java From android-BluetoothAdvertisements with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View view, ViewGroup parent) { // Reuse an old view if we can, otherwise create a new one. if (view == null) { view = mInflater.inflate(R.layout.listitem_scanresult, null); } TextView deviceNameView = (TextView) view.findViewById(R.id.device_name); TextView deviceAddressView = (TextView) view.findViewById(R.id.device_address); TextView lastSeenView = (TextView) view.findViewById(R.id.last_seen); ScanResult scanResult = mArrayList.get(position); String name = scanResult.getDevice().getName(); if (name == null) { name = mContext.getResources().getString(R.string.no_name); } deviceNameView.setText(name); deviceAddressView.setText(scanResult.getDevice().getAddress()); lastSeenView.setText(getTimeSinceString(mContext, scanResult.getTimestampNanos())); return view; }
Example #13
Source File: RileyLinkBLEScanActivity.java From AndroidAPS with GNU Affero General Public License v3.0 | 6 votes |
@Override public void onBatchScanResults(final List<ScanResult> results) { runOnUiThread(() -> { boolean added = false; for (ScanResult result : results) { if (addDevice(result)) added = true; } if (added) mLeDeviceListAdapter.notifyDataSetChanged(); }); }
Example #14
Source File: ScannerFragment.java From connectivity-samples with Apache License 2.0 | 5 votes |
@Override public void onBatchScanResults(List<ScanResult> results) { super.onBatchScanResults(results); for (ScanResult result : results) { mAdapter.add(result); } mAdapter.notifyDataSetChanged(); }
Example #15
Source File: ScannerFragment.java From connectivity-samples with Apache License 2.0 | 5 votes |
@Override public void onScanResult(int callbackType, ScanResult result) { super.onScanResult(callbackType, result); mAdapter.add(result); mAdapter.notifyDataSetChanged(); }
Example #16
Source File: ScanResultAdapter.java From connectivity-samples with Apache License 2.0 | 5 votes |
/** * Add a ScanResult item to the adapter if a result from that device isn't already present. * Otherwise updates the existing position with the new ScanResult. */ public void add(ScanResult scanResult) { int existingPosition = getPosition(scanResult.getDevice().getAddress()); if (existingPosition >= 0) { // Device is already in list, update its record. mArrayList.set(existingPosition, scanResult); } else { // Add new Device's ScanResult to list. mArrayList.add(scanResult); } }
Example #17
Source File: BluetoothCentralTest.java From blessed-android with MIT License | 5 votes |
@Test public void autoconnectTestUnCached() throws Exception { application.grantPermissions(Manifest.permission.ACCESS_COARSE_LOCATION); BluetoothDevice device = mock(BluetoothDevice.class); when(device.getAddress()).thenReturn("12:23:34:98:76:54"); when(device.getType()).thenReturn(BluetoothDevice.DEVICE_TYPE_LE); bluetoothAdapter.addDevice(device); BluetoothPeripheral peripheral = mock(BluetoothPeripheral.class); when(peripheral.getAddress()).thenReturn("12:23:34:98:76:54"); when(peripheral.getType()).thenReturn(BluetoothDevice.DEVICE_TYPE_UNKNOWN); central.autoConnectPeripheral(peripheral, peripheralCallback); verify(peripheral, never()).autoConnect(); verify(scanner).startScan(anyList(), any(ScanSettings.class), any(ScanCallback.class)); // Grab the scan callback that is used Field field = BluetoothCentral.class.getDeclaredField("autoConnectScanCallback"); field.setAccessible(true); ScanCallback scanCallback = (ScanCallback) field.get(central); // Fake scan result ScanResult scanResult = mock(ScanResult.class); when(scanResult.getDevice()).thenReturn(device); scanCallback.onScanResult(CALLBACK_TYPE_ALL_MATCHES, scanResult); verify(peripheral).connect(); }
Example #18
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override public void onScanResult(int callbackType, ScanResult result) { super.onScanResult(callbackType, result); if( result == null || result.getDevice() == null || TextUtils.isEmpty(result.getDevice().getName()) ) return; StringBuilder builder = new StringBuilder( result.getDevice().getName() ); builder.append("\n").append(new String(result.getScanRecord().getServiceData(result.getScanRecord().getServiceUuids().get(0)), Charset.forName("UTF-8"))); mText.setText(builder.toString()); }
Example #19
Source File: StartupBroadcastReceiver.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { LogManager.d(TAG, "onReceive called in startup broadcast receiver"); if (android.os.Build.VERSION.SDK_INT < 18) { LogManager.w(TAG, "Not starting up beacon service because we do not have API version 18 (Android 4.3). We have: %s", android.os.Build.VERSION.SDK_INT); return; } BeaconManager beaconManager = BeaconManager.getInstanceForApplication(context.getApplicationContext()); if (beaconManager.isAnyConsumerBound() || beaconManager.getScheduledScanJobsEnabled()) { int bleCallbackType = intent.getIntExtra(BluetoothLeScanner.EXTRA_CALLBACK_TYPE, -1); // e.g. ScanSettings.CALLBACK_TYPE_FIRST_MATCH if (bleCallbackType != -1) { LogManager.d(TAG, "Passive background scan callback type: "+bleCallbackType); LogManager.d(TAG, "got Android O background scan via intent"); int errorCode = intent.getIntExtra(BluetoothLeScanner.EXTRA_ERROR_CODE, -1); // e.g. ScanCallback.SCAN_FAILED_INTERNAL_ERROR if (errorCode != -1) { LogManager.w(TAG, "Passive background scan failed. Code; "+errorCode); } ArrayList<ScanResult> scanResults = intent.getParcelableArrayListExtra(BluetoothLeScanner.EXTRA_LIST_SCAN_RESULT); ScanJobScheduler.getInstance().scheduleAfterBackgroundWakeup(context, scanResults); } else if (intent.getBooleanExtra("wakeup", false)) { LogManager.d(TAG, "got wake up intent"); } else { LogManager.d(TAG, "Already started. Ignoring intent: %s of type: %s", intent, intent.getStringExtra("wakeup")); } } else { LogManager.d(TAG, "No consumers are bound. Ignoring broadcast receiver."); } }
Example #20
Source File: BluetoothGlucoseMeter.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@TargetApi(21) private void initScanCallback() { Log.d(TAG, "init v21 ScanCallback()"); // v21 version if (Build.VERSION.SDK_INT >= 21) { mScanCallback = new ScanCallback() { @Override public void onScanResult(int callbackType, ScanResult result) { Log.i(TAG, "onScanResult result: " + result.toString()); final BluetoothDevice btDevice = result.getDevice(); scanLeDevice(false); // stop scanning connect(btDevice.getAddress()); } @Override public void onBatchScanResults(List<ScanResult> results) { for (ScanResult sr : results) { Log.i("ScanResult - Results", sr.toString()); } } @Override public void onScanFailed(int errorCode) { Log.e(TAG, "Scan Failed Error Code: " + errorCode); if (errorCode == 1) { Log.e(TAG, "Already Scanning: "); // + isScanning); //isScanning = true; } else if (errorCode == 2) { // reset bluetooth? } } }; } }
Example #21
Source File: BluetoothSettingsFragment.java From openScale with GNU General Public License v3.0 | 5 votes |
private void onDeviceFound(final ScanResult bleScanResult) { BluetoothDevice device = bleScanResult.getDevice(); if (device.getName() == null || foundDevices.containsKey(device.getAddress())) { return; } BluetoothDeviceView deviceView = new BluetoothDeviceView(getContext()); deviceView.setDeviceName(formatDeviceName(bleScanResult.getDevice())); BluetoothCommunication btDevice = BluetoothFactory.createDeviceDriver(getContext(), device.getName()); if (btDevice != null) { Timber.d("Found supported device %s (driver: %s)", formatDeviceName(device), btDevice.driverName()); deviceView.setDeviceAddress(device.getAddress()); deviceView.setIcon(R.drawable.ic_bluetooth_device_supported); deviceView.setSummaryText(btDevice.driverName()); } else { Timber.d("Found unsupported device %s", formatDeviceName(device)); deviceView.setIcon(R.drawable.ic_bluetooth_device_not_supported); deviceView.setSummaryText(getString(R.string.label_bt_device_no_support)); deviceView.setEnabled(false); if (OpenScale.DEBUG_MODE) { deviceView.setEnabled(true); deviceView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getDebugInfo(device); } }); } } foundDevices.put(device.getAddress(), btDevice != null ? device : null); deviceListView.addView(deviceView); }
Example #22
Source File: EddystoneScannerService.java From nearby-beacons with MIT License | 5 votes |
private void processResult(ScanResult result) { ScanRecord record = result.getScanRecord(); if (record == null) { Log.w(TAG, "Invalid scan record."); return; } final byte[] data = record.getServiceData(UID_SERVICE); if (data == null) { Log.w(TAG, "Invalid Eddystone scan result."); return; } final String deviceAddress = result.getDevice().getAddress(); final int rssi = result.getRssi(); byte frameType = data[0]; switch (frameType) { case TYPE_UID: mCallbackHandler.post(new Runnable() { @Override public void run() { processUidPacket(deviceAddress, rssi, data); } }); break; case TYPE_TLM: case TYPE_URL: //Do nothing, ignoring these return; default: Log.w(TAG, "Invalid Eddystone scan result."); } }
Example #23
Source File: PeripheralScannerTest.java From bitgatt with Mozilla Public License 2.0 | 5 votes |
@Test public void testConnectionAlreadyInMapScannedPropertiesChangedScanRecord() { MockScanResultProvider provider = new MockScanResultProvider(10, -167, -40); peripheralScanner.addRssiFilter(-10); ScanResult result = provider.getAllResults().get(0); FitbitBluetoothDevice device = new FitbitBluetoothDevice(result.getDevice()); device.setScanRecord(result.getScanRecord()); GattConnection conn = new GattConnection(device, mockLooper); conn.setMockMode(true); conn.setState(GattState.DISCONNECTED); gatt.getConnectionMap().put(device, conn); FitbitBluetoothDevice.DevicePropertiesChangedCallback propChanged = device1 -> Assert.assertNull(device1.getScanRecord()); device.addDevicePropertiesChangedListener(propChanged); device.setScanRecord(null); device.removeDevicePropertiesChangedListener(propChanged); NoOpGattCallback cb = new NoOpGattCallback() { @Override public void onBluetoothPeripheralDiscovered(@NonNull GattConnection connection) { Assert.assertEquals(conn, connection); gatt.unregisterGattEventListener(this); } }; gatt.registerGattEventListener(cb); gatt.addScannedDevice(device); }
Example #24
Source File: MockLollipopScanner.java From bitgatt with Mozilla Public License 2.0 | 5 votes |
public void onBatchScanResults(final List<ScanResult> results) { Handler handler = mHandler; handler.post(new Runnable() { @Override public void run() { mScanCallback.onBatchScanResults(results); } }); }
Example #25
Source File: BluetoothLeDeviceFilter.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** @hide */ @Override public boolean matches(ScanResult device) { boolean result = matches(device.getDevice()) && (mRawDataFilter == null || BitUtils.maskedEquals(device.getScanRecord().getBytes(), mRawDataFilter, mRawDataFilterMask)); if (DEBUG) Log.i(LOG_TAG, "matches(this = " + this + ", device = " + device + ") -> " + result); return result; }
Example #26
Source File: RileyLinkBLEScanActivity.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onScanResult(int callbackType, final ScanResult scanRecord) { Log.d(TAG, scanRecord.toString()); runOnUiThread(() -> { if (addDevice(scanRecord)) mLeDeviceListAdapter.notifyDataSetChanged(); }); }
Example #27
Source File: Device.java From easyble-x with Apache License 2.0 | 5 votes |
public void readFromParcel(Parcel in) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.scanResult = in.readParcelable(ScanResult.class.getClassLoader()); } int scanRecordLen = in.readInt(); if (scanRecordLen > 0) { this.scanRecord = new byte[scanRecordLen]; in.readByteArray(this.scanRecord); } String inName = in.readString(); this.name = inName == null ? "" : inName; this.address = Objects.requireNonNull(in.readString()); this.rssi = in.readInt(); this.connectionState = ConnectionState.valueOf(in.readString()); }
Example #28
Source File: ScannerFragment.java From android-BluetoothAdvertisements with Apache License 2.0 | 5 votes |
@Override public void onScanResult(int callbackType, ScanResult result) { super.onScanResult(callbackType, result); mAdapter.add(result); mAdapter.notifyDataSetChanged(); }
Example #29
Source File: BLEService.java From android_wear_for_ios with MIT License | 5 votes |
@Override public void onScanResult(int callbackType, android.bluetooth.le.ScanResult result) { Log.d(TAG_LOG, "scan result" + result.toString()); BluetoothDevice device = result.getDevice(); if (!is_connect) { Log.d(TAG_LOG, "is connect"); if (device != null) { Log.d(TAG_LOG, "device "); if (!is_reconnect && device.getName() != null) { if(device.getName().equals("Blank")) { // if(device.getName().equals("BLE Utility")) { Log.d(TAG_LOG, "getname "); iphone_uuid = device.getAddress().toString(); is_connect = true; bluetooth_gatt = result.getDevice().connectGatt(getApplicationContext(), false, bluetooth_gattCallback); } } else if (is_reconnect && device.getAddress().toString().equals(iphone_uuid)) { if(!is_time) { Log.d(TAG_LOG, "-=-=-=-=-=-=-=-=-=- timer start:: -=-==-=-=-=-=-=-==--=-=-=-==-=-=-=-=-=-=-=-"); start_time = System.currentTimeMillis(); is_time = true; }else if(System.currentTimeMillis() - start_time > 5000){ Log.d(TAG_LOG, "-=-=-=-=-=-=-=-=-=- reconnect:: -=-==-=-=-=-=-=-==--=-=-=-==-=-=-=-=-=-=-=-"); is_connect = true; is_reconnect = false; bluetooth_gatt = device.connectGatt(getApplicationContext(), true, bluetooth_gattCallback); } } else { Log.d(TAG_LOG, "skip:: "); skip_count++; } } } }
Example #30
Source File: RileyLinkBLEScanActivity.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
public void addDevice(ScanResult result) { if (!mLeDevices.contains(result.getDevice())) { mLeDevices.add(result.getDevice()); } rileyLinkDevices.put(result.getDevice(), result.getRssi()); notifyDataSetChanged(); }