/// <summary> /// First sends a BIST initialization request to the sensor, then checks /// for the sensor response every second over the course of 5 minutes. /// </summary> /// <returns></returns> private static async Task FullBist(string sensorId) { Console.WriteLine("Test /api/initialize-bist and /api/sensor/bist-response/{SensorId}/{LastUpdated}"); Console.WriteLine("Run basic internal self test (BIST) (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 BIST request..."); string now = DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss"); // Initialize the test await SensorApi.InitializeBist(json.ToString()); Console.WriteLine("BIST Sent at UTC: " + now); List <BistResponse> responses = new List <BistResponse>(); // We want to call the bist-response every second for 5 minutes // or until a response comes back. int timer = 0; while (timer < 300) { responses = await SensorApi.BistResponse(sensorId, now); if (responses.Count > 0) { break; } Console.WriteLine("Waiting for Bist response " + (++timer)); await Task.Delay(1000); } if (timer >= 300) { Console.WriteLine("No response..."); } else { Console.WriteLine("BIST response recieved!"); foreach (BistResponse response in responses) { Console.WriteLine("--> " + response.SensorType + ": " + response.Status); } } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine("Method Error: " + ex.Message + "\n"); } } }