public static void Main() { //Start the server time setting thread. new Thread(() => NTP.UpdateTime()).Start(); while (!NTP.timeSet) { Thread.Sleep(100); } Thread.Sleep(100); PowerManagment.SetPeripheralState(Peripheral.PowerLED, false); //Start the server itself. ServerConfiguration = new Configuration(8081); ServerCredential = new Credential(new string[] { "Test" }, "/auth.htm", new string[] { "/auth.htm", "/img/Log-In.png", "/css/main.css", "/lib/GetInTemp.js", "/lib/Login.js" }); Server = new HttpServer(ServerConfiguration, ServerCredential, 1024, 1024, @"\SD\htdocs"); Server.OnServerError += new OnServerErrorDelegate(Server_OnServerError); AC = new ACStatus(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D10); commander = new IRCommands(IR, commands); timers = new Timers(AC, tempSensor, commander); handler = new requestHandler(@"\SD\htdocs", commander, tempSensor, AC, timers, ServerCredential); Server.OnRequestReceived += new OnRequestRecievedDelegate(handler.processRequest); Server.Start(); //Start the temp management thread. new Thread(timers.tempControl).Start(); //Blink LED three times to show we're up and running. for (int i = 0; i < 6; i++) { led.Write(!led.Read()); Thread.Sleep(350); } led.Write(false); }
public Timers(ACStatus AC, HIH6130 temp, IRCommands commander) { _AC = AC; _temp = temp; _commander = commander; if (File.Exists(@"\SD\settings.txt")) { Debug.Print("Loading settings"); using (StreamReader sr = new StreamReader(@"\SD\settings.txt")) { string[] lines = sr.ReadToEnd().Split('\n'); int i = 0; foreach (string line in lines) { lines[i] = line.Trim(); i++; } _highTemp = Double.Parse(lines[0]); _lowTemp = Double.Parse(lines[1]); } } else { Debug.Print("No file"); _highTemp = 0; _lowTemp = 0; } }
public requestHandler(string webfolder, IRCommands commander, HIH6130 tempSensor, ACStatus AC, Timers timers, Credential credentials) { _webfolder = webfolder; _commander = commander; _sensor = tempSensor; _AC = AC; _timers = timers; _credentials = credentials; }