當前位置: 首頁>>代碼示例>>Java>>正文


Java ScanResult.getRssi方法代碼示例

本文整理匯總了Java中android.bluetooth.le.ScanResult.getRssi方法的典型用法代碼示例。如果您正苦於以下問題:Java ScanResult.getRssi方法的具體用法?Java ScanResult.getRssi怎麽用?Java ScanResult.getRssi使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.bluetooth.le.ScanResult的用法示例。


在下文中一共展示了ScanResult.getRssi方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);
    BluetoothDevice device = result.getDevice();
    if ( device != null )
    {
        String msg = device.getName() + "\n" +"[RSSI : " + result.getRssi() + "dBm]" + device.getAddress();
        NLog.d( "onLeScan " + msg );

        /**
         * setting pen client control for ble
         */
            if(!temp.contains( device.getAddress() ))
            {
                NLog.d( "ACTION_FOUND onLeScan : " +device.getName() + " address : "+ device.getAddress()+", COD:" + device.getBluetoothClass());
                temp.add( device.getAddress());
                mNewDevicesArrayAdapter.add(msg);
            }
    }
}
 
開發者ID:NeoSmartpen,項目名稱:AndroidSDK2.0,代碼行數:21,代碼來源:DeviceListActivity.java

示例2: convertBleDevice

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public BleDevice convertBleDevice(ScanResult scanResult) {
    if (scanResult == null) {
        throw new IllegalArgumentException("scanResult can not be Null!");
    }
    BluetoothDevice bluetoothDevice = scanResult.getDevice();
    int rssi = scanResult.getRssi();
    ScanRecord scanRecord = scanResult.getScanRecord();
    byte[] bytes = null;
    if (scanRecord != null)
        bytes = scanRecord.getBytes();
    long timestampNanos = scanResult.getTimestampNanos();
    return new BleDevice(bluetoothDevice, rssi, bytes, timestampNanos);
}
 
開發者ID:Jasonchenlijian,項目名稱:FastBle,代碼行數:15,代碼來源:BleManager.java

示例3: ScanResultCompat

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
ScanResultCompat(ScanResult result) {
    mDevice = result.getDevice();
    mScanRecord = new ScanRecordCompat(result.getScanRecord());
    mRssi = result.getRssi();
    mTimestampNanos = result.getTimestampNanos();
}
 
開發者ID:joerogers,項目名稱:BluetoothCompat,代碼行數:8,代碼來源:ScanResultCompat.java

示例4: beaconFromScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
protected static Beacon beaconFromScanResult(ScanResult scanResult) {
    ScanRecord scanRecord = scanResult.getScanRecord();
    if (scanRecord == null) {
        return null;
    }
    FrameType type;
    Integer txPower;
    double rssi = scanResult.getRssi();
    byte[] bytes = scanRecord.getServiceData(EDDYSTONE_SPEC);
    String identifier = scanResult.getDevice().getAddress();

    txPower = txPowerFromBytes(bytes);

    if (txPower != null) {
        Beacon beacon = new Beacon(rssi, txPower, identifier);
        beacon.parseScanResult(scanResult);
        return beacon;
    }

    return null;
}
 
開發者ID:BlueBiteLLC,項目名稱:eddystone-android,代碼行數:22,代碼來源:Beacon.java

示例5: createCallback

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
private static android.bluetooth.le.ScanCallback createCallback(ScanCallback scanCallback) {
    return new android.bluetooth.le.ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {

            BluetoothDevice device = result.getDevice();
            int rssi = result.getRssi();
            byte[] scanRecord = (result.getScanRecord() != null ? result.getScanRecord().getBytes() : null);
            scanCallback.onDeviceFound(device, rssi, scanRecord);

            super.onScanResult(callbackType, result);
        }

        @Override
        public void onBatchScanResults(List<ScanResult> results) {
            super.onBatchScanResults(results);
        }

        @Override
        public void onScanFailed(int errorCode) {
            super.onScanFailed(errorCode);
        }
    };
}
 
開發者ID:devicehive,項目名稱:android-ble,代碼行數:25,代碼來源:BleScannerL.java

示例6: ScanResultCompat

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
ScanResultCompat(ScanResult result) {
    mDevice = new BluetoothLeDevice(result.getDevice(), result.getRssi(), result.getScanRecord().getBytes(), System.currentTimeMillis());//result.getTimestampNanos()
    mScanRecord = new ScanRecordCompat(result.getScanRecord());
    mRssi = result.getRssi();
    mTimestampNanos = System.currentTimeMillis();//result.getTimestampNanos();
}
 
