//void initWiFi(String ssid, String passphrase) //{ // bool foundSSID = false; // if (!wifiRS21.NetworkInterface.Opened) // wifiRS21.NetworkInterface.Open(); // wifiRS21.NetworkInterface.EnableDhcp(); // wifiRS21.UseDHCP(); // //wifi.UseStaticIP("192.168.1.225", "255.255.255.0", "192.168.1.1", new string[] { "10.1.10.1" }); // wifiRS21.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(wifiRS21_NetworkDown); // wifiRS21.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(wifiRS21_NetworkUp); // Debug.Print("Scan for wireless networks"); // WiFiRS9110.NetworkParameters[] scanResult = wifiRS21.NetworkInterface.Scan(); // if (scanResult != null) // { // foreach (WiFiRS9110.NetworkParameters x in scanResult) // { // if (x.Ssid == ssid) foundSSID = true; // Debug.Print(x.Ssid.ToString()); // } // } // else // { // Debug.Print("No wireless networks were found."); // } // Debug.Print("------------------------------------"); // if (foundSSID) // { // Debug.Print("Connecting to " + ssid); // wifiRS21.NetworkInterface.Join(ssid, passphrase); // Network with WPA or WPA2 security. // Thread.Sleep(1000); // Debug.Print("Connected"); // Debug.Print("IP Address: " + wifiRS21.NetworkSettings.IPAddress); // } // else // { // Debug.Print(ssid + " Wireless network was not found"); // } // Debug.Print("------------------------------------"); //} //void wifiRS21_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state) //{ // Debug.Print("Network down"); //} //void wifiRS21_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state) //{ // Debug.Print("Network Up"); // Debug.Print("IP Address: " + wifiRS21.NetworkSettings.IPAddress); //} // Callback function for measurement of temp and humidity. called every SendFrequency milliseconds void tempHumidity_MeasurementComplete(TempHumidity sender, TempHumidity.MeasurementCompleteEventArgs e) { // Convert temperature into Fahrenheit var FahrenheitTemp = e.Temperature * 9 / 5 + 32; // Display data and time in debug console Debug.Print(DateTime.Now.ToString()); Debug.Print("Temperature=" + FahrenheitTemp.ToString()); Debug.Print("Humidity=" + e.RelativeHumidity.ToString()); // Create hashtable for data Hashtable hashtable = new Hashtable(); hashtable.Add("hmdt", e.RelativeHumidity); hashtable.Add("temp", FahrenheitTemp); hashtable.Add("Subject", "wthr"); hashtable.Add("time", DateTime.UtcNow); hashtable.Add("from", DeviceID); hashtable.Add("dspl", DeviceName); // Serialize hashtable into JSON JsonSerializer serializer = new JsonSerializer(DateTimeFormat.Default); string payload = serializer.Serialize(hashtable); // send to Event Hub SendAMQPMessage(payload); }
void sensor_MeasurementComplete(TempHumidity sender, TempHumidity.MeasurementCompleteEventArgs e) { rowNr[currentRow % 5].TextContent = (currentRow + 1).ToString(); xValues[currentRow % 5].TextContent = e.Temperature.ToString("F2"); yValues[currentRow % 5].TextContent = e.RelativeHumidity.ToString("F2"); currentRow++; }
//void initWiFi(String ssid, String passphrase) //{ // bool foundSSID = false; // if (!wifiRS21.NetworkInterface.Opened) // wifiRS21.NetworkInterface.Open(); // wifiRS21.NetworkInterface.EnableDhcp(); // wifiRS21.UseDHCP(); // //wifi.UseStaticIP("192.168.1.225", "255.255.255.0", "192.168.1.1", new string[] { "10.1.10.1" }); // wifiRS21.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(wifiRS21_NetworkDown); // wifiRS21.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(wifiRS21_NetworkUp); // Debug.Print("Scan for wireless networks"); // WiFiRS9110.NetworkParameters[] scanResult = wifiRS21.NetworkInterface.Scan(); // if (scanResult != null) // { // foreach (WiFiRS9110.NetworkParameters x in scanResult) // { // if (x.Ssid == ssid) foundSSID = true; // Debug.Print(x.Ssid.ToString()); // } // } // else // { // Debug.Print("No wireless networks were found."); // } // Debug.Print("------------------------------------"); // if (foundSSID) // { // Debug.Print("Connecting to " + ssid); // wifiRS21.NetworkInterface.Join(ssid, passphrase); // Network with WPA or WPA2 security. // Thread.Sleep(1000); // Debug.Print("Connected"); // Debug.Print("IP Address: " + wifiRS21.NetworkSettings.IPAddress); // } // else // { // Debug.Print(ssid + " Wireless network was not found"); // } // Debug.Print("------------------------------------"); //} //void wifiRS21_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state) //{ // Debug.Print("Network down"); //} //void wifiRS21_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state) //{ // Debug.Print("Network Up"); // Debug.Print("IP Address: " + wifiRS21.NetworkSettings.IPAddress); //} // Callback function for measurement of temp and humidity. called every SendFrequency milliseconds void tempHumidity_MeasurementComplete(TempHumidity sender, TempHumidity.MeasurementCompleteEventArgs e) { // Convert temperature into Fahrenheit var FahrenheitTemp = e.Temperature * 9 / 5 + 32; // Display data and time in debug console Debug.Print(DateTime.Now.ToString()); Debug.Print("Temperature=" + FahrenheitTemp.ToString()); Debug.Print("Humidity=" + e.RelativeHumidity.ToString()); // send to Event Hub SendAMQPMessage(FormatMessage("Temperature", "F", FahrenheitTemp)); SendAMQPMessage(FormatMessage("Humidity", "%", e.RelativeHumidity)); }
//void initWiFi(String ssid, String passphrase) //{ // bool foundSSID = false; // if (!wifiRS21.NetworkInterface.Opened) // wifiRS21.NetworkInterface.Open(); // wifiRS21.NetworkInterface.EnableDhcp(); // wifiRS21.UseDHCP(); // //wifi.UseStaticIP("192.168.1.225", "255.255.255.0", "192.168.1.1", new string[] { "10.1.10.1" }); // wifiRS21.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(wifiRS21_NetworkDown); // wifiRS21.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(wifiRS21_NetworkUp); // Debug.Print("Scan for wireless networks"); // WiFiRS9110.NetworkParameters[] scanResult = wifiRS21.NetworkInterface.Scan(); // if (scanResult != null) // { // foreach (WiFiRS9110.NetworkParameters x in scanResult) // { // if (x.Ssid == ssid) foundSSID = true; // Debug.Print(x.Ssid.ToString()); // } // } // else // { // Debug.Print("No wireless networks were found."); // } // Debug.Print("------------------------------------"); // if (foundSSID) // { // Debug.Print("Connecting to " + ssid); // wifiRS21.NetworkInterface.Join(ssid, passphrase); // Network with WPA or WPA2 security. // Thread.Sleep(1000); // Debug.Print("Connected"); // Debug.Print("IP Address: " + wifiRS21.NetworkSettings.IPAddress); // } // else // { // Debug.Print(ssid + " Wireless network was not found"); // } // Debug.Print("------------------------------------"); //} //void wifiRS21_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state) //{ // Debug.Print("Network down"); //} //void wifiRS21_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state) //{ // Debug.Print("Network Up"); // Debug.Print("IP Address: " + wifiRS21.NetworkSettings.IPAddress); //} // Callback function for measurement of temp and humidity. called every SendFrequency milliseconds void tempHumidity_MeasurementComplete(TempHumidity sender, TempHumidity.MeasurementCompleteEventArgs e) { // Convert temperature into Fahrenheit var FahrenheitTemp = e.Temperature * 9 / 5 + 32; // Display data and time in debug console Debug.Print(DateTime.Now.ToString()); Debug.Print("Temperature=" + FahrenheitTemp.ToString()); Debug.Print("Humidity=" + e.RelativeHumidity.ToString()); // Create hashtable for data Hashtable hashtable = new Hashtable(); hashtable.Add("hmdt", e.RelativeHumidity); hashtable.Add("temp", FahrenheitTemp); hashtable.Add("Subject", "wthr"); hashtable.Add("time", DateTime.UtcNow); hashtable.Add("from", DeviceID); hashtable.Add("dspl", DeviceName); // Serialize hashtable into JSON JsonSerializer serializer = new JsonSerializer(DateTimeFormat.Default); string payload = serializer.Serialize(hashtable); // send to Event Hub SendAMQPMessage(payload); }