Plugin.BluetoothLE

Hello everybody,
I want to write - send text to a specific Characteristic and I found that I can send bytes with the following command.
Is there a different way or command to send text ?

Thank you

    public async void WWC(Guid ServiceUUID,Guid CharacteristicUUID,Byte[] Key)
    {


            CharacteristicGattResult x = await this.device.WriteCharacteristic(ServiceUUID, CharacteristicUUID, Key);

    }

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    You can use the following code to wirte a text to a specific Characteristic as well.

    //get the characteristic
    var characteristic = await service.GetCharacteristicAsync(Guid.Parse("ffe0ecd2-3d16-4f8d-1234-000000000000"));
    var data = await characteristic.ReadAsync();
    data[0] = 0x13;
    //write data 
    await characteristic.WriteAsync(data);
    //update
    characteristic.ValueUpdated += (s, e) =>
    {
       Debug.WriteLine("New value: {0}", e.Characteristic.Value);
    };
    characteristic.StartUpdates();
    
  • LeonLuLeonLu Member, Xamarin Team Xamurai

    @ChrisFotop Are there any updates for this issue? If the reply is helpful, please mark it as an answer, it will help others who have similar issue.

  • ChrisFotopChrisFotop Member

    @LeonLu said:
    @ChrisFotop Are there any updates for this issue? If the reply is helpful, please mark it as an answer, it will help others who have similar issue.

    Hi again
    it was unable to declare that variable
    var characteristic = await service.GetCharacteristicAsync(Guid.Parse("ffe0ecd2-3d16-4f8d-1234-000000000000"));

    service.GetCharacteristicAsync does not exist

    Second i cannot see the string you pass in your code

Sign In or Register to comment.