mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 17:29:50 +03:00
make standalone compile
This commit is contained in:
@@ -51,9 +51,9 @@ int main(int argc __attribute__((unused)), char * argv[] __attribute__((unused))
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long millis() {
|
||||
return __millis;
|
||||
}
|
||||
// unsigned long millis() {
|
||||
// return __millis;
|
||||
// }
|
||||
|
||||
int64_t esp_timer_get_time() {
|
||||
return __millis;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <iostream>
|
||||
|
||||
// #define IPAddress std::string
|
||||
#define IPAddress String
|
||||
// #define IPAddress String
|
||||
|
||||
#define ICACHE_FLASH_ATTR
|
||||
#define ICACHE_RAM_ATTR
|
||||
@@ -171,7 +171,13 @@ extern NativeConsole Serial;
|
||||
extern ETHClass ETH;
|
||||
extern WiFiClass WiFi;
|
||||
|
||||
unsigned long millis();
|
||||
// unsigned long millis();
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <chrono> // NOLINT [build/c++11]
|
||||
#include <thread> // NOLINT [build/c++11] for yield()
|
||||
#define millis() std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count()
|
||||
#endif
|
||||
|
||||
int64_t esp_timer_get_time();
|
||||
|
||||
|
||||
@@ -112,6 +112,11 @@ class ESP8266React {
|
||||
return _mqttClient;
|
||||
}
|
||||
|
||||
void setWill(const char * will_topic) {
|
||||
}
|
||||
void onMessage(espMqttClientTypes::OnMessageCallback callback) {
|
||||
}
|
||||
|
||||
StatefulService<DummySettings> * getNetworkSettingsService() {
|
||||
return &_settings;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <functional>
|
||||
#include <IPAddress.h>
|
||||
|
||||
#define WiFiMode_t wifi_mode_t
|
||||
#define WIFI_OFF WIFI_MODE_NULL
|
||||
|
||||
0
lib_standalone/avr/pgmspace.h
Normal file
0
lib_standalone/avr/pgmspace.h
Normal file
@@ -1,130 +0,0 @@
|
||||
#ifndef ESPMQTTCLIENT_H_
|
||||
#define ESPMQTTCLIENT_H_
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <functional>
|
||||
|
||||
namespace espMqttClientTypes {
|
||||
|
||||
enum class DisconnectReason : uint8_t {
|
||||
USER_OK = 0,
|
||||
MQTT_UNACCEPTABLE_PROTOCOL_VERSION = 1,
|
||||
MQTT_IDENTIFIER_REJECTED = 2,
|
||||
MQTT_SERVER_UNAVAILABLE = 3,
|
||||
MQTT_MALFORMED_CREDENTIALS = 4,
|
||||
MQTT_NOT_AUTHORIZED = 5,
|
||||
TLS_BAD_FINGERPRINT = 6,
|
||||
TCP_DISCONNECTED = 7
|
||||
};
|
||||
const char * disconnectReasonToString(DisconnectReason reason);
|
||||
|
||||
enum class SubscribeReturncode : uint8_t { QOS0 = 0x00, QOS1 = 0x01, QOS2 = 0x02, FAIL = 0X80 };
|
||||
const char * subscribeReturncodeToString(SubscribeReturncode returnCode);
|
||||
|
||||
enum class Error : uint8_t { SUCCESS = 0, OUT_OF_MEMORY = 1, MAX_RETRIES = 2, MALFORMED_PARAMETER = 3, MISC_ERROR = 4 };
|
||||
const char * errorToString(Error error);
|
||||
|
||||
struct MessageProperties {
|
||||
uint8_t qos;
|
||||
bool dup;
|
||||
bool retain;
|
||||
uint16_t packetId;
|
||||
};
|
||||
|
||||
typedef std::function<void(bool sessionPresent)> OnConnectCallback;
|
||||
typedef std::function<void(DisconnectReason reason)> OnDisconnectCallback;
|
||||
typedef std::function<void(uint16_t packetId, const SubscribeReturncode * returncodes, size_t len)> OnSubscribeCallback;
|
||||
typedef std::function<void(uint16_t packetId)> OnUnsubscribeCallback;
|
||||
typedef std::function<void(const MessageProperties & properties, const char * topic, const uint8_t * payload, size_t len, size_t index, size_t total)> OnMessageCallback;
|
||||
typedef std::function<void(uint16_t packetId)> OnPublishCallback;
|
||||
typedef std::function<size_t(uint8_t * data, size_t maxSize, size_t index)> PayloadCallback;
|
||||
typedef std::function<void(uint16_t packetId, Error error)> OnErrorCallback;
|
||||
|
||||
} // namespace espMqttClientTypes
|
||||
|
||||
class espMqttClient {
|
||||
public:
|
||||
espMqttClient();
|
||||
~espMqttClient();
|
||||
|
||||
espMqttClient & setKeepAlive(uint16_t keepAlive);
|
||||
espMqttClient & setClientId(const char * clientId);
|
||||
espMqttClient & setCleanSession(bool cleanSession);
|
||||
espMqttClient & setMaxTopicLength(uint16_t maxTopicLength);
|
||||
espMqttClient & setCredentials(const char * username, const char * password = nullptr);
|
||||
espMqttClient & setWill(const char * topic, uint8_t qos, bool retain, const char * payload = nullptr, size_t length = 0) {
|
||||
return *this;
|
||||
}
|
||||
espMqttClient & setServer(IPAddress ip, uint16_t port);
|
||||
espMqttClient & setServer(const char * host, uint16_t port);
|
||||
|
||||
espMqttClient & onConnect(espMqttClientTypes::OnConnectCallback callback) {
|
||||
return *this;
|
||||
}
|
||||
espMqttClient & onDisconnect(espMqttClientTypes::OnDisconnectCallback callback) {
|
||||
return *this;
|
||||
}
|
||||
espMqttClient & onSubscribe(espMqttClientTypes::OnSubscribeCallback callback) {
|
||||
return *this;
|
||||
}
|
||||
espMqttClient & onUnsubscribe(espMqttClientTypes::OnUnsubscribeCallback callback) {
|
||||
return *this;
|
||||
}
|
||||
espMqttClient & onMessage(espMqttClientTypes::OnMessageCallback callback) {
|
||||
return *this;
|
||||
}
|
||||
espMqttClient & onPublish(espMqttClientTypes::OnPublishCallback callback) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool connected() const {
|
||||
return false;
|
||||
}
|
||||
void connect() {
|
||||
}
|
||||
void disconnect(bool force = false) {
|
||||
}
|
||||
uint16_t subscribe(const char * topic, uint8_t qos) {
|
||||
return 1;
|
||||
}
|
||||
uint16_t unsubscribe(const char * topic) {
|
||||
return 1;
|
||||
}
|
||||
uint16_t publish(const char * topic, uint8_t qos, bool retain, const char * payload = nullptr, size_t length = 0, bool dup = false, uint16_t message_id = 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * getClientId() {
|
||||
return "12";
|
||||
}
|
||||
|
||||
uint16_t getQueue() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
bool _connected;
|
||||
bool _connectPacketNotEnoughSpace;
|
||||
bool _disconnectOnPoll;
|
||||
bool _tlsBadFingerprint;
|
||||
uint32_t _lastClientActivity;
|
||||
uint32_t _lastServerActivity;
|
||||
uint32_t _lastPingRequestTime;
|
||||
char _generatedClientId[18 + 1]; // esp8266-abc123 and esp32-abcdef123456
|
||||
IPAddress _ip;
|
||||
const char * _host;
|
||||
bool _useIp;
|
||||
uint16_t _port;
|
||||
uint16_t _keepAlive;
|
||||
bool _cleanSession;
|
||||
const char * _clientId;
|
||||
const char * _username;
|
||||
const char * _password;
|
||||
const char * _willTopic;
|
||||
const char * _willPayload;
|
||||
uint16_t _willPayloadLength;
|
||||
uint8_t _willQos;
|
||||
bool _willRetain;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user