mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-03 12:15:54 +02:00
fix compilation of ESP8266
This commit is contained in:
parent
10423d7476
commit
7336981c62
1 changed files with 13 additions and 3 deletions
|
@ -11,6 +11,8 @@
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
#define xSemaphoreTake(a, b) { while(a) { yield(); } a = true; }
|
||||||
|
#define xSemaphoreGive(a) { a = false; }
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,8 +41,12 @@ template<class HMSYSTEM>
|
||||||
class PubMqtt {
|
class PubMqtt {
|
||||||
public:
|
public:
|
||||||
PubMqtt() : SendIvData() {
|
PubMqtt() : SendIvData() {
|
||||||
mutex = xSemaphoreCreateBinaryStatic(&mutexBuffer);
|
#if defined(ESP32)
|
||||||
xSemaphoreGive(mutex);
|
mutex = xSemaphoreCreateBinaryStatic(&mutexBuffer);
|
||||||
|
xSemaphoreGive(mutex);
|
||||||
|
#else
|
||||||
|
mutex = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
mLastIvState.fill(InverterStatus::OFF);
|
mLastIvState.fill(InverterStatus::OFF);
|
||||||
mIvLastRTRpub.fill(0);
|
mIvLastRTRpub.fill(0);
|
||||||
|
@ -54,7 +60,9 @@ class PubMqtt {
|
||||||
}
|
}
|
||||||
|
|
||||||
~PubMqtt() {
|
~PubMqtt() {
|
||||||
|
#if defined(ESP32)
|
||||||
vSemaphoreDelete(mutex);
|
vSemaphoreDelete(mutex);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(IApp *app, cfgMqtt_t *cfg_mqtt, const char *devName, const char *version, HMSYSTEM *sys, uint32_t *utcTs, uint32_t *uptime) {
|
void setup(IApp *app, cfgMqtt_t *cfg_mqtt, const char *devName, const char *version, HMSYSTEM *sys, uint32_t *utcTs, uint32_t *uptime) {
|
||||||
|
@ -667,9 +675,11 @@ class PubMqtt {
|
||||||
IApp *mApp;
|
IApp *mApp;
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
WiFiEventHandler mHWifiCon, mHWifiDiscon;
|
WiFiEventHandler mHWifiCon, mHWifiDiscon;
|
||||||
#endif
|
volatile bool mutex;
|
||||||
|
#else
|
||||||
SemaphoreHandle_t mutex;
|
SemaphoreHandle_t mutex;
|
||||||
StaticSemaphore_t mutexBuffer;
|
StaticSemaphore_t mutexBuffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
HMSYSTEM *mSys = nullptr;
|
HMSYSTEM *mSys = nullptr;
|
||||||
PubMqttIvData<HMSYSTEM> SendIvData;
|
PubMqttIvData<HMSYSTEM> SendIvData;
|
||||||
|
|
Loading…
Add table
Reference in a new issue