Ejemplo n.º 1
0
        #pragma warning disable 1998
        /// <summary>
        /// Code running when the application starts or restarts
        /// </summary>
        /// <returns></returns>
        private async Task <SoundSensorStateReported> StartApplication(SoundSensorState desiredProperties)
        {
            _config = desiredProperties;

            if (_config != null)
            {
                if (_config.GpioConfig == null)
                {
                    _config.GpioConfig = new SoundSensorGpioConfig()
                    {
                        GpioSound = PIN_SOUND
                    };
                }

                if (_config.SoundTriggerDelay < SOUND_TRIGGER_DELAY_MINIMUM)
                {
                    _config.SoundTriggerDelay = SOUND_TRIGGER_DELAY_MINIMUM;
                }

                if (_config.State == DeviceState.On)
                {
                    _gpioService.InitGPIOInput(_config.GpioConfig.GpioSound, GpioSoundChanged);
                }
            }

            return(new SoundSensorStateReported()
            {
                DeviceState = _config
            });
        }
Ejemplo n.º 2
0
 #pragma warning disable 1998
 private async Task <SoundSensorStateReported> ReceiveDesiredConfiguration(SoundSensorState desiredProperties)
 {
     _config = desiredProperties;
     //Here the behavior to handle decibel threshold would be added
     //---
     return(new SoundSensorStateReported()
     {
         DeviceState = _config
     });
 }