2020-10-13 17:01:29 +02:00
|
|
|
#ifndef OMOBI_LED_DISPLAY
|
|
|
|
#define OMOBI_LED_DISPLAY
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <ArduinoJson.h>
|
2020-10-15 22:54:20 +02:00
|
|
|
#include "mbedtls/md.h"
|
|
|
|
#include "EepromManager.h"
|
2020-10-13 17:01:29 +02:00
|
|
|
#include "BluetoothLeUartServer.h"
|
|
|
|
#include "LedDisplayController.h"
|
|
|
|
|
2020-10-14 23:54:54 +02:00
|
|
|
class OmobiLedDisplay : protected BluetoothLeUartServerCallbacks
|
|
|
|
{
|
2020-10-13 17:01:29 +02:00
|
|
|
|
|
|
|
public:
|
2020-10-14 23:54:54 +02:00
|
|
|
explicit OmobiLedDisplay(String deviceName, Adafruit_NeoMatrix *ledDisplayMatrix);
|
2020-10-13 17:01:29 +02:00
|
|
|
|
2020-10-14 23:54:54 +02:00
|
|
|
// befriend for callbacks
|
|
|
|
friend class BluetoothLeUartServer;
|
2020-10-13 17:01:29 +02:00
|
|
|
|
2020-10-15 16:58:06 +02:00
|
|
|
void loop();
|
|
|
|
|
2020-10-13 17:01:29 +02:00
|
|
|
protected:
|
2020-10-14 23:54:54 +02:00
|
|
|
// calbacks for BluetoothLeUartServerCallbacks
|
|
|
|
void onDeviceConnectedChanged(bool deviceConnected) override;
|
2020-10-13 17:01:29 +02:00
|
|
|
void onDataReceived(String data) override;
|
|
|
|
|
|
|
|
private:
|
2020-10-14 23:54:54 +02:00
|
|
|
enum OmobiDisplayCommand
|
|
|
|
{
|
2020-10-15 16:58:06 +02:00
|
|
|
AuthorizeSessionCommand = 0,
|
|
|
|
KeepAliveCommand = 1,
|
2020-10-14 23:54:54 +02:00
|
|
|
GetAllTextSetsCommand = 10,
|
|
|
|
GetTextSetParameterCommand = 11,
|
|
|
|
GetDisplayBrightnessCommand = 12,
|
|
|
|
SetTextSetParameterCommand = 20,
|
2020-10-17 03:22:37 +02:00
|
|
|
SetDisplayBrightnessCommand = 21,
|
|
|
|
SetDisplayCodeCommand = 22,
|
|
|
|
SetDisplayNameCommand = 23
|
2020-10-14 23:54:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum OmobiDisplayStatusCode
|
|
|
|
{
|
|
|
|
Success = 200,
|
2020-10-17 03:22:37 +02:00
|
|
|
BadRequestError = 400,
|
2020-10-15 22:54:20 +02:00
|
|
|
Unauthorized = 401,
|
2020-10-14 23:54:54 +02:00
|
|
|
InternalError = 500,
|
|
|
|
DisplayControllerError = 501
|
|
|
|
};
|
|
|
|
|
2020-10-15 16:58:06 +02:00
|
|
|
unsigned long lastKeepAlive;
|
|
|
|
const int maximumKeepAliveDelay = 10000;
|
2020-10-15 22:54:20 +02:00
|
|
|
bool sessionAuthorized;
|
2020-10-15 16:58:06 +02:00
|
|
|
|
2020-10-15 22:54:20 +02:00
|
|
|
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);
|
2020-10-13 17:01:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OMOBI_LED_DISPLAY
|