コード例 #1
0
        public ServerStatus GetServerStatus(int attemptsToConnect = 1)
        {
            for (int i = 1; i <= attemptsToConnect; i++)
                try
                {
                    string jsonString = new TimeoutedWebClient().DownloadString(arduinoAddress + "/status");
                    ServerStatus newServerStatus = JsonConvert.DeserializeObject<ServerStatus>(jsonString);
                    return newServerStatus;
                }
                catch { }

            return null;
        }
コード例 #2
0
        public bool IsNewSampleReaded(int attemptsToConnect = 10)
        {
            for (int i = 1; i <= attemptsToConnect; i++)
                try
                {
                    string jsonString = new TimeoutedWebClient().DownloadString(arduinoAddress + "/ir/info");
                    IRStatus newSample = JsonConvert.DeserializeObject<IRStatus>(jsonString);

                    return newSample.irCodeStored;
                }
                catch { }

            return false;
        }
コード例 #3
0
        public IRStatus GetIRStatus(int attemptsToConnect = 10)
        {
            for (int i = 1; i <= attemptsToConnect; i++)
                try
                {
                    string jsonString = new TimeoutedWebClient().DownloadString(arduinoAddress + "/ir/info");
                    IRStatus newSample = JsonConvert.DeserializeObject<IRStatus>(jsonString);

                    return newSample;
                }
                catch { }

            return null;
        }
コード例 #4
0
        public bool CancelReadNewSample(int attemptsToConnect = 10)
        {
            for (int i = 1; i <= attemptsToConnect; i++)
                try
                {
                    string jsonString = new TimeoutedWebClient().DownloadString(arduinoAddress + "/ir/clear");
                    IRStatus newSample = JsonConvert.DeserializeObject<IRStatus>(jsonString);

                    return newSample.waitForIRCode == false;
                }
                catch { }

            return false;
        }
コード例 #5
0
        public IRSample GetIRSample(int attemptsToConnect = 10)
        {
            for (int i = 1; i <= attemptsToConnect; i++)
                try
                {
                    string jsonString = new TimeoutedWebClient().DownloadString(arduinoAddress + "/ir/info");
                    IRSample newSample = JsonConvert.DeserializeObject<IRSample>(jsonString);
                    if (newSample.Length > 0)
                        CancelReadNewSample();

                    return newSample;
                }
                catch { }

            return null;
        }
コード例 #6
0
        public bool SendIR(int type, int length, int value, int attemptsToConnect = 10)
        {
            for (int i = 1; i <= attemptsToConnect; i++)
                try
                {
                    string jsonString = new TimeoutedWebClient().DownloadString(
                        arduinoAddress
                        + "/ir/send"
                        + "/" + type
                        + "/" + length
                        + "/" + value
                        );
                    // IRStatus newSample = JsonConvert.DeserializeObject<IRStatus>(jsonString);

                    return true;
                }
                catch { }

            return false;
        }