Attachment 'credentials.c'

Download

   1 /** Load WLAN credentials from EEPROM */
   2 void loadCredentials() {
   3   EEPROM.begin(512);
   4   EEPROM.get(0, ssid);
   5   EEPROM.get(0+sizeof(ssid), password);
   6   char ok[2+1];
   7   EEPROM.get(0+sizeof(ssid)+sizeof(password), ok);
   8   EEPROM.end();
   9   if (String(ok) != String("OK")) {
  10     ssid[0] = 0;
  11     password[0] = 0;
  12   }
  13   Serial.println("Recovered credentials:");
  14   Serial.println(ssid);
  15   Serial.println(strlen(password)>0?"********":"<no password>");
  16 }
  17 
  18 /** Store WLAN credentials to EEPROM */
  19 void saveCredentials() {
  20   EEPROM.begin(512);
  21   EEPROM.put(0, ssid);
  22   EEPROM.put(0+sizeof(ssid), password);
  23   char ok[2+1] = "OK";
  24   EEPROM.put(0+sizeof(ssid)+sizeof(password), ok);
  25   EEPROM.commit();
  26   EEPROM.end();
  27 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2015-12-20 15:34:00, 3.3 KB) [[attachment:GetTemp.c]]
  • [get | view] (2015-12-18 19:00:00, 79.9 KB) [[attachment:Thingspeak_WarmWasser.png]]
  • [get | view] (2015-12-21 15:53:00, 11.9 KB) [[attachment:WiFiLoggerOneWire.c]]
  • [get | view] (2015-12-20 15:35:00, 1.0 KB) [[attachment:WiFiLoggerOneWire.h]]
  • [get | view] (2015-12-15 21:02:00, 77.5 KB) [[attachment:WiFiLoggerOneWireVZ.png]]
  • [get | view] (2015-12-20 15:05:00, 103.1 KB) [[attachment:WiFiLoggerOneWire_config.png]]
  • [get | view] (2015-12-18 19:51:00, 89.0 KB) [[attachment:WiFiLogger_DSC06322.jpg]]
  • [get | view] (2016-05-08 10:40:00, 36.5 KB) [[attachment:WiFiLogger_screenshot.png]]
  • [get | view] (2016-06-20 05:37:00, 35.1 KB) [[attachment:WiFiLogger_screenshot2.png]]
  • [get | view] (2015-12-15 14:38:00, 100.5 KB) [[attachment:WiFi_Logger_DSC06319.jpg]]
  • [get | view] (2015-12-20 15:33:00, 0.7 KB) [[attachment:credentials.c]]
  • [get | view] (2015-12-20 15:33:00, 3.9 KB) [[attachment:getNTPtime.c]]
  • [get | view] (2015-12-20 15:34:00, 5.4 KB) [[attachment:handleHTTP.c]]
  • [get | view] (2015-12-20 15:35:00, 0.4 KB) [[attachment:tools.c]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.