Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write/Read command on Characteristic doesn't work on Android #66

Open
Krodz opened this issue Sep 22, 2016 · 0 comments
Open

Write/Read command on Characteristic doesn't work on Android #66

Krodz opened this issue Sep 22, 2016 · 0 comments

Comments

@Krodz
Copy link

Krodz commented Sep 22, 2016

Hello !

I have this device I need to read data from but the constructor created a custom service.
In order to get informations like DeviceID I need to write a command on a characteristic and read the result from another one.

The two characteristics have the same GUID, the differences are the rights (one can only write, the other can read/update).

While I write my command on the WriteOnly, the event "ValueUpdated" of the other characteristic is triggered but the characteristic value is always null.

var characts = service.Characteristics.Where(c => c.ID == new Guid("81eb77bd-89b8-4494-8a09-7f83d986ddc7"));
writeCharact = characts.FirstOrDefault(c => c.CanWrite && !c.CanRead);
readCharact = characts.FirstOrDefault(c => c.CanRead && c.CanUpdate);
if (writeCharact != null)
{
var cmd = ToMeter("&W "); // Just my command it will send "&W 58287"
readCharact.ValueUpdated += async (sender, e) =>
{
var readValue = readCharact.Value;
var c = await readCharact.ReadAsync();
var id = c.Value;
};
readCharact.StartUpdates();
writeCharact.Write(cmd);
}

This code works on iOS but doesn't on android. I can scan the devices, discover the services, discover the characteristics with no problem. Only this scenario doesn't work.

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant