BLE with Monkey.Robotics multiple notifications from characteristics in an EventHandler not working

BenedictPBenedictP DEMember
edited September 2015 in Cross Platform with Xamarin


I'm currently writing a small app that should get notifications from the sensors from a TI Sensortag.
I read the guide from Monkey.Robotics and also looked into the sample source code but I have following problem:
If I try to handle multiple value update notifications from different characteristics only the first one that started will notify my valueUpdateHandler (see code below). I changed the order in my sensorList and I figured out that the first sensor on my list will notifiy me and the others not.

The relevant Code:

public class MyDeviceService
    EventHandler<CharacteristicReadEventArgs> _valueUpdatedHandler;


    //The beginning:
    public async void ConnectToDevice ()
        IDevice device = await _adapter.ConnectAsync (_deviceToConnect);
        await EnabelSensors (device);
        //here starts the relevant code:
        _valueUpdatedHandler = (s, e) => DecodeAndSend (e.Characteristic);
        await EnableNotifications (device);

    async Task EnableNotifications (IDevice device)
        foreach (Sensor sensor in _sensorList) {
            IService service = await device.GetServiceAsync (sensor.sensorService);
            ICharacteristic characteristic = await service.GetCharacteristicAsync (sensor.sensorData);
            if (characteristic.CanUpdate) {
                characteristic.ValueUpdated += _valueUpdatedHandler;
                characteristic.StartUpdates ();

    void DecodeAndSend (ICharacteristic characteristic)
        if (characteristic.ID.Equals (SensorGuid.IR_TEMPERATURE_DATA)) {
            Console.WriteLine ("temperature");
        } else if (characteristic.ID.Equals (SensorGuid.HUMIDITY_DATA)) {
            Console.WriteLine ("humidty");
        } else if (characteristic.ID.Equals (SensorGuid.ACCELEROMETER_DATA)) {
            Console.WriteLine ("accelerometer");
        } else if (characteristic.ID.Equals (SensorGuid.MAGNETOMETER_DATA)) {
            Console.WriteLine ("magnetometer");


As I said only the first sensor in my sensorList is calling DecodeAndSend.

If you want I can upload the whole code on Github.


  • indraxamarinindraxamarin ESMember

    Any solution to this?

    I have also the same issue in Android. I have a BLE device that has 2 characteristics to be notified, but only the first characteristic where the notifications are enabled works.

Sign In or Register to comment.