private void Service_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("InvalidRequest"))
            {
                rootPage.NotifyUser("Invalid request!", NotifyType.ErrorMessage);
            }

            //new characteristic value received
            if (e.PropertyName.Equals("Value"))
            {
                // switch (sender) ...
                Debug.WriteLine($"Lightbulb service received value from : {sender}");

                String receivedWrite = BLEServices.Helpers.ToHexString(rootPage.Ble.lightBulbService.LightBulbSwitch.Value);
                rootPage.NotifyUser("WRITE received: " + receivedWrite, NotifyType.StatusMessage);

                //check if value is 01, otherwise error?
                if (receivedWrite.Equals("01"))
                {
                    LightBulb.On();
                    if (isSolved == false)
                    {
                        isSolved = true;
                        rootPage.NotifyCorrect(scenarioName);
                        Solved.Visibility = Visibility.Visible;
                    }
                }
                else if (receivedWrite.Equals("00"))
                {
                    LightBulb.Off();
                }
            }
        }
Example #2
0
        private void Service_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("InvalidRequest"))
            {
                rootPage.NotifyUser("Invalid request!", NotifyType.ErrorMessage);
            }

            else if (e.PropertyName.Equals("InvalidPin"))
            {
                rootPage.NotifyUser("Invalid password, access denied!", NotifyType.ErrorMessage);
            }

            // process ARGB Value
            if (e.PropertyName.Equals("Value"))
            {
                byte[] newColor = rootPage.Ble.lightBulbService.LightBulbColor.argb;
                rootPage.NotifyUser($"New color received: {newColor[0]} {newColor[1]} {newColor[2]} {newColor[3]}", NotifyType.StatusMessage);

                //initial check already in the characteristic, assuming [A R G B] here
                lightBulbBrush.Color = Windows.UI.Color.FromArgb(newColor[0], newColor[1], newColor[2], newColor[3]);
                LightBulb.ARGB(lightBulbBrush);
            }

            // password protected special scenario received
            else if (e.PropertyName.Equals("SpecialValue"))
            {
                byte specialEffects = rootPage.Ble.lightBulbService.LightBulbColor.specialEffectsScenario;
                rootPage.NotifyUser($"Correct PIN, new special effects scenario received: {specialEffects}", NotifyType.StatusMessage);

                //initial check already in the characteristic, assuming [A R G B] here
                if (specialEffects == 0x01)
                {
                    //Green
                    lightBulbBrush.Color = Windows.UI.Color.FromArgb(0xFF, 0x00, 0xFF, 0x00);
                    LightBulb.ARGB(lightBulbBrush);

                    //TextToSpeech.AutoPlay = true;
                    VoiceCongrats.SetSource(speechStream, speechStream.ContentType);
                    VoiceCongrats.Play();
                    // play Rick after the voice congrats finishes
                    VoiceCongrats.MediaEnded += RickRoll;

                    rootPage.NotifyCorrect(scenarioName);
                    Solved.Visibility       = Visibility.Visible;
                    ShowValidPin.Visibility = Visibility.Visible;
                    LightBulb.Checked(true);
                }
                else
                {
                    LightBulb.Off();
                    LightBulb.Checked(false);
                    Rick.Stop();
                    Rick.Visibility = Visibility.Collapsed;
                    colorTicker.Stop();
                }
            }
        }
        private void Service_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("InvalidRequest"))
            {
                rootPage.NotifyUser("Invalid request!", NotifyType.ErrorMessage);
            }

            else if (e.PropertyName.Equals("BlinkPassed"))
            {
                rootPage.NotifyCorrect(scenarioName);
                Solved.Visibility = Visibility.Visible;
                LightBulb.Checked(true);
                isSolved = true;
            }

            //new characteristic value received
            else if (e.PropertyName.Equals("Value"))
            {
                String receivedWrite = BLEServices.Helpers.ToHexString(rootPage.Ble.lightBulbService.LightBulbSwitch.Value);

                // notify of every write until solved, otherwise it will overwrite the "congratulations" notification
                if (!isSolved)
                {
                    rootPage.NotifyUser("Write received: " + receivedWrite, NotifyType.StatusMessage);
                }

                if (receivedWrite.Equals("01"))
                {
                    LightBulb.On();
                }
                else if (receivedWrite.Equals("00"))
                {
                    LightBulb.Off();
                }
            }
        }
Example #4
0
 public void lightBulbOff()
 {
     lightbulb.Off();
 }
Example #5
0
 public void undo()
 {
     lightBulb.Off();
 }