Beispiel #1
0
        protected override OCEntityHandlerResult OnPropertyUpdated(RepPayload payload)
        {
            bool state;

            if (payload.TryGetBool("state", out state))
            {
                SetProperty(OicResourceTypeConstants.SwitchBinary, "state", state);
                Log.WriteLine($"Switch state updated to '{state}'");
                return(OCEntityHandlerResult.OC_EH_OK);
            }
            return(OCEntityHandlerResult.OC_EH_NOT_ACCEPTABLE);
        }
Beispiel #2
0
        protected override OCEntityHandlerResult OnPropertyUpdated(RepPayload payload)
        {
            long brightness;

            if (payload.TryGetInt64("brightness", out brightness))
            {
                if (brightness < 0 || brightness > 100)
                {
                    return(OCEntityHandlerResult.OC_EH_NOT_ACCEPTABLE);
                }

                SetProperty(OicResourceTypeConstants.LightBrightness, "brightness", brightness);

                return(OCEntityHandlerResult.OC_EH_OK);
            }
            return(base.OnPropertyUpdated(payload));
        }