Example usage for android.bluetooth BluetoothGattDescriptor ENABLE_NOTIFICATION_VALUE

List of usage examples for android.bluetooth BluetoothGattDescriptor ENABLE_NOTIFICATION_VALUE

Introduction

In this page you can find the example usage for android.bluetooth BluetoothGattDescriptor ENABLE_NOTIFICATION_VALUE.

Prototype

null ENABLE_NOTIFICATION_VALUE

To view the source code for android.bluetooth BluetoothGattDescriptor ENABLE_NOTIFICATION_VALUE.

Click Source Link

Document

Value used to enable notification for a client configuration descriptor

Usage

From source file:com.cerevo.blueninja.blueninja_ble_example.MainActivity.java

/**
 * Characteristic?Notification?//from  w ww.  jav  a2  s. c om
 */
private void enableBleNotification() {
    for (int i = 0; i < UUIDS_CHARACTERISTIC.length; i++) {
        boolean reg = mGatt.setCharacteristicNotification(mCharacteristics[i], true);
        BluetoothGattDescriptor desc = mCharacteristics[i]
                .getDescriptor(UUID.fromString(UUID_CLIENT_CHARACTERISTIC_CONFIG));
        desc.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
        mGatt.writeDescriptor(desc);

        if (!reg) {
            setStatus(AppState.BLE_NOTIF_REGISTER_FAILED);
            return;
        }
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    setStatus(AppState.BLE_NOTIF_REGISTERD);
}

From source file:com.example.alexanderbolinsky.ble_uart_remote.UartService.java

/**
 * Enable TXNotification/* w  w w  .j  a va 2  s  . c om*/
 *
 * @return
 */
public void enableTXNotification() {

    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }

    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);

    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    mBluetoothGatt.writeDescriptor(descriptor);

}

From source file:com.shenqu.jlplayer.nRFUARTv2.UartService.java

/**
 * Enable TXNotification/* w w w.j  ava 2s .  co m*/
 *
 * @return
 */
public void enableTXNotification() {
    /*
    if (mBluetoothGatt == null) {
      showMessage("mBluetoothGatt null" + mBluetoothGatt);
      broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
      return;
    }
    */
    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);

    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    mBluetoothGatt.writeDescriptor(descriptor);
}

From source file:com.example.alan.bikelog.UartService.java

/**
 * Enable TXNotification//from  ww  w. j  ava2  s.c om
 *
 * @return 
 */
public void enableTXNotification() {
    /*
    if (mBluetoothGatt == null) {
       showMessage("mBluetoothGatt null" + mBluetoothGatt);
       broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
       return;
    }
       */
    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);

    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    mBluetoothGatt.writeDescriptor(descriptor);

}

From source file:com.cardiograph.service.UartService.java

/**
 * Enable TXNotification/* ww  w.j a v a  2  s .c om*/
 *
 * @return 
 */
public void enableTXNotification() {

    if (mBluetoothGatt == null) {
        showMessage("mBluetoothGatt null" + mBluetoothGatt);
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }

    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);

    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    mBluetoothGatt.writeDescriptor(descriptor);

}

From source file:com.pandadentist.service.UartService.java

/**
 * Enable TXNotification/*from   w w  w  . ja  v a2 s.co  m*/
 *
 * @return
 */
public void enableTXNotification() {
    /*
    if (mBluetoothGatt == null) {
      showMessage("mBluetoothGatt null" + mBluetoothGatt);
      broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
      return;
    }
      */
    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);

    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    mBluetoothGatt.writeDescriptor(descriptor);

}

From source file:com.github.vgoliveira.panificadora.UartService.java

/**
 * Enable TXNotification// w  w  w.j  av a 2s.  c  o  m
 *
 * @return
 */

// No est sendo usadada na verso autal
public void enableTXNotification() {
    /*
    if (mBluetoothGatt == null) {
       showMessage("mBluetoothGatt null" + mBluetoothGatt);
       broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
       return;
    }
       */
    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);

    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    mBluetoothGatt.writeDescriptor(descriptor);

}

From source file:com.huiwu.bluetooth.BluetoothService.java

/**
 * Enable TXNotification//from w  ww  .j av a 2s. com
 *
 * @return
 */
public void enableTXNotification(boolean enable) {
    /*
    if (mBluetoothGatt == null) {
      showMessage("mBluetoothGatt null" + mBluetoothGatt);
      broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
      return;
    }
      */
    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);

    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    if (enable) {
        descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    } else {
        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
    }
    mBluetoothGatt.writeDescriptor(descriptor);

}

From source file:com.aprilbrother.blueduino.UartService.java

/**
 * Enable TXNotification/*from  w w  w  .  ja v  a2  s. c  o  m*/
 * 
 * @return
 */
public void enableTXNotification() {
    /*
     * if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" +
     * mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
     * return; }
     */

    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {

        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);
    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    mBluetoothGatt.writeDescriptor(descriptor);

}

From source file:com.example.UART.UartService.java

/**
 * Enable TXNotification/*  www.  ja v  a 2 s.  c o  m*/
 *
 * @return 
 */
@SuppressLint("NewApi")
public void enableTXNotification() {

    if (mBluetoothGatt == null) {
        showMessage("mBluetoothGatt null" + mBluetoothGatt);
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }

    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    if (TxChar == null) {
        showMessage("Tx charateristic not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(TxChar, true);

    BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    mBluetoothGatt.writeDescriptor(descriptor);

}