I'm trying to write to the GAP service (0x180) characteristics and 0x2A04
Whenever I try writing to 0x2A04 (connection parameters) or 0x0200 (device name),
var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromShortId(0x1800));
var service = await GattDeviceService.FromIdAsync(devices[0].Id);
var gapData = service.GetCharacteristics(new Guid("00002A04-0000-1000-8000-00805f9b34fb"))[0];
var raw = await gapData.ReadValueAsync();
byte[] conParas = new byte[raw.Value.Length];
DataReader.FromBuffer(raw.Value).ReadBytes(conParas);
//I can breakpoint and verify that the read works fine
var status = await gapData.WriteValueAsync(conParas.AsBuffer());
and call the WriteValueAsync(), the program breaks on that line and my exception is
An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code
Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I'm not quite sure what level of the stack the parameters are being refused - I don't even know if the parameters are even reaching the BLE device. However, as I can write to other GATT services and read from the GAP characteristics, I believe it is the device.
Can anybody see a fool proof method to discover where this problem is coming from?
Thanks Thomas