public static void Main()
        {
            var wifi = new NeonWifiDevice();

            wifi.Connect(SSID, PASSWD);

            var sntp = new SntpClient(wifi, "time1.google.com");

            sntp.SetTime();

            MobileServiceClient msc = new MobileServiceClient(wifi, azureMobileAppUri, null, AzureAppKey);
            IMobileServiceTable tab = msc.GetTable("environment_measures");

            // Test a dummy insert for now
            MeasurementRow row    = new MeasurementRow();
            string         result = tab.Insert(row);

            Debug.Print(DateTime.Now.ToString("T") + " " + result);

            bool state    = true;
            int  iCounter = 0;

            while (true)
            {
                Hardware.UserLed.Write(state);
                state = !state;
                if (++iCounter == 10)
                {
                    Debug.Print("Current UTC time : " + DateTime.UtcNow);
                    iCounter = 0;
                }
                Thread.Sleep(500);
            }
        }
Exemple #2
0
        public static void Main()
        {
            var wifi = new NeonWifiDevice();

            //wifi.EnableDebugOutput = true;
            //wifi.EnableVerboseOutput = true;

            wifi.Booted += WifiOnBooted;  // or you can wait on the wifi.IsInitializedEvent
            //wifi.Error += WifiOnError;
            //wifi.ConnectionStateChanged += WifiOnConnectionStateChanged;

            //var apList = wifi.GetAccessPoints();
            //Debug.Print("Access points:");
            //foreach (var ap in apList)
            //{
            //    Debug.Print("ECN : " + ap.Ecn);
            //    Debug.Print("SSID : " + ap.Ssid);
            //    Debug.Print("RSSI : " + ap.Rssi);
            //    Debug.Print("MAC addr : " + ap.MacAddress);
            //    Debug.Print("Connection is : " + (ap.AutomaticConnectionMode ? "Automatic" : "Manual"));
            //}

            wifi.Connect("XXX", "XXX");

            var sntp = new SntpClient(wifi, "time1.google.com");

            sntp.SetTime();

            var uri        = new Uri("http://www.example.com");
            var httpClient = new HttpClient(wifi);
            var request    = new HttpRequest(uri);

            request.Uri = uri;
            request.Headers.Add("Connection", "Keep-Alive");
            request.ResponseReceived += HttpResponseReceived;
            httpClient.SendAsync(request);

            bool state    = true;
            int  iCounter = 0;

            while (true)
            {
                Hardware.UserLed.Write(state);
                state = !state;
                if (++iCounter == 10)
                {
                    Debug.Print("Current UTC time : " + DateTime.UtcNow);
                    iCounter = 0;
                }
                Thread.Sleep(500);
            }
        }
Exemple #3
0
        public static void Main()
        {
            var wifi = new NeonWifiDevice();

            //wifi.EnableDebugOutput = true;
            //wifi.EnableVerboseOutput = true;

            wifi.Booted += WifiOnBooted;  // or you can wait on the wifi.IsInitializedEvent

            wifi.Connect(SSID, PASSWD);

            var sntp = new SntpClient(wifi, "time1.google.com");

            sntp.SetTime();

            MobileServiceClient msc = new MobileServiceClient(wifi, ak16Uri, null, AzureAppKey);
            IMobileServiceTable tab = msc.GetTable("environment_measures");

            //try
            //{
            // Test a dummy insert for now
            MeasurementRow row = new MeasurementRow();

            row.DateTimeStamp = DateTime.Now;
            row.where         = "here"; //Resources.GetString(Resources.StringResources.VanWie);
            row.what          = "nothing";
            row.value         = -1f;
            row.uom           = " ";
            string surprise = tab.Insert(row); // Failing on this line

            Debug.Print(DateTime.Now.ToString("T") + " " + surprise);

            bool state    = true;
            int  iCounter = 0;

            while (true)
            {
                Hardware.UserLed.Write(state);
                state = !state;
                if (++iCounter == 10)
                {
                    Debug.Print("Current UTC time : " + DateTime.UtcNow);
                    iCounter = 0;
                }
                Thread.Sleep(500);
            }
        }