question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StartUpdatesAsync() / ValueUpdated not called

See original GitHub issue

Hi, The component I want to connect to works as follows: We write in a characteristic (TX) and we come to read the answer in another characteristic (RX).

The RX characteristic has the following attributes: canread: false canwrite: false cannotify: true So I can not do it by simple reading. I tried the following code for an event to be called when the characteristic is changed, but the program never goes into this event.

I have tried many solutions already proposed in the previous discussions but none has worked for now. However I am beginner in xamarin, Maybe I did something wrong.

this.Adapter.DeviceConnected += async (s, a) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(new Action(async () =>
                {
                    this.Connected = true;
                    this.Not_Connected = false;
                    this.Liste_Device_Connected.Add(a.Device);

                    this.Service_Selected = await this.Device_Selected.GetServiceAsync(Guid.Parse("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"));
                    this.Characteristic_TX = await this.Service_Selected.GetCharacteristicAsync(Guid.Parse("6e400002-b5a3-f393-e0a9-e50e24dcca9e"));
                    this.Characteristic_RX = await this.Service_Selected.GetCharacteristicAsync(Guid.Parse("6e400003-b5a3-f393-e0a9-e50e24dcca9e"));
                    await Task.Delay(1000);

                    this.Characteristic_RX.ValueUpdated += (o, args) =>
                    {
                        var bytes = args.Characteristic.Value;
                    };
                    await Task.Delay(1000);
                    await this.Characteristic_RX.StartUpdatesAsync();
                    await Task.Delay(1000);

                    byte[] octet = new byte[1];
                    octet[0] = 0x82;
                    var y = await this.Characteristic_TX.WriteAsync(octet);
                }));
                
            };

Expected behavior

it should go into the event just after writing the TX characteristic

Actual behavior

It don’t go into event.

Crashlog

none

Configuration

Version of the Plugin: 1.3.0

Platform: e.g. Android 8.0

Device: Huawei P20 light

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
ffrigecommented, Jul 11, 2020

@Joden31 @xabre were you guys able to find what causes this issue? I have the same problem here: I can write and read fine but I cannot get notifications. The code where I call StartUpdatesAsync does not generate any exception, but the ValueUpdated event is never called.

I tried with a 3rd party application on the same Android device and it works fine, so the server is sending out data correctly, I just can’t receive it on my side.

I also tried the suggestion mentioned by @ilakidain but it did not change anything, unfortunately.

What else could it be? Permissions? Timings? Thanks for your help.

0reactions
ffrigecommented, Jul 16, 2020

Since no activity or response was given here I decided to switch to another similar Bluetooth package (https://github.com/nexussays/ble.net) and found that it works flawlessly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

StartUpdatesAsync() / ValueUpdated not called · Issue #354
Hi, The component I want to connect to works as follows: We write in a characteristic (TX) and we come to read the...
Read more >
xamarin forms: How to get Bluetooth LE Notify
ValueUpdated and await characteristic.StartUpdatesAsync() to get response from BLE device. Expected behavior: The event characteristic.
Read more >
Xamarin Plugin.BLE why data read doesn't change?
ValueUpdated += UpdatingValue; await characteristic.StartUpdatesAsync(); // now we can write and hopefully read values byte[] data = { Coderequest.
Read more >
Implementation and complete understanding of BLE(Bluetooth ...
Connect to known Device. ConnectToKnownDeviceAsync can connect to a device with a given GUID. This means that if the device GUID is known,...
Read more >
Xamarin Community Forums - RSSing.com
When I call StartUpdatesAsync() method I can see that ValueUpdated event is handled continuously, even if the value doesn't change. Is this correctly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found