Few extra comments

main
xad1 3 years ago
parent 110bda8f5e
commit 9ed49d95ba

@ -2,6 +2,7 @@
#define JSON_RETRIEVE_H
#include <ArduinoJson.h>
/// @brief Struct to store information about a node in appropriate data types.
typedef struct {
String name;
float cpu;
@ -14,6 +15,7 @@ typedef struct {
long long uptime;
} Node;
/// @brief Struct to store information about a container in appropriate data types.
typedef struct {
String name;
int id;
@ -23,6 +25,7 @@ typedef struct {
long long uptime;
} Container;
/// @brief Struct to store information about a VM in appropriate data types.
typedef struct {
String name;
int id;
@ -34,7 +37,7 @@ typedef struct {
long long netout;
} VM;
/// @brief Struct to store information about a disk in appropriate data types.
typedef struct {
String devpath;
long long size;
@ -45,6 +48,7 @@ typedef struct {
String health;
} Disk;
/// @brief Struct to store information about a pool in appropriate data types.
typedef struct {
String name;
long long free;
@ -52,12 +56,14 @@ typedef struct {
String health;
} Pool;
// Function declarations
Node *getNodeInfo(int &numNodes);
Container *getContainerInfo(int &numContainers, const String &node);
VM *getVMInfo(int &numVMs, const String &node);
Disk *getDiskInfo(int &numDisks, const String &node);
Pool *getPoolInfo(int &numPools, const String &node);
/// @brief Template for a callback function for processing JSON data in to an appropriate struct.
typedef void (*ProcessDataCallback)(DynamicJsonDocument&, int&, void*&);

@ -1,6 +1,8 @@
#ifndef JSON_SEND_H
#define JSON_SEND_H
#include <Arduino.h>
// Function declarations
void restartVM(const String &node, const int &vmid);
void restartContainer(const String &node, const int &containerid);
void startVM(const String &node, const int &vmid);

@ -2,7 +2,8 @@
#define JSON_UTILS_H
#include <ArduinoJson.h>
#include <json/retrieve.h>
//JsonObject getNode(String name, JsonArray nodes);
// Function declarations
Node getNode(const String &name);
Container getContainer(const int &id, const String &node);
VM getVM(const int &id, const String &node);

@ -1,6 +1,7 @@
#ifndef MANAGE_H
#define MANAGE_H
// Function declarations
void vmRestart();
void containerRestart();
void vmStart();

@ -3,12 +3,14 @@
#include <Arduino.h>
#include <json/retrieve.h>
// Struct for static menu items such as on the main menu. Has the name of the menu item and a function to run when it is selected.
/// @brief Struct for static menu items such as on the main menu. Has the name of the menu item and a function to run when it is selected.
typedef struct {
String name;
void (*function)();
} MenuItem;
// Function declarations
void listNodes(Node* nodes, const int &numItems);
int listContainers(Container* containers, const int &numItems);
int listVMs(VM* vms, const int &numItems);
@ -18,11 +20,16 @@ void mainMenu();
void manageContainerMenu();
void manageVMMenu();
/// @brief Template for a callback function to print a menu entry.
typedef void (*MenuPrintCallback)(void*);
/// @brief Variable to hold the currently selected menu item index.
extern int selectedItem;
/// @brief Variable to hold the currently selected page index.
extern int selectedPage;
/// @brief Variable to hold the name of the selected node.
extern String selectedNode;
#endif

@ -1,6 +1,8 @@
#ifndef PIN_H
#define PIN_H
#include <Arduino.h>
/// @brief Constant which holds the pin code.
const String LOCK_PIN = "";
/**
* 0 = A Button

@ -2,14 +2,22 @@
#ifndef SERVER_H_
#define SERVER_H_
/**
* Enter WiFi network and Proxmox information
*
*/
/// @brief Address of the Proxmox server being connected to. Do not add a trailing '/'. E.g. https://10.10.10.10:8006
const String PROXMOX_ADDRESS = "";
/// @brief Proxmox token user. E.g. root@pam
const String PROXMOX_TOKEN_USER = "";
/// @brief Name of the Proxmox token.
const String PROXMOX_TOKEN_NAME = "";
/// @brief Proxmox token secret key. E.g. 0ec1060d-a4a0-4975-a624-ea5cc49ee04e
const String PROXMOX_TOKEN_SECRET = "";
#endif

@ -1,5 +1,7 @@
#ifndef STATISTICS_H
#define STATISTICS_H
// Function declarations
void nodeInfo();
void containerInfo();
void vmInfo();

@ -2,8 +2,10 @@
#define UTILS_H
#include <Arduino.h>
// Function declarations
void displayError(String message);
void connectWiFi();
bool enterPin();
int pinListener();
#endif /* UTILS_H */

@ -2,10 +2,13 @@
#define WIFI_H_
/**
* Enter WiFi network and Proxmox information
* Enter WiFi network information
*/
/// @brief The SSID of the WiFi network to connect to.
const char* WIFI_SSID = "";
/// @brief The password of the WiFi network to connect to.
const char* WIFI_PASS = "";
#endif

@ -33,6 +33,7 @@ void restartVM(const String &node, const int &vmid)
apiSend(apiPath, "");
}
/// @brief The function to restart a given container. Calls the apiSend() function with the appropriate parameters to restart a container.
/// @param node A reference to a string which contains the name of the node that is running the container that is being restarted.
/// @param containerid A reference to an integer which holds the ID of the container being restarted.

@ -7,6 +7,11 @@
#include <json/retrieve.h>
#include <pin.h>
/**
* @brief The main loop of the program. Runs the node selection screen, followed by the main menu.
* In the case of any errors the program will start this loop again.
*/
void loop()
{
// Check if still connected to a WiFi network. If not then display this to the user and then attempt to reconnect.
@ -39,6 +44,10 @@ void loop()
}
}
/**
* @brief Initial setup of the program. Run the pin system before attempting WiFi connection.
* Setup ends after successful connection to a WiFi network.
*/
void setup()
{
Serial.begin(115200);

Loading…
Cancel
Save