<!doctype html><htmllang="en"class="no-js"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width,initial-scale=1"><metahttp-equiv="x-ua-compatible"content="ie=edge"><metaname="description"content="ESP8266/ESP32 WLAN configuration at run time with web interface"><linkrel="canonical"href="https://Hieromon.github.io/AutoConnect/credit.html"><metaname="author"content="Hieromon Ikasamo"><metaname="lang:clipboard.copy"content="Copy to clipboard"><metaname="lang:clipboard.copied"content="Copied to clipboard"><metaname="lang:search.language"content="en"><metaname="lang:search.pipeline.stopwords"content="True"><metaname="lang:search.pipeline.trimmer"content="True"><metaname="lang:search.result.none"content="No matching documents"><metaname="lang:search.result.one"content="1 matching document"><metaname="lang:search.result.other"content="# matching documents"><metaname="lang:search.tokenizer"content="[\s\-]+"><linkrel="shortcut icon"href="assets/images/favicon.png"><metaname="generator"content="mkdocs-1.0.4, mkdocs-material-4.3.1"><title>Saved credentail access - AutoConnect for ESP8266/ESP32</title><linkrel="stylesheet"href="assets/stylesheets/application.4031d38b.css"><linkrel="stylesheet"href="assets/stylesheets/application-palette.224b79ff.css"><metaname="theme-color"content="#3f51b5"><scriptsrc="assets/javascripts/modernizr.74668098.js"></script><linkhref="https://fonts.gstatic.com"rel="preconnect"crossorigin><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono&display=swap"><style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style><linkrel="stylesheet"href="assets/fonts/material-icons.css"><linkrel="stylesheet"href="css/paragraph.css"><linkrel="stylesheet"href="css/extra.css"><linkrel="stylesheet"href="https://use.fontawesome.com/releases/v5.6.1/css/all.css"><script>window.ga=window.ga||function(){
<p>AutoConnect stores the established WiFi connection in the EEPROM of the ESP8266/ESP32 module and equips the class to access it from the sketch. You can read, write or erase the credentials using this class individually. It's <ahref="#autoconnectcredential"><strong>AutoConnectCredential</strong></a> class which provides the access method to the saved credentials in EEPROM.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1"rel="footnote">1</a></sup></p>
<p>AutoConnectCredential default constructor. The default offset value is 0. If the offset value is 0, the credential area starts from the top of the EEPROM. AutoConnect sometimes overwrites data when using this area with user sketch.</p>
<dd><spanclass="apidef">offset</span><spanclass="apidesc">Species offset from the top of the EEPROM for the credential area together. The offset value is from 0 to the flash sector size.</span></dd>
</dl></p>
<h3id="public-member-functions"><iclass="fa fa-code"></i> Public member functions<aclass="headerlink"href="#public-member-functions"title="Permanent link">¶</a></h3>
<dd>Save the specified SSID's credential entry to station_config pointed to by the parameter as <strong>config</strong>. -1 is returned if the SSID is not saved. </dd>
<dd>Save the specified credential entry to station_config pointed to by the parameter as <strong>config</strong>. -1 is returned if specified number is not saved. </dd>
<h3id="the-credential-entry"><iclass="fa fa-code"></i> The credential entry<aclass="headerlink"href="#the-credential-entry"title="Permanent link">¶</a></h3>
<p>A data structure of the credential saving area in EEPROM as the below. <supid="fnref:2"><aclass="footnote-ref"href="#fn:2"rel="footnote">2</a></sup></p>
<table>
<thead>
<tr>
<th>Byte offset</th>
<th>Length</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>8</td>
<td>AC_CREDT</td>
</tr>
<tr>
<td>8</td>
<td>1</td>
<td>Number of contained entries (uint8_t)</td>
</tr>
<tr>
<td>9</td>
<td>2</td>
<td>Container size, excluding size of AC_CREDT and size of the number of entries(width for uint16_t type).</td>
</tr>
<tr>
<td>11</td>
<td>variable</td>
<td>SSID terminated by 0x00. Max length is 32 bytes.</td>
</tr>
<tr>
<td>variable</td>
<td>variable</td>
<td>Password plain text terminated by 0x00. Max length is 64 bytes.</td>
</tr>
<tr>
<td>variable</td>
<td>6</td>
<td>BSSID</td>
</tr>
<tr>
<td>variable</td>
<td></td>
<td>Contained the next entries. (Continuation SSID+Password+BSSID)</td>
</tr>
<tr>
<td>variable</td>
<td>1</td>
<td>0x00. End of container.</td>
</tr>
</tbody>
</table>
<divclass="footnote">
<hr/>
<ol>
<liid="fn:1">
<p>An example using AutoConnectCredential is provided as <ahref="https://github.com/Hieromon/AutoConnect/blob/master/examples/Credential/Credential.ino">an example</a> of a library sketch to delete saved credentials. <aclass="footnote-backref"href="#fnref:1"rev="footnote"title="Jump back to footnote 1 in the text">↩</a></p>
</li>
<liid="fn:2">
<p>There may be 0xff as an invalid data in the credential saving area. The 0xff area would be reused. <aclass="footnote-backref"href="#fnref:2"rev="footnote"title="Jump back to footnote 2 in the text">↩</a></p>