mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
Terminal
This commit is contained in:
22
include/CaptiveRequestHandler.h
Normal file
22
include/CaptiveRequestHandler.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <AsyncWebSocket.h>
|
||||
|
||||
class CaptiveRequestHandler : public AsyncWebHandler {
|
||||
public:
|
||||
CaptiveRequestHandler(const char *host);
|
||||
|
||||
virtual ~CaptiveRequestHandler();
|
||||
|
||||
bool canHandle(AsyncWebServerRequest *request) override;
|
||||
|
||||
void handleRequest(AsyncWebServerRequest *request) override;
|
||||
|
||||
private:
|
||||
bool isLocalIp(String name);
|
||||
bool isLocalName(String name);
|
||||
|
||||
private:
|
||||
char _local_name[32];
|
||||
IPAddress _local_ip;
|
||||
};
|
||||
@@ -1,5 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
enum TimerTask_t { WIFI_SCAN,
|
||||
WIFI_MQTT_CONNECTION_CHECK,
|
||||
SENSORS,
|
||||
STEPPER1,
|
||||
STEPPER2,
|
||||
LOG1,
|
||||
LOG2,
|
||||
LOG3,
|
||||
LOG4,
|
||||
LOG5,
|
||||
TIMER_COUNTDOWN,
|
||||
TIME,
|
||||
TIME_SYNC,
|
||||
STATISTICS,
|
||||
UPTIME,
|
||||
UDP,
|
||||
UDP_DB,
|
||||
TEST };
|
||||
|
||||
enum ErrorType_t {
|
||||
ET_NONE,
|
||||
ET_FUNCTION,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "UptimeInterval.h"
|
||||
#include "Clock.h"
|
||||
|
||||
#include "MqttClient.h"
|
||||
#include "Utils\FileUtils.h"
|
||||
#include "Utils\JsonUtils.h"
|
||||
#include "Utils\StringUtils.h"
|
||||
@@ -63,31 +64,13 @@ extern AsyncWebServer server;
|
||||
extern DallasTemperature sensors;
|
||||
|
||||
extern boolean but[NUM_BUTTONS];
|
||||
|
||||
extern Bounce* buttons;
|
||||
|
||||
/*
|
||||
* Global vars
|
||||
*/
|
||||
|
||||
enum { WIFI_SCAN,
|
||||
WIFI_MQTT_CONNECTION_CHECK,
|
||||
SENSORS,
|
||||
STEPPER1,
|
||||
STEPPER2,
|
||||
LOG1,
|
||||
LOG2,
|
||||
LOG3,
|
||||
LOG4,
|
||||
LOG5,
|
||||
TIMER_COUNTDOWN,
|
||||
TIME,
|
||||
TIME_SYNC,
|
||||
STATISTICS,
|
||||
UPTIME,
|
||||
UDP,
|
||||
UDP_DB,
|
||||
TEST };
|
||||
|
||||
extern boolean just_load;
|
||||
|
||||
extern String configSetupJson; //все настройки
|
||||
@@ -199,18 +182,6 @@ extern void servo_();
|
||||
|
||||
extern void setLedStatus(LedStatus_t);
|
||||
|
||||
// Mqtt
|
||||
extern void initMQTT();
|
||||
extern void loopMQTT();
|
||||
extern boolean connectMQTT();
|
||||
|
||||
extern boolean publishData(const String& topic, const String& data);
|
||||
extern boolean publishChart(const String& topic, const String& data);
|
||||
extern boolean publishStatus(const String& topic, const String& state);
|
||||
extern boolean publishControl(String id, String topic, String state);
|
||||
|
||||
extern void reconnectMQTT();
|
||||
|
||||
//Scenario
|
||||
extern void eventGen(String event_name, String number);
|
||||
extern String add_set(String param_name);
|
||||
|
||||
@@ -152,12 +152,12 @@ class Terminal : public Print {
|
||||
uint8_t curY = 0xff;
|
||||
uint8_t curX = 0xff;
|
||||
|
||||
unsigned long lastReceived = 0;
|
||||
unsigned long _lastReceived = 0;
|
||||
State state = ST_INACTIVE;
|
||||
Stream *_stream;
|
||||
EditLine _line;
|
||||
char cc_buf[32] = {0};
|
||||
size_t cc_pos = 0;
|
||||
char _cc_buf[32] = {0};
|
||||
size_t _cc_pos = 0;
|
||||
bool _color = false;
|
||||
bool _controlCodes = false;
|
||||
bool _echo = false;
|
||||
|
||||
27
include/MqttClient.h
Normal file
27
include/MqttClient.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace MqttClient {
|
||||
|
||||
void init();
|
||||
boolean connect();
|
||||
void reconnect();
|
||||
void loop();
|
||||
|
||||
void subscribe();
|
||||
|
||||
boolean publish(const String& topic, const String& data);
|
||||
boolean publishData(const String& topic, const String& data);
|
||||
boolean publishChart(const String& topic, const String& data);
|
||||
boolean publishControl(String id, String topic, String state);
|
||||
boolean publishChart_test(const String& topic, const String& data);
|
||||
boolean publishStatus(const String& topic, const String& data);
|
||||
|
||||
void publishWidgets();
|
||||
void publishState();
|
||||
|
||||
void handleSubscribedUpdates(char* topic, uint8_t* payload, size_t length);
|
||||
const String getStateStr();
|
||||
|
||||
} // namespace MqttClient
|
||||
@@ -39,4 +39,14 @@ int timeZoneInSeconds(const byte timeZone);
|
||||
|
||||
bool hasTimeSynced();
|
||||
|
||||
int getBiasInSeconds();
|
||||
int getBiasInSeconds();
|
||||
|
||||
/*
|
||||
* Время (мс) прошедщее с @simce
|
||||
*/
|
||||
unsigned long millis_since(unsigned long sinse);
|
||||
|
||||
/*
|
||||
* Интерввал времени (мс) между @start и @fimish
|
||||
*/
|
||||
unsigned long millis_passed(unsigned long start, unsigned long finish);
|
||||
Reference in New Issue
Block a user