static void Init() { //Load sound files PinVoiceTools.Init(); //Set servo ServoTool.Init(); //Load pin codes codes = File.ReadAllLines("Assets\\codes.txt"); //Load the current saved index, if any if (File.Exists("Session\\location.txt")) { pinIndex = int.Parse(File.ReadAllText("Session\\location.txt")); } else { pinIndex = 0; } //Start HTTP server listener = new HttpListener(); listener.Prefixes.Add("http://10.0.1.12:80/"); listener.Start(); listener.BeginGetContext(OnGetRequst, null); }
static void RunCycle() { //Press button to start ServoTool.PressButton(); //Delay a small amount Thread.Sleep(1000); //Run attempts RunAttempt(); RunAttempt(); RunAttempt(); //Wait a little bit at the end Thread.Sleep(300); }
static void RunAttempt() { //Log Console.WriteLine($"[ATTEMPT] Attempting {codes[pinIndex]}, index {pinIndex}"); //Push button ServoTool.PressButton(); //Delay Thread.Sleep(600); //Speak code PinVoiceTools.PlayPinCode(codes[pinIndex]); //Delay Thread.Sleep(1000); //Begin recording ResponseRecordTools.RecordResponse($"Session\\attempt_{pinIndex}", 5000); //Add to current value and save pinIndex++; File.WriteAllText("Session\\location.txt", pinIndex.ToString()); }