Android - Problema con bluetooth

 
Vista:

Problema con bluetooth

Publicado por Jesus (1 intervención) el 30/05/2016 11:13:23
Hola, estoy haciendo una aplicacion android en el que tengo que que conectarme a una Psoc BLE para transmitir datos en ambos sentidos. Para ello he creado en Psoc dos caracteristicas (Temperatura y humedad) pero a humedad no puedo acceder de la misma forma que lo hago a la caracteristica temperatura.
Esta es la característica de que si funciona (temperatura):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
cbtemp.setOnClickListener (nueva View.OnClickListener () {     // temperatura CheckBox
 
@Anular
public void onClick (Ver vista) {
booleano isChecked = ((casilla de verificación) Vista) .isChecked ();
 
if (isChecked) {
 
  BluetoothGattService mCustomService=mBluetoothLeService.getServices();
 
  BluetoothGattCharacteristic mCustomCharacteristic =    mCustomService.getCharacteristic(UUID.fromString("00000002-0000-1000-   8000- 00805f9b34fb"));   //UUID characteristic temperature
 
  final int charaProp = mCustomCharacteristic.getProperties();
 
  if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
 
    if (mNotifyCharacteristic != null) {
 
      mBluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, false);
 
      mNotifyCharacteristic = null;
      }
 
mBluetoothLeService.readCharacteristic(mCustomCharacteristic); }
 
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
 
    mNotifyCharacteristic = mCustomCharacteristic;
 
    mBluetoothLeService.setCharacteristicNotification(mCustomCharacteristic, true); }
}
});
 
donde getservices función () es:
 
public BluetoothGattService getServices(){
return mBluetoothGatt.getService(UUID.fromString("00000001-0000-1000-8000-00805f9b34fb"));  //UUID Service
}


Para la humedad característica que hago el mismo procedimiento pero utilizando el UUID correspondiente (00000003-0000-1000- 8000-00805f9b34fb), pero haciendo clic en la casilla de verificación para activar me dice:

java.lang.NullPointerException : Attempt to invoke virtual method ' int android.bluetooth.BluetoothGattCharacteristic.getProperties () ' on a null object reference.

No se porque no funciona. si alguien me puediera ayudar seria de gran ayuda. Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder