Skip to content

Instantly share code, notes, and snippets.

@cmaneu cmaneu/cheat.md
Last active Mar 7, 2019

Embed
What would you like to do?
MsDevRoadshow - cheat sheet

main.js - line 57

        scope.rgbColor.g = data.desired.rgbLEDG || 0;
        scope.rgbColor.b = data.desired.rgbLEDB || 0;

State.cs - end of file

        static async Task UpdateRgbLedColor(string state, Microsoft.Azure.Devices.Shared.Twin twin)
        {
            var color = Regex.Split(state, ",");
            var parsedR = int.TryParse(color[0], out var r);
            var parsedG = int.TryParse(color[1], out var g);
            var parsedB = int.TryParse(color[2], out var b);

            if (parsedR && parsedG && parsedB)
            {
                var patch = new
                {
                    properties = new
                    {
                        desired = new
                        {
                            rgbLEDR = r,
                            rgbLEDG = g,
                            rgbLEDB = b
                        }
                    }
                };
                await registryManager.UpdateTwinAsync(twin.DeviceId, JsonConvert.SerializeObject(patch), twin.ETag);
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.