예제 #1
0
        public async Task <Bluetooth.LE.Gatt.Client.GattDescriptorsResult> DiscoverAllCharacteristicDescriptorsAsync()
        {
            var win10Result = await Win10Characteristic.GetDescriptorsAsync();

            Bluetooth.LE.Gatt.Client.GattDescriptorsResult rxResult = new Bluetooth.LE.Gatt.Client.GattDescriptorsResult();
            rxResult.CommunicationStatus = win10Result.Status.ToRXCommunicationStatus();
            if (rxResult.CommunicationStatus == RemoteX.Bluetooth.LE.Gatt.GattCommunicationStatus.Success)
            {
                rxResult.ProtocolError = GattErrorCode.Success;
                List <RXGattClientDescriptor> rxDescriptorList = new List <RXGattClientDescriptor>();
                foreach (var win10Descriptor in win10Result.Descriptors)
                {
                    rxDescriptorList.Add(RXGattClient.GetRXDescriptorFromWin10Descriptor(win10Descriptor));
                }
                rxResult.Descriptors = rxDescriptorList.ToArray();
            }
            else if (rxResult.CommunicationStatus == RemoteX.Bluetooth.LE.Gatt.GattCommunicationStatus.ProtocolError)
            {
                rxResult.ProtocolError = (Bluetooth.LE.Gatt.GattErrorCode)(win10Result.ProtocolError);
            }
            else if (rxResult.CommunicationStatus == GattCommunicationStatus.Unreachable)
            {
                throw new NotImplementedException("UNREACHABLE");
            }
            else if (rxResult.CommunicationStatus == GattCommunicationStatus.AccessDenied)
            {
                throw new NotImplementedException("ACCESSDENIED");
            }
            return(rxResult);
        }