void NetworkChange_NetworkAddressChanged(object sender, EventArgs e) { Debug.Print("Network Address Change to: " + this.ethernetJ11D.NetworkInterface.IPAddress); if (this.ethernetJ11D.NetworkInterface.IPAddress != "0.0.0.0") { Debug.Print("IP Address: " + this.ethernetJ11D.NetworkInterface.IPAddress); Debug.Print("Gateway Address: " + this.ethernetJ11D.NetworkInterface.GatewayAddress); foreach (string dns in this.ethernetJ11D.NetworkInterface.DnsAddresses) { Debug.Print("DNS Address: " + dns); } this.WriteOnDisplay(0, 0, "IP Address:"); this.WriteOnDisplay(1, 0, this.ethernetJ11D.NetworkInterface.IPAddress); try { this.TimeServiceSetup(); } catch (Exception) { Debug.Print("TimeService initialization failed"); // fake time for debugging ? TimeService.SetUtcTime((new DateTime(2015, 4, 18, 11, 30, 00)).Ticks); Debug.Print("DateTime = " + DateTime.Now.ToString()); } // set and open the IoT client if (this.iotClient == null) { #if CONNECT_THE_DOTS this.iotClient = new IoTClientDots("gadgeteer", Guid.NewGuid().ToString(), connectionString, eventhubentity); #elif HEART_RATE this.iotClient = new IoTClientHealth("gadgeteer", Guid.NewGuid().ToString(), connectionString, eventhubentity); #else this.iotClient = new IoTClient("gadgeteer", Guid.NewGuid().ToString(), connectionString, eventhubentity); #endif } if (!this.iotClient.IsOpen) { this.iotClient.Open(); } // NOTE : seems to be a .Net MF bug when in this ethernet handler and you are waiting // a response on serial port, the data can't be received. // Launch serial communication with BLE module on different thread. Thread t = new Thread(this.SensorsSetup); t.Start(); //this.SensorsSetup(); } }
public async void Run(IBackgroundTaskInstance taskInstance) { // // TODO: Insert code to start one or more asynchronous methods // BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); this.tmp102 = new TMP102(); // set and open the IoT client if (this.iotClient == null) { //this.iotClient = new IoTClient("raspberrypi2", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); this.iotClient = new IoTClientConnectTheDots("raspberrypi2", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); } if (!this.iotClient.IsOpen) { this.iotClient.Open(); } bool isOpened = await this.tmp102.OpenAsync(); IDictionary bag = new Dictionary <SensorType, float>(); while (true) { float temperature = tmp102.Temperature(); SensorType sensorType = SensorType.Temperature; if (!bag.Contains(sensorType)) { bag.Add(sensorType, temperature); } else { bag[sensorType] = temperature; } if ((this.iotClient != null) && (this.iotClient.IsOpen)) { this.iotClient.SendAsync(bag); } await Task.Delay(5000); } deferral.Complete(); }
public MainPage() { this.InitializeComponent(); // set and open the IoT client if (this.iotClient == null) { // this.iotClient = new IoTClient("raspberrypi2", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); this.iotClient = new IoTClientConnectTheDots("raspberrypi2", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); } if (!this.iotClient.IsOpen) this.iotClient.Open(); // just to start without UI :-) this.btnStart_Click(null, null); }
public void Run() { Microsoft.SPOT.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged; Microsoft.SPOT.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged; networkAvailableEvent.WaitOne(); Debug.Print("link is up!"); networkAddressChangedEvent.WaitOne(); Debug.Print("address acquired: " + Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress); Debug.Print("\r\n*** GET NETWORK INTERFACE SETTINGS ***"); Microsoft.SPOT.Net.NetworkInformation.NetworkInterface[] networkInterfaces = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(); Debug.Print("Found " + networkInterfaces.Length + " network interfaces."); // get date/time via NTP DateTime dateTime = MFToolkit.Net.Ntp.NtpClient.GetNetworkTime(); Utility.SetLocalTime(dateTime); // set and open the IoT client if (this.iotClient == null) { #if CONNECT_THE_DOTS this.iotClient = new IoTClientDots("netduino", Guid.NewGuid().ToString(), connectionString, eventhubentity); #elif HEART_RATE this.iotClient = new IoTClientHealth("netduino", Guid.NewGuid().ToString(), connectionString, eventhubentity); #else this.iotClient = new IoTClient("netduino", Guid.NewGuid().ToString(), connectionString, eventhubentity); #endif } if (!this.iotClient.IsOpen) { this.iotClient.Open(); } // NOTE : seems to be a .Net MF bug when in this ethernet handler and you are waiting // a response on serial port, the data can't be received. // Launch serial communication with BLE module on different thread. Thread t = new Thread(this.SensorsSetup); t.Start(); //this.SensorsSetup(); Thread.Sleep(Timeout.Infinite); }
public async void Run(IBackgroundTaskInstance taskInstance) { // // TODO: Insert code to start one or more asynchronous methods // BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); this.tmp102 = new TMP102(); // set and open the IoT client if (this.iotClient == null) { //this.iotClient = new IoTClient("raspberrypi2", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); this.iotClient = new IoTClientConnectTheDots("raspberrypi2", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); } if (!this.iotClient.IsOpen) this.iotClient.Open(); bool isOpened = await this.tmp102.OpenAsync(); IDictionary bag = new Dictionary<SensorType, float>(); while (true) { float temperature = tmp102.Temperature(); SensorType sensorType = SensorType.Temperature; if (!bag.Contains(sensorType)) bag.Add(sensorType, temperature); else bag[sensorType] = temperature; if ((this.iotClient != null) && (this.iotClient.IsOpen)) { this.iotClient.SendAsync(bag); } await Task.Delay(5000); } deferral.Complete(); }
public void Run() { Microsoft.SPOT.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged; Microsoft.SPOT.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged; networkAvailableEvent.WaitOne(); Debug.Print("link is up!"); networkAddressChangedEvent.WaitOne(); Debug.Print("address acquired: " + Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress); Debug.Print("\r\n*** GET NETWORK INTERFACE SETTINGS ***"); Microsoft.SPOT.Net.NetworkInformation.NetworkInterface[] networkInterfaces = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(); Debug.Print("Found " + networkInterfaces.Length + " network interfaces."); // get date/time via NTP DateTime dateTime = MFToolkit.Net.Ntp.NtpClient.GetNetworkTime(); Utility.SetLocalTime(dateTime); // set and open the IoT client if (this.iotClient == null) { #if CONNECT_THE_DOTS this.iotClient = new IoTClientDots("netduino", Guid.NewGuid().ToString(), connectionString, eventhubentity); #elif HEART_RATE this.iotClient = new IoTClientHealth("netduino", Guid.NewGuid().ToString(), connectionString, eventhubentity); #else this.iotClient = new IoTClient("netduino", Guid.NewGuid().ToString(), connectionString, eventhubentity); #endif } if (!this.iotClient.IsOpen) this.iotClient.Open(); // NOTE : seems to be a .Net MF bug when in this ethernet handler and you are waiting // a response on serial port, the data can't be received. // Launch serial communication with BLE module on different thread. Thread t = new Thread(this.SensorsSetup); t.Start(); //this.SensorsSetup(); Thread.Sleep(Timeout.Infinite); }
public MainPage() { this.InitializeComponent(); this.tmp102 = new TMP102(); // set and open the IoT client if (this.iotClient == null) { //this.iotClient = new IoTClient("raspberrypi2", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); this.iotClient = new IoTClientConnectTheDots("raspberrypi2", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); } if (!this.iotClient.IsOpen) { this.iotClient.Open(); } // just to start without UI :-) this.btnStart_Click(null, null); }
void NetworkChange_NetworkAddressChanged(object sender, EventArgs e) { Debug.Print("Network Address Change to: " + this.ethernetJ11D.NetworkInterface.IPAddress); if (this.ethernetJ11D.NetworkInterface.IPAddress != "0.0.0.0") { Debug.Print("IP Address: " + this.ethernetJ11D.NetworkInterface.IPAddress); Debug.Print("Gateway Address: " + this.ethernetJ11D.NetworkInterface.GatewayAddress); foreach (string dns in this.ethernetJ11D.NetworkInterface.DnsAddresses) { Debug.Print("DNS Address: " + dns); } this.WriteOnDisplay(0,0, "IP Address:"); this.WriteOnDisplay(1,0, this.ethernetJ11D.NetworkInterface.IPAddress); try { this.TimeServiceSetup(); } catch (Exception) { Debug.Print("TimeService initialization failed"); // fake time for debugging ? TimeService.SetUtcTime((new DateTime(2015, 4, 18, 11, 30, 00)).Ticks); Debug.Print("DateTime = " + DateTime.Now.ToString()); } // set and open the IoT client if (this.iotClient == null) { #if CONNECT_THE_DOTS this.iotClient = new IoTClientDots("gadgeteer", Guid.NewGuid().ToString(), connectionString, eventhubentity); #elif HEART_RATE this.iotClient = new IoTClientHealth("gadgeteer", Guid.NewGuid().ToString(), connectionString, eventhubentity); #else this.iotClient = new IoTClient("gadgeteer", Guid.NewGuid().ToString(), connectionString, eventhubentity); #endif } if (!this.iotClient.IsOpen) this.iotClient.Open(); // NOTE : seems to be a .Net MF bug when in this ethernet handler and you are waiting // a response on serial port, the data can't be received. // Launch serial communication with BLE module on different thread. Thread t = new Thread(this.SensorsSetup); t.Start(); //this.SensorsSetup(); } }
private void InitIoTClient() { // set and open the IoT client if (this.iotClient == null) { // this.iotClient = new IoTClient("IoTSpikeRaspberry", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); this.iotClient = new IoTClientConnectTheDots("IoTSpikeRaspberry", Guid.NewGuid().ToString(), this.connectionString, this.eventHubEntity); } if (!this.iotClient.IsOpen) this.iotClient.Open(); }