访问被拒绝。 (当写入BLE值时,(HRESULT异常:0x80070005(E_ACCESSDENIED)) [英] Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) when write value to BLE

查看:98
本文介绍了访问被拒绝。 (当写入BLE值时,(HRESULT异常:0x80070005(E_ACCESSDENIED))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows应用商店中使用Gatt api将值写入BLE设备。我有BLE设备名称OLP425。我想写值1来使BLE设备闪烁,但当我试图写入值时,它会显示我的异常,如下所示

I am trying to write the value to BLE device using Gatt api in a windows store app. I have BLE device name OLP425. I would like to write value 1 to blink the BLE device, But when I am trying to write value it shows me exception like below




{"访问被拒绝。 (HRESULT异常:0x80070005(E_ACCESSDENIED))"}

{"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"}

这里我的代码

  var devices = await DeviceInformation.FindAllAsync(

         GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids。 GenericAccess),$
         new string [] {" System.Devices.ContainerId"});

 var devices = await DeviceInformation.FindAllAsync(
                GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.GenericAccess),
                new string[] { "System.Devices.ContainerId" });

  if(devices.Count> 0)

            {

 if (devices.Count > 0)
            {

  //连接到服务 

                var accService = await GattDeviceService.FromIdAsync(devices [0] .Id);

                if(accService == null)

                   返回;

 //Connect to the service  
                var accService = await GattDeviceService.FromIdAsync(devices[0].Id);
                if (accService == null)
                    return;

  var accData = accService.GetCharacteristics(new Guid(" 00002a00-0000-1000-8000-00805f9b34fb"))[0];

 var accData = accService.GetCharacteristics(new Guid("00002a00-0000-1000-8000-00805f9b34fb"))[0];




}

muke

推荐答案

Hi Muke,

Hi Muke,

GenericAccess服务是系统使用的保留服务,它仅供所有人阅读。 如果您将自己的专有特性转移到自己的服务中,您将被允许写入。

The GenericAccess service is a reserved service for system use, it is available as read only for everyone.  If you move your proprietary characteristic into its own service, you will be allowed to write to it.

谢谢


这篇关于访问被拒绝。 (当写入BLE值时,(HRESULT异常:0x80070005(E_ACCESSDENIED))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