public void SetLed(LedAction action)
 {
     if (jtCradle.ControlLed(action))
     {
         Toast.MakeText(this, action.ToString(), ToastLength.Short).Show();
     }
     else
     {
         Toast.MakeText(this, "Failed to control the LED. Check if the device is inserted in the Cradle",
                        ToastLength.Long).Show();
     }
 }
Exemple #2
0
        /// <summary>
        /// Switch the led state
        /// </summary>
        /// <param name="pNewLedState">New led state</param>
        /// <returns>Return the result of this operation</returns>
        public DeviceActionResult SwitchLedState(LedAction pNewLedState)
        {
            DeviceActionResult dev_result = new DeviceActionResult();

            //Prepare the command
            string comando = Common.StringParams("{\"system\":{\"set_led_off\":{\"off\":{0}}}}", (pNewLedState == LedAction.TurnOff) ? "1" : "0");

            //Send the command to the device and get the Json string result
            string sJsonResult = this.ExecuteAndRead(comando);

            try
            {
                JObject json_object = JObject.Parse(sJsonResult);
                dev_result.LoadFromJson(json_object["system"]["set_led_off"]);
            }
            catch (Exception ex)
            {
                throw new NonCompatibleDeviceException(ex.Message, ex);
            }

            return(dev_result);
        }