'How to fix C# BLE WriteValueAsync() Got Error?

Get Error Message "Offset specified was past the end of the attribute. (Exception from HRESULT: 0x80650007)" write value to BLE device when executing below command

WriteCharacteristic.WriteValueAsync(CryptographicBuffer.CreateFromByteArray(data), GattWriteOption.WriteWithResponse);



Solution 1:[1]

Open application manifest (AndroidManifest.xml) and click on Merged Manifest tab on bottom of your edit pane. Check the image below:

image

From image you can see Error in the right column, try to solve the error. It may help some one with the same problem. Read more here.

Also, once you found the error and if you get that error from external library that you are using, You have to let compiler to ignore the attribute from the external library. //add this attribute in application tag in the manifest

tools:replace="android:allowBackup" 
                                                                                                                                          
//Add this in the manifest tag at the top

xmlns:tools="http://schemas.android.com/tools"

Solution 2:[2]

This app was built for an older version of Android and may not work properly. Try checking for updates, or contact the developer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 FlutterChicken
Solution 2 divya dave