Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

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

Description

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions