// This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            // init wifi and register callback
            WiFiRS9110 wifi = wifi_RS21.Interface;
            wifi.WirelessConnectivityChanged += new WiFiRS9110.WirelessConnectivityChangedEventHandler(wifi_WirelessConnectivityChanged);
            GeneralHelpers.initWiFi(wifi, ssid, passwd);

            // create new instance of orchestratorJS
            orchestratorJSClient = new OrchestratorJSClient(deviceIdentity);

            // register handler for listening method calls from orchestrator
            orchestratorJSClient.MethodCallReceived += new OrchestratorJSClient.OnMethodCallRecievedHandler(ojs_client_MethodCallReceived);

            Debug.Print("Program Initialized");
        }
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            SetupWindow();

            timeUntilCoffeeReady = 10;

            gyro.Calibrate();
            gyro.StartContinuousMeasurements();

            button.ButtonPressed += new Button.ButtonEventHandler((Button sender, Button.ButtonState state) =>
            {
                /*
                if (gyroIsmesasuring)
                {
                    gyro.StopContinuousMeasurements();
                }
                else
                {
                    gyro.StartContinuousMeasurements();
                }
                gyroIsmesasuring = !gyroIsmesasuring;
                getLoadedState();
                */
                coffeeMachineOn();
            });

            coffeeRelay.TurnOn();

            // init wifi and register callback
            WiFiRS9110 wifi = wifi_RS21.Interface;
            wifi.WirelessConnectivityChanged += new WiFiRS9110.WirelessConnectivityChangedEventHandler((s, e) =>
            {
                orchestratorJSClient.connect(host, port);
            });
            OrchestratorJSClient.GeneralHelpers.initWiFi(wifi, ssid, passwd);

            // create new instance of orchestratorJS
            orchestratorJSClient = new OrchestratorJSClient.OrchestratorJSClient(deviceIdentity);

            // register handler for listening method calls from orchestrator
            orchestratorJSClient.MethodCallReceived += new OrchestratorJSClient.OrchestratorJSClient.OnMethodCallRecievedHandler((e) =>
            {

                Program.BeginInvoke(new DispatcherOperationCallback(delegate
                {

                if ( e.capabilityName == "CoffeeCapability" && e.methodCallName == "makeCoffee" )
                {
                    orchestratorJSClient.sendResponse( coffeeMachineOn() );
                    return null;
                }
                else if (e.capabilityName == "CoffeeCapability" && e.methodCallName == "turnOff")
                {
                    // turn the machine of (also called after n. minutes)
                    orchestratorJSClient.sendResponse(coffeeMachineOff());
                    return null;
                }
                else if ( e.capabilityName == "CoffeeCapability" && e.methodCallName == "isLoaded" )
                {
                    orchestratorJSClient.sendResponse( ( coffeeMachineState == CoffeeMachineState.LOADED ) );
                    return null;
                }
                else if ( e.capabilityName == "CoffeeCapability" && e.methodCallName == "isOn" )
                {
                    orchestratorJSClient.sendResponse( ( coffeeMachineState == CoffeeMachineState.ON ) );
                    return null;

                }
                else if (e.capabilityName == "CoffeeCapability" && e.methodCallName == "isCoffeeReady")
                {
                    // check if timer is 0 -> ready
                    if (timeUntilCoffeeReady <= 0)
                    {
                        Debug.Print("Coffee was READY!");
                        orchestratorJSClient.sendResponse(true);
                        return null;
                    }
                    else
                    {
                        Debug.Print("Coffee is NOT READY yet!");
                        orchestratorJSClient.sendResponse(false);
                        return null;
                    }

                }
                else
                {
                    Debug.Print("unknown capability and/or method");
                }
                orchestratorJSClient.sendResponse();

                        return null;
                }), "");

            });
        }