ESP8266 Updater¶
-
class
FFUpdates
¶ Provides an abstraction layer for the user to update their device. Piggy backs off of the ESP8266httpUpdate class. The additional functionality provided by this library includes handling changes made to the server’s ssl certificate fingerpint.
Public Functions
-
FFUpdates
()¶ Default Constructor for the FFUpdates class. Creates the object but does not intialize any data. Requires the user to provide the token_SHA256 and user_token via the set methods.
-
FFUpdates
(String user_token, String user_secret)¶ Basic Constructor for the FFUpdates class, initializes object data such as token_SHA256.
- Parameters
user_token
: The token provided to the user on their profile page.user_secret
: The token provided to the user for the specific device, can be found on the devices page on the device’s card.
-
void
enable_debug
(bool debug)¶ Enable/disable debug.
- Parameters
debug
: enable or disable debugging by passing true or false respectively.
-
String
get_user_token
()¶ Returns the user token.
- Return
the stored user token.
-
void
set_user_token
(String user_token)¶ Sets the user token.
- Parameters
user_token
: Token provided to the user on their profile page.
-
String
get_user_secret
()¶ Gets the device token.
- Return
device token
-
void
set_user_secret
(String user_secret)¶ Sets the device token.
- Parameters
user_secret
: Secret provided to user on their profile page.
-
String
get_token_SHA256
()¶ Returns the token_SHA256 hash.
- Return
the stored token hash.
-
void
set_token_SHA256
(String token_SHA256)¶ Sets the token_SHA256 hash.
- Parameters
token_SHA256
: Previously calculated SHA256 hash of the user token and user secret.
-
void
print_SHA256
()¶ Prints the sha256 has that the device has calculated. Meant more for debugging than for user usage.
-
String
get_fingerprint
()¶ Gets the stored server fingerprint.
- Return
the stored fingerprint.
-
void
set_fingerprint
(String fingerprint)¶ Sets the current server fingerprint.
- Parameters
fingerprint
: last known valid fingerprint of the SSL cert.
-
void
renewFingerprint
()¶ Asks the server for it’s ssl certificate’s sha1 fingerprint.
The certificate will change every so often due to it expiring, in that event, the device needs to grab the new one so that it may communicate over https. To do this, the device will ask the serverfor its certificate fingerprint and for a challenge token. This token is the sha256 hash value of the device owner’s user secret combined with the device owner’s user token. Both the device and the server will know this value and can calculate it independent of one another. If the hash passed from the server matches what the device has calculated, the fingerprint is accepted and will be used to establish secure communicates with the authentic server. This hash is transmitted in encrypted form using AES256 in CBC mode.
The user never needs to call this funciton directly, update will call it in the event that the fingerprint has changed. This function has been left as public so that the user can call this if they ever choose to, although there is really no reason to.
-
void
update
()¶ Checks to see if there is an update available for the device. If there is, the update is downloaded and applied. Otherwise, its business as usual.
The user is required to determine the update interval. For instance, if you want to check for an update 5 times an hour, then you would need to implement a clock function that calls update 5 times an hour.
-