Beispiel #1
0
  public ProgramInfo(byte[] mImage, SensorTagDevice device) {
    // this.mFileImgHdr = mFileImgHdr;
    mFileImgHdr = new ImageHdr(mImage);
    mFileBuffer = mImage;
    this.mBtLeService = BluetoothLeService.getInstance();
    this.deviceAddress = device.getAddress();

    BluetoothGattService mOadService = device.getOadService();
    BluetoothGattService mConnControlService = device.getConnControlService();
    // Characteristics list
    List<BluetoothGattCharacteristic> mCharListOad = mOadService.getCharacteristics();
    List<BluetoothGattCharacteristic> mCharListCc = mConnControlService.getCharacteristics();

    mServiceOk = mCharListOad.size() == 2 && mCharListCc.size() >= 3;
    if (mServiceOk) {
      mCharIdentify = mCharListOad.get(0);
      mCharBlock = mCharListOad.get(1);
      mCharBlock.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
      mCharConnReq = mCharListCc.get(1);

      mBtLeService.setCharacteristicNotification(deviceAddress, mCharBlock, true);

      if (Build.VERSION.SDK_INT >= 21) {
        mBtLeService.requestConnectionPriority(
            deviceAddress, BluetoothGatt.CONNECTION_PRIORITY_HIGH);
      }

      setConnectionParameters();
    }
  }
Beispiel #2
0
  public void stopProgramming() {
    mTimer.cancel();
    mTimer.purge();
    mProgramming = false;

    mBtLeService.setCharacteristicNotification(deviceAddress, mCharBlock, false);
  }