開發者ID:Twelvelines,項目名稱:AndroidMuseumBleManager,代碼行數:8,代碼來源:ScanResultCompat.java

示例7: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
     public void onScanResult(int callbackType, final ScanResult result) {
         //Log.i(TAG, "Scan Result:"+result.toString()); 

 		int connType = 3;
int addrType = 0;

String strAddr=result.getDevice().getAddress();
byte[] addr = stringToAddress(strAddr);

         byte[] data = result.getScanRecord().getBytes();
         int rssi = result.getRssi();
         
         advReportNative(connType, addrType, addr, data, rssi);
     }
 
開發者ID:blxble,項目名稱:mesh-core-on-android,代碼行數:16,代碼來源:JniCallbacks.java

示例8: processResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
private void processResult(ScanResult result) {
    Log.i(TAG, "New LE Device: " + result.getDevice().getName() + " @ " + result.getRssi());

    /*
     * Create a new beacon from the list of obtains AD structures
     * and pass it up to the main thread
     */
    TemperatureBeacon beacon = new TemperatureBeacon(result.getScanRecord(),
            result.getDevice().getAddress(),
            result.getRssi());
    mHandler.sendMessage(Message.obtain(null, 0, beacon));
}
 
開發者ID:ruipoliveira,項目名稱:livingCity-Android,代碼行數:13,代碼來源:BeaconLollipopActivity.java

示例9: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
@RequiresPermission(allOf = {
        Manifest.permission.BLUETOOTH,
        Manifest.permission.BLUETOOTH_ADMIN,
})
public void onScanResult(int callbackType, ScanResult result) {
    if (result.getScanRecord() == null) {
        return;
    }

    BluetoothDevice device = result.getDevice();
    String address = device.getAddress();
    ScannedPeripheral existingResult = results.get(address);
    if (existingResult != null) {
        existingResult.rssi = result.getRssi();
        return;
    }

    byte[] scanResponse = result.getScanRecord().getBytes();
    AdvertisingData advertisingData = AdvertisingData.parse(scanResponse);
    logger.info(BluetoothStack.LOG_TAG, "Found device " + device.getName() + " - " + address + " " + advertisingData);

    if (!peripheralCriteria.matches(advertisingData)) {
        return;
    }

    if (hasAddresses && !peripheralCriteria.peripheralAddresses.contains(address)) {
        return;
    }

    results.put(address, new ScannedPeripheral(device, advertisingData, result.getRssi()));

    if (results.size() >= peripheralCriteria.limit) {
        logger.info(BluetoothStack.LOG_TAG, "Discovery limit reached, concluding scan");
        onConcludeScan();
    }
}
 
開發者ID:hello,項目名稱:android-buruberi,代碼行數:38,代碼來源:LollipopLePeripheralScanner.java

示例10: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);
    final BluetoothDevice device = result.getDevice();
    final int rssi = result.getRssi();
    DeviceListDialog.this.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            addDevice(device, rssi);
        }
    });
}
 
開發者ID:miyakeryo,項目名稱:WDMD_Android,代碼行數:13,代碼來源:DeviceListDialog.java

示例11: processResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
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.");
    }
}
 
開發者ID:devunwired,項目名稱:nearby-beacons,代碼行數:33,代碼來源:EddystoneScannerService.java

示例12: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);
    Log.d("ni", "onScanResult");
    NDB beacon = new NDB(result.getRssi(), result.getDevice().getAddress(), result.getTimestampNanos());
    scanNDBTreeSet.add(beacon);
}
 
開發者ID:tallenintegsys,項目名稱:ADF,代碼行數:8,代碼來源:NDBScanner.java

示例13: BLEScanner

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
public BLEScanner(final Activity activity, int requestEnableBluetooth, @NonNull OnClosestChangedListener onClosestChangedListener) {
    mRequestEnableBluetooth = requestEnableBluetooth;
    mOnClosestChangedListener = onClosestChangedListener;
    init(activity);
    scanFilters = new ArrayList<>();
    scanFilters.add(new ScanFilter.Builder().setServiceUuid(EDDYSTONE_SERVICE_UUID).build());
    scanCallback = new ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {
            ScanRecord scanRecord = result.getScanRecord();
            if (scanRecord == null) {
                return;
            }

            String deviceAddress = result.getDevice().getAddress();
            Beacon beacon;
            if (!deviceToBeaconMap.containsKey(deviceAddress)) {
                beacon = new Beacon(deviceAddress, result.getRssi());
                deviceToBeaconMap.put(deviceAddress, beacon);
            } else {
                deviceToBeaconMap.get(deviceAddress).lastSeenTimestamp = System.currentTimeMillis();
                deviceToBeaconMap.get(deviceAddress).rssi = result.getRssi();
            }

            byte[] serviceData = scanRecord.getServiceData(EDDYSTONE_SERVICE_UUID);
            validateServiceData(deviceAddress, serviceData);

            findClosest();
        }

        @Override
        public void onScanFailed(int errorCode) {
            switch (errorCode) {
                case SCAN_FAILED_ALREADY_STARTED:
                    logErrorAndShowToast(activity, "SCAN_FAILED_ALREADY_STARTED");
                    break;
                case SCAN_FAILED_APPLICATION_REGISTRATION_FAILED:
                    logErrorAndShowToast(activity, "SCAN_FAILED_APPLICATION_REGISTRATION_FAILED");
                    break;
                case SCAN_FAILED_FEATURE_UNSUPPORTED:
                    logErrorAndShowToast(activity, "SCAN_FAILED_FEATURE_UNSUPPORTED");
                    break;
                case SCAN_FAILED_INTERNAL_ERROR:
                    logErrorAndShowToast(activity, "SCAN_FAILED_INTERNAL_ERROR");
                    break;
                default:
                    logErrorAndShowToast(activity, "Scan failed, unknown error code");
                    break;
            }
        }
    };
}
 
開發者ID:etsy,項目名稱:divertsy-client,代碼行數:53,代碼來源:BLEScanner.java

示例14: BLEMeasurementsRecord

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public BLEMeasurementsRecord(List<ScanResult> scanResults) {
    super(new RecordInfo());

    this.deviceCount = scanResults.size();

    this.deviceAddresses = new String[deviceCount];
    this.deviceNames = new String[deviceCount];
    this.rssis = new int[deviceCount];
    this.deviceBondStatuses = new int[deviceCount];
    this.deviceTypes = new int[deviceCount];
    this.timestampsNano = new long[deviceCount];
    this.advertisingSids = new int[deviceCount];
    this.dataStatuses = new int[deviceCount];
    this.periodicAdvertisingIntervals = new int[deviceCount];
    this.primaryPhies = new int[deviceCount];
    this.secondaryPhies = new int[deviceCount];
    this.txPowers = new int[deviceCount];
    this.areConnectable = new boolean[deviceCount];
    this.areLegacy = new boolean[deviceCount];
    this.uuids = new String[deviceCount];
    this.majors = new int[deviceCount];
    this.minors = new int[deviceCount];

    for (int i = 0; i < scanResults.size(); i++) {
        ScanResult scanResult = scanResults.get(i);

        BluetoothDevice bluetoothDevice = scanResult.getDevice();
        this.deviceAddresses[i] = nullStringToEmpty(bluetoothDevice.getAddress());
        this.deviceNames[i] = nullStringToEmpty(bluetoothDevice.getName());
        this.rssis[i] = scanResult.getRssi();
        this.deviceBondStatuses[i] = bluetoothDevice.getBondState();
        this.deviceTypes[i] = bluetoothDevice.getType();
        this.timestampsNano[i] = scanResult.getTimestampNanos();

        this.advertisingSids[i] = getAdvertisingSid(scanResult);
        this.dataStatuses[i] = getDataStatus(scanResult);
        this.periodicAdvertisingIntervals[i] = getPeriodicAdvertisingInterval(scanResult);
        this.primaryPhies[i] = getPrimaryPhy(scanResult);
        this.secondaryPhies[i] = getSecondaryPhy(scanResult);
        this.txPowers[i] = getTxPower(scanResult);
        this.areConnectable[i] = getIsConnectable(scanResult);
        this.areLegacy[i] = getIsLegacy(scanResult);

        byte[] scanRecord = scanResult.getScanRecord().getBytes();
        this.uuids[i] = getUuid(scanRecord);
        this.majors[i] = getMajor(scanRecord);
        this.minors[i] = getMinor(scanRecord);
    }
}
 
開發者ID:ubikgs,項目名稱:AndroidSensors,代碼行數:51,代碼來源:BLEMeasurementsRecord.java

示例15: create

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public RxBleInternalScanResult create(ScanResult result) {
    final ScanRecordImplNativeWrapper scanRecord = new ScanRecordImplNativeWrapper(result.getScanRecord());
    return new RxBleInternalScanResult(result.getDevice(), result.getRssi(), result.getTimestampNanos(), scanRecord,
            ScanCallbackType.CALLBACK_TYPE_BATCH);
}
 
開發者ID:Polidea,項目名稱:RxAndroidBle,代碼行數:7,代碼來源:InternalScanResultCreator.java


注:本文中的android.bluetooth.le.ScanResult.getRssi方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。