@Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) { mConnected = true; updateConnectionState(R.string.connected); invalidateOptionsMenu(); } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) { mConnected = false; updateConnectionState(R.string.disconnected); invalidateOptionsMenu(); } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) { BluetoothGattService gattService = mBluetoothLeService.getSoftSerialService(); characteristicTX = gattService.getCharacteristic(BluetoothLeService.UUID_HM_RX_TX); // characteristicRX = gattService.getCharacteristic(BluetoothLeService.UUID_HM_RX_TX); characteristicRX = characteristicTX; if ((gattService != null) && (characteristicTX != null)) { mBluetoothLeService.setCharacteristicNotification(characteristicTX, true); isSerial.setText("Serial ready"); updateReadyState(R.string.ready); } else { isSerial.setText("Serial can't be found"); } } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) { displayData(intent.getStringExtra(mBluetoothLeService.EXTRA_DATA)); } }