Magic Poi Lite 0.1
IOT LED Poi
Loading...
Searching...
No Matches
Authentication.h
Go to the documentation of this file.
1#ifndef AUTHENTICATION_H
2#define AUTHENTICATION_H
3
4#include <Arduino.h>
5#include <WiFiClient.h>
6
7/**
8 * @file Authentication.h
9 * @brief Declaration of the Authentication class.
10 */
11
13public:
14 Authentication(); // Constructor declaration
15 String readJWTTokenFromFile();
16 void saveJWTTokenToFile(const char *token);
17 bool authenticate();
18 bool checkSavedToken();
19
20private:
21 /**
22 * @brief Buffer for JWT token.
23 *
24 * This buffer stores the JWT token retrieved from authentication.
25 */
26 char token[500];
27
28 /**
29 * @brief Buffer for JWT token.
30 *
31 * This buffer stores the JWT token retrieved from LittleFS.
32 */
33 char jwtToken[500];
34
35 /**
36 * @brief Flag indicating whether a token has been retrieved.
37 */
38 boolean gotToken = false;
39
40 /**
41 * @brief Path to the file storing JWT token.
42 *
43 * This string represents the file path of the file storing the JWT token in LittleFS.
44 */
45 const char *jwtFilePath = "/jwt.txt";
46
47 /**
48 * @brief WiFi client object.
49 *
50 * This object is used for network communication with the server.
51 */
52 WiFiClient client;
53};
54
55#endif
Definition Authentication.h:12
WiFiClient client
WiFi client object.
Definition Authentication.h:52
bool checkSavedToken()
Checks for a saved JWT token and loads it if available.
Definition Authentication.cpp:177
void saveJWTTokenToFile(const char *token)
Saves a JWT token to a file on LittleFS.
Definition Authentication.cpp:83
char jwtToken[500]
Buffer for JWT token.
Definition Authentication.h:33
Authentication()
Default constructor for Authentication class.
Definition Authentication.cpp:23
boolean gotToken
Flag indicating whether a token has been retrieved.
Definition Authentication.h:38
char token[500]
Buffer for JWT token.
Definition Authentication.h:26
String readJWTTokenFromFile()
Reads JWT token from a file stored on LittleFS.
Definition Authentication.cpp:39
bool authenticate()
Authenticates the client with the server.
Definition Authentication.cpp:117
const char * jwtFilePath
Path to the file storing JWT token.
Definition Authentication.h:45