LedDisplay/vscode/OmobiLEDdisplayBluetooth/include/OmobiLedDisplay.h

73 lines
No EOL
1.7 KiB
C++

#ifndef OMOBI_LED_DISPLAY
#define OMOBI_LED_DISPLAY
#include <Arduino.h>
#include <ArduinoJson.h>
#include "mbedtls/md.h"
#include "EepromManager.h"
#include "BluetoothLeUartServer.h"
#include "LedDisplayController.h"
class OmobiLedDisplay : protected BluetoothLeUartServerCallbacks
{
public:
explicit OmobiLedDisplay(String deviceName, Adafruit_NeoMatrix *ledDisplayMatrix);
// befriend for callbacks
friend class BluetoothLeUartServer;
void loop();
protected:
// calbacks for BluetoothLeUartServerCallbacks
void onDeviceConnectedChanged(bool deviceConnected) override;
void onDataReceived(String data) override;
private:
enum OmobiDisplayCommand
{
AuthorizeSessionCommand = 0,
KeepAliveCommand = 1,
GetAllTextSetsCommand = 10,
GetTextSetParameterCommand = 11,
GetDisplayBrightnessCommand = 12,
SetTextSetParameterCommand = 20,
SetDisplayBrightnessCommand = 21,
SetDisplayCodeCommand = 22,
SetDisplayNameCommand = 23
};
enum OmobiDisplayStatusCode
{
Success = 200,
BadRequestError = 400,
Unauthorized = 401,
InternalError = 500,
DisplayControllerError = 501
};
unsigned long lastKeepAlive;
const int maximumKeepAliveDelay = 10000;
bool sessionAuthorized;
typedef struct {
char deviceName[50];
char deviceCode[5];
char valid[3];
} DisplayProperties;
DisplayProperties properties;
EepromManager* eepromManager;
EepromUnit* eepromUnit;
LedDisplayController* ledDisplayController;
BluetoothLeUartServer* bleServer;
bool loadProperties();
bool storeProperties();
String sha256(String payload);
};
#endif // OMOBI_LED_DISPLAY