示例#1
0
 public void scanLeDevice(final int duration, final boolean enable) {
   if (enable) {
     if (mScanning) {
       return;
     }
     Log.d("TAG", "~ Starting Scan");
     // Stops scanning after a pre-defined scan period.
     if (duration > 0) {
       mHandler.postDelayed(
           new Runnable() {
             @Override
             public void run() {
               Log.d("TAG", "~ Stopping Scan (timeout)");
               mScanning = false;
               mBluetoothUtils.getBluetoothAdapter().stopLeScan(mLeScanCallback);
             }
           },
           duration);
     }
     mScanning = true;
     mBluetoothUtils.getBluetoothAdapter().startLeScan(mLeScanCallback);
   } else {
     Log.d("TAG", "~ Stopping Scan");
     mScanning = false;
     mBluetoothUtils.getBluetoothAdapter().stopLeScan(mLeScanCallback);
   }
 }
 private void initialize() {
   bluetoothDevice = BluetoothUtils.getBluetoothAdapter().getRemoteDevice(address);
   isConnected = false;
   bluetoothBuffer = new LinkedBlockingQueue<>();
   serialBuffer = new LinkedBlockingQueue<>();
   manager = OneSheeldManager.getInstance();
   connectionCallbacks = new CopyOnWriteArrayList<>();
   errorCallbacks = new CopyOnWriteArrayList<>();
   dataCallbacks = new CopyOnWriteArrayList<>();
   versionQueryCallbacks = new CopyOnWriteArrayList<>();
   queuedFrames = new ConcurrentLinkedQueue<>();
   isMuted = false;
   arduinoLibraryVersion = 0;
   majorVersion = 0;
   minorVersion = 0;
   isFirmwareVersionQueried = false;
   isLibraryVersionQueried = false;
   sysexBytesRead = 0;
   parsingSysex = false;
   waitForData = 0;
   executeMultiByteCommand = 0;
   multiByteChannel = 0;
   storedInputData = new byte[MAX_DATA_BYTES];
   isPinDebuggingEnabled = false;
 }
示例#3
0
  public DeviceData(BluetoothDevice device, String emptyName) {
    name = device.getName();
    address = device.getAddress();
    bondState = device.getBondState();

    if (name == null || name.isEmpty()) name = emptyName;
    deviceClass = device.getBluetoothClass().getDeviceClass();
    majorDeviceClass = device.getBluetoothClass().getMajorDeviceClass();
    uuids = BluetoothUtils.getDeviceUuids(device);
  }
示例#4
0
 public void forceStopScan() {
   mScanning = false;
   mBluetoothUtils.getBluetoothAdapter().stopLeScan(mLeScanCallback);
 }