简体   繁体   English

蓝牙低功耗连接参数更新 - 导致HRESULT的设备或窗口:0x80070005(E_ACCESSDENIED))?

[英]Bluetooth Low Energy connection parameters update - device or windows causing HRESULT: 0x80070005 (E_ACCESSDENIED))?

I'm trying to write to the GAP service (0x180) characteristics and 0x2A04 我正在尝试写入GAP服务(0x180)特性和0x2A04

Whenever I try writing to 0x2A04 (connection parameters) or 0x0200 (device name), 每当我尝试写入0x2A04(连接参数)或0x0200(设备名称)时,

    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 并调用WriteValueAsync(),程序在该行中断,我的异常是

An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code mscorlib.dll中出现“System.UnauthorizedAccessException”类型的异常,但未在用户代码中处理

Additional information: Access is denied. 其他信息:访问被拒绝。 (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) (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. 我不太确定参数被拒绝的堆栈级别 - 我甚至不知道参数是否甚至到达BLE设备。 However, as I can write to other GATT services and read from the GAP characteristics, I believe it is the device. 但是,由于我可以写入其他GATT服务并从GAP特性中读取,我相信它就是设备。

Can anybody see a fool proof method to discover where this problem is coming from? 任何人都可以看到一个万无一失的方法来发现这个问题的来源吗?

Thanks Thomas 谢谢托马斯

I had this problem before. 我以前遇到过这个问题。 It seems Microsoft doesn't like you writing to the GAP. 看来微软并不喜欢你写给GAP。

I recommend you structure your Gatt.XML so that it only contains "Name" and "Appearance" services in the GAP (only these 2 services) and then put the remaining characteristics underneath a Custom Service or a standard one. 我建议您构建Gatt.XML,使其仅包含GAP中的“名称”和“外观”服务(仅限这两项服务),然后将其余特征放在自定义服务或标准服务下。

If you try writing to a characteristic that is write enabled beneath the custom service it should work. 如果您尝试写入自定义服务下启用了写入功能的特性,它应该可以工作。

Summary: You can't write to characteristics under GAP. 简介:您无法在GAP下写入特征。

Reference: Restructuring the Gatt.XML of my device fixed this same problem for me. 参考:重构我的设备的Gatt.XML为我修复了同样的问题。

Additional Details: For these "Access Denied" errors you want to check that: 1) You have your package manifest capabilities manually edited to include the Services your Gatt.XML has. 其他详细信息:对于这些“拒绝访问”错误,您需要检查:1)您手动编辑了包清单功能,以包含您的Gatt.XML所具有的服务。 You have to specify custom services and standard services alike. 您必须指定自定义服务和标准服务。 2) Your Gatt.XML is correctly structured. 2)您的Gatt.XML结构正确。 3) The caracteristic you are trying to write to exists/the device is currently paired to. 3)您尝试写入的特征存在/设备当前已配对。

Cheers, Togepi 干杯,Togepi

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在SetInputToDefaultAudioDevice()上访问被拒绝的HRESULT:0x80070005(E_ACCESSDENIED); - Access Denied HRESULT: 0x80070005 (E_ACCESSDENIED)) on SetInputToDefaultAudioDevice(); WATIN与HRESULT一起崩溃:0x80070005(E_ACCESSDENIED) - WATIN keeps crashing with HRESULT: 0x80070005 (E_ACCESSDENIED) 无法删除Windows Store应用程序中的文件-访问被拒绝。 (HRESULT:0x80070005(E_ACCESSDENIED)) - Cant delete a file in Windows Store Application - Access is denied. (HRESULT: 0x80070005 (E_ACCESSDENIED)) 从非管理员用户获取外壳程序窗口会引发访问被拒绝的异常HRESULT:0x80070005(E_ACCESSDENIED) - Fetching shell windows throws access denied exception HRESULT: 0x80070005 (E_ACCESSDENIED) from non-admin user 移至Windows Phone 8.1中的表单会引发“访问被拒绝。 (来自HRESULT的异常:0x80070005(E_ACCESSDENIED))” - Moving to forms in Windows Phone 8.1 throws “Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))” 获取“访问被拒绝。 (在HR8ULT中出现异常:0x80070005(E_ACCESSDENIED))在Windows 8 App中,在DispatchTimer中使用Message对话框时? - Getting “Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))” in Windows 8 App when using Message dialog in DispatchTimer? 在Win 8 App中检索文件时,HRESULT异常:0x80070005(E_ACCESSDENIED)) - Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) when retrieving a file in Win 8 App Pool.Recycle() 从 HRESULT 抛出异常:0x80070005 (E_ACCESSDENIED) - Pool.Recycle() throwing exception from HRESULT: 0x80070005 (E_ACCESSDENIED) 访问被拒绝。 (来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))删除活动目录帐户 - Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) deleting active directory account 访问被拒绝。 (HRESULT异常:0x80070005(E_ACCESSDENIED))添加Active Directory帐户 - Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Adding Active Directory Account
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM