/// <summary> /// Send down a Ping request and wait up to 5 minutes for the response /// </summary> /// <returns></returns> private static async Task FullPingTest(string sensorId) { Console.WriteLine("Test /api/sensor/ping and /api/sensor/ping-response/{SensorId}/{LastUpdated}"); Console.WriteLine("Ping sensor (y/n)?"); string input = Console.ReadLine(); if (input == "y" || input == "Y") { // Sample JSON to send JObject json = new JObject { ["sensorId"] = sensorId }; try { Console.WriteLine("Sending Ping request..."); string now = DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss"); // Send down the Ping request await SensorApi.InitializePing(json.ToString()); Console.WriteLine("Ping Sent at UTC: " + now); List <PingResponse> responses = new List <PingResponse>(); // We want to call the ping-response every second for 5 minutes // or until a response comes back. int timer = 0; while (timer < 300) { responses = await SensorApi.PingResponse(sensorId, now); if (responses.Count > 0) { break; } Console.WriteLine("Waiting for Ping response " + (++timer)); await Task.Delay(1000); } if (timer >= 300) { Console.WriteLine("No response..."); } else { Console.WriteLine("Ping response recieved!"); foreach (PingResponse response in responses) { Console.WriteLine("--> Ping RSSI: " + response.PingRssi + ", Ping SNR: " + response.PingSNR + ". Server time: " + response.ServerTime); } } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine("Method Error: " + ex.Message + "\n"); } } }