Beispiel #1
0
        /// <summary>
        /// Retrieves the serial device, instantiates and configures
        /// the Cottonwood board. Also turns on the antenna so that
        /// the device is ready to perform inventory scans.
        /// </summary>
        /// <returns>If configuration successful.</returns>
        private async Task <bool> ConfigureCottonwood()
        {
            // Retrieve serial device representing the Cottonwood board.
            string deviceQuery = SerialDevice.GetDeviceSelector();
            var    discovered  = await DeviceInformation.FindAllAsync(deviceQuery);

            var readerInfo = discovered.Where(x => x.Name == uartBridgeName).FirstOrDefault();

            // If serial device found...
            if (readerInfo != null)
            {
                var bridgeDevice = await SerialDevice.FromIdAsync(readerInfo.Id);

                // If bridge device retrieved...
                if (bridgeDevice != null)
                {
                    // Instantiate the Cottonwood with the serial device.
                    reader = new Cottonwood(bridgeDevice);
                    bool isAntennaOn = await reader.TurnOnAntenna();

                    if (isAntennaOn)
                    {
                        // Set USA frequency.
                        var isUsFrequency = await reader.ConfigureUnitedStatesFrequency();

                        if (isUsFrequency)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }