当前位置: 首页>>代码示例>>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;未经允许,请勿转载。