<div dir="ltr"><div>I was getting a lot of scope errors in my code, so I made my local declarations global.  It compiled.  So I asked  Claude.Sonnet to refactor the code, reducing the number of global variables.  Who knew refactoring is this simple:</div><div>// Configuration struct to contain all WiFi related settings<br>struct Config {<br>  // Access Point settings<br>  const char* ap_ssid = &quot;ESP32-Setup&quot;;<br>  const char* ap_password = &quot;password123&quot;;  // Minimum 8 characters<br>  IPAddress local_ip{192, 168, 1, 1};<br>  IPAddress gateway{192, 168, 1, 1};<br>  IPAddress subnet{255, 255, 255, 0};<br>  <br>  // Station mode credentials<br>  String station_ssid = &quot;&quot;;<br>  String station_password = &quot;&quot;;<br>  bool credentialsUpdated = false;<br>  <br>  // EEPROM settings<br>  static const int EEPROM_SIZE = 512;<br>  static const int SSID_ADDR = 0;<br>  static const int PASS_ADDR = 100;<br>  static const int FLAG_ADDR = 200;<br>  <br>  // GPIO pins<br>  static const int redLed = 27;<br>  static const int yellowLed = 26;<br>  static const int inSwitch = 25;<br>  <br>  // Connection timeout (ms)<br>  static const int timeout = 30000;<br>};<br><br>// Single global instance for configuration<br>Config config;<br></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">George Bowden  250-893-7423<div>Victoria BC</div><div>No ChatGPT used</div><div><br></div></div></div></div>