Now I can read the data, thanks =)
I have one more question. I'm trying to set up Auto Notifications for all 
available services.
So far, the callbacks (in onCharacteristicChanged) do not come.
In the class BluetoothGattDescriptor I have:

public static final byte[] ENABLE_NOTIFICATION_VALUE = {0x01, 0x00};

Is it a common constant, or it is different from device to the device?  I 
don't found a datasheet  (constants describingon) on the Developer 
<https://www.myvert.com/> page .

Also,here is my code to enable notifications.

   1. public  void startNotifying()
   2.    {
   3. 
   4.  
   5.        mBluetoothGattServices=mBluetoothGatt.getServices();
   6.        for (BluetoothGattService device:mBluetoothGattServices  )
   7.        {
   8.       
   9.             mBluetoothGattCharacteristics = device.getCharacteristics
   ();
   10.       
   11.             for (BluetoothGattCharacteristic 
caracteristic:mBluetoothGattCharacteristics 
    )
   12.            {
   13.                setNotificationForCharacteristic(caracteristic,true);
   14.                try {
   15.                    Thread.sleep(300);
   16.                } catch (InterruptedException e) {
   17.                    e.printStackTrace();
   18.                }
   19.            }
   20.        }
   21. 
   22.     }
   23. 
   24.   public void setNotificationForCharacteristic(
   BluetoothGattCharacteristic ch, boolean enabled) {
   25. 
   26.  
   27.        mBluetoothGatt.setCharacteristicNotification(ch, enabled);
   28. 
   29.  
   30.        for (BluetoothGattDescriptor descriptor:ch.getDescriptors()){
   31.            descriptor.setValue(BluetoothGattDescriptor.
   ENABLE_NOTIFICATION_VALUE);
   32.            mBluetoothGatt.writeDescriptor(descriptor);
   33.        }
   34. 
   35.     }




пятница, 14 октября 2016 г., 23:21:10 UTC+3 пользователь Александр 
Сергеевич Джус написал:
>
> Hello, I want to use Bluetooth 4.0 to connect the Vert device. The problem 
> is,that I have android 4.4, but your official example is based on android 
> 6.0.  I rebuilded this  example to work on my device, it starts  with 
> problems (I can connect and  get BleService(s)/BleCharacteristic(s), but 
> haracteristic.getValue("...") always null ).  So can you say what is wrong, 
> and what should I do to get Vert's values ?  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/51d47aeb-2bd1-4c2f-bf9b-5bc070ae392e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to