Skip to content

Commit

Permalink
Fixing headers for gateway modules (#1554)
Browse files Browse the repository at this point in the history
* Fixing red squiggles in VSCode/PlatformIO

* Lint issues
  • Loading branch information
NorthernMan54 authored Mar 28, 2023
1 parent 08279ba commit bf004b0
Show file tree
Hide file tree
Showing 20 changed files with 83 additions and 34 deletions.
43 changes: 43 additions & 0 deletions main/User_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,4 +670,47 @@ CRGB leds2[FASTLED_IND_NUM_LEDS];
#define displayPrint(...) // only print if not in low power mode
#define lpDisplayPrint(...) // print in low power mode

/*----------- SHARED WITH OMG MODULES --------------*/

char mqtt_topic[parameters_size + 1] = Base_Topic;
char gateway_name[parameters_size + 1] = Gateway_Name;

unsigned long uptime();
bool cmpToMainTopic(const char*, const char*);
void pub(const char*, const char*, bool);
// void pub(const char*, JsonObject&);
void pub(const char*, const char*);
// void pub_custom_topic(const char*, JsonObject&, boolean);

#if defined(ESP32)
# include <Preferences.h>
Preferences preferences;
#endif

#ifdef ZmqttDiscovery
bool disc = true; // Auto discovery with Home Assistant convention
unsigned long lastDiscovery = 0; // Time of the last discovery to trigger automaticaly to off after DiscoveryAutoOffTimer
#endif

#if defined(ESP8266) || defined(ESP32)
# include <vector>
// Flags definition for white list, black list, discovery management
# define device_flags_init 0 << 0
# define device_flags_isDisc 1 << 0
# define device_flags_isWhiteL 1 << 1
# define device_flags_isBlackL 1 << 2
# define device_flags_connect 1 << 3
# define isWhite(device) device->isWhtL
# define isBlack(device) device->isBlkL
# define isDiscovered(device) device->isDisc
#endif

#if defined(ZgatewayRF) || defined(ZgatewayIR) || defined(ZgatewaySRFB) || defined(ZgatewayWeatherStation) || defined(ZgatewayRTL_433)
bool isAduplicateSignal(SIGNAL_SIZE_UL_ULL);
void storeSignalValue(SIGNAL_SIZE_UL_ULL);
#endif

#define convertTemp_CtoF(c) ((c * 1.8) + 32)
#define convertTemp_FtoC(f) ((f - 32) * 5 / 9)

#endif
1 change: 1 addition & 0 deletions main/config_ADC.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

extern void setupADC();
extern void ADCtoMQTT();
extern void MeasureADC();
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define ADCTOPIC "/ADCtoMQTT"
Expand Down
4 changes: 2 additions & 2 deletions main/config_AHTx0.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#ifndef config_AHTx0_h
#define config_AHTx0_h

extern void setupAHTx0();
extern void AHTx0toMQTT();
extern void setupZsensorAHTx0();
extern void MeasureAHTTempHum();

#define AHTx0_always true // if false when the current value of the parameter is the same as previous one don't send it by MQTT
#define TimeBetweenReadingAHTx0 30000
Expand Down
4 changes: 2 additions & 2 deletions main/config_BH1750.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#ifndef config_BH1750_h
#define config_BH1750_h

extern void setupBH1750();
extern void BH1750toMQTT();
extern void setupZsensorBH1750();
extern void MeasureLightIntensity();

#define bh1750_always true // if false when the current value for light Level (Lux) is the same as previous one don't send it by MQTT
#define TimeBetweenReadingBH1750 30000
Expand Down
4 changes: 2 additions & 2 deletions main/config_BME280.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#ifndef config_BME280_h
#define config_BME280_h

extern void setupBME280();
extern void BME280toMQTT();
extern void setupZsensorBME280();
extern void MeasureTempHumAndPressure();

#ifndef bme280_always
# define bme280_always true // if false when the current value of the parameter is the same as previous one don't send it by MQTT
Expand Down
4 changes: 4 additions & 0 deletions main/config_BT.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ extern bool BTtoMQTT();
extern void MQTTtoBT(char* topicOri, JsonObject& RFdata);
extern void emptyBTQueue();
extern void launchBTDiscovery(bool overrideDiscovery);
extern void stopProcessing();
extern void startProcessing();
extern void lowPowerESP32();
extern void stateBTMeasures(bool);

#ifdef ESP32
extern int btQueueBlocked;
Expand Down
3 changes: 2 additions & 1 deletion main/config_DHT.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#define config_DHT_h

extern void setupDHT();
extern void DHTtoMQTT();
extern void MeasureTempAndHum();

/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define DHTTOPIC "/DHTtoMQTT/dht1"
Expand Down
2 changes: 2 additions & 0 deletions main/config_DS1820.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

extern void setupZsensorDS1820();
extern void DS1820toMQTT();
extern void MeasureDS1820Temp();
extern void pubOneWire_HADiscovery();

/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define OW_TOPIC "/OneWiretoMQTT/ds1820"
Expand Down
4 changes: 4 additions & 0 deletions main/config_FASTLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#ifndef config_FASTLED_h
#define config_FASTLED_h

extern void setupFASTLED();
extern void FASTLEDLoop();
extern void MQTTtoFASTLED(char*, char*);
extern void MQTTtoFASTLED(char*, JsonObject&);
/*-------------------FASTLED topics & parameters----------------------*/
//FASTLED MQTT Subjects
#define subjectMQTTtoFASTLED "/commands/MQTTtoFASTLED"
Expand Down
1 change: 1 addition & 0 deletions main/config_GPIOInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

extern void setupGPIOInput();
extern void GPIOInputtoMQTT();
extern void MeasureGPIOInput();
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectGPIOInputtoMQTT "/GPIOInputtoMQTT"
Expand Down
1 change: 1 addition & 0 deletions main/config_GPIOKeyCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

extern void setupGPIOKeyCode();
extern void GPIOKeyCodetoMQTT();
extern void MeasureGPIOKeyCode();
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectGPIOKeyCodetoMQTT "/keycode"
Expand Down
1 change: 1 addition & 0 deletions main/config_HCSR501.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

extern void setupHCSR501();
extern void HCSR501toMQTT();
extern void MeasureHCSR501();
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectHCSR501toMQTT "/HCSR501toMQTT"
Expand Down
4 changes: 2 additions & 2 deletions main/config_HTU21.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#ifndef config_HTU21_h
#define config_HTU21_h

extern void setupHTU21();
extern void HTU21toMQTT();
extern void setupZsensorHTU21();
extern void MeasureTempHum();

#define htu21_always true // if false when the current value of the parameter is the same as previous one don't send it by MQTT
#define TimeBetweenReadinghtu21 30000
Expand Down
2 changes: 2 additions & 0 deletions main/config_INA226.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

extern void setupINA226();
extern void INA226toMQTT();
extern void MeasureINA226();

/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectINA226toMQTT "/INA226toMQTT"
Expand Down
1 change: 1 addition & 0 deletions main/config_ONOFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
extern void setupONOFF();
extern void MQTTtoONOFF(char* topicOri, char* datacallback);
extern void MQTTtoONOFF(char* topicOri, JsonObject& RFdata);
extern void stateONOFFMeasures();
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectMQTTtoONOFF "/commands/MQTTtoONOFF"
Expand Down
5 changes: 5 additions & 0 deletions main/config_PWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
/*-------------------PWM topics & parameters----------------------*/

// PWM MQTT Subjects

extern void setupPWM();
extern void PWMLoop();
extern void MQTTtoPWM(char*, JsonObject&);

#define subjectMQTTtoPWM "/commands/MQTTtoPWM"
#define subjectMQTTtoPWMset subjectMQTTtoPWM "/set" //set channel(s) with JSON struct {"r":0-1,"g":0-1,"b":0-1,"w0":0-1,"w0":0-1,"fade":<fade time in seconds>}
#define subjectMQTTtoPWMcalibrate subjectMQTTtoPWM "/calibrate" //set calibration data JSON struct {"gamma-r":0.5-4.0,"min-r":0-1,"max-r":0-1 etc. }
Expand Down
3 changes: 3 additions & 0 deletions main/config_RF.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ extern void disableRTLreceive();
extern int getRTLrssiThreshold();
extern int getRTLCurrentRSSI();
extern int getRTLMessageCount();
extern int getRTLAverageRSSI();
extern int getOOKThresh();

# ifdef ZmqttDiscovery
extern void launchRTL_433Discovery(bool overrideDiscovery);
// This structure stores the entities of the RTL 433 devices and is they have been discovered or not
Expand Down
4 changes: 2 additions & 2 deletions main/config_TEMT6000.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#ifndef config_TEMT6000_h
#define config_TEMT6000_h

extern void setupTEMT6000();
extern void TEMT6000toMQTT();
extern void setupZsensorTEMT6000();
extern void MeasureLightIntensityTEMT6000();

#define temt6000_always true // if false only send current value if it has changed
#define TEMT6000LIGHTSENSORPIN A0 //Ambient light sensor reading = ADC0
Expand Down
4 changes: 2 additions & 2 deletions main/config_TSL2561.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#ifndef config_TSL2561_h
#define config_TSL2561_h

extern void setupTSL2561();
extern void TSL2561toMQTT();
extern void setupZsensorTSL2561();
extern void MeasureLightIntensityTSL2561();

#define tsl2561_always true // if false only send current value if it has changed
#define TimeBetweenReadingtsl2561 30000
Expand Down
22 changes: 1 addition & 21 deletions main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ char mqtt_user[parameters_size + 1] = MQTT_USER; // not compulsory only if your
char mqtt_pass[parameters_size + 1] = MQTT_PASS; // not compulsory only if your broker needs authentication
char mqtt_server[parameters_size + 1] = MQTT_SERVER;
char mqtt_port[6] = MQTT_PORT;
char mqtt_topic[parameters_size + 1] = Base_Topic;
char gateway_name[parameters_size + 1] = Gateway_Name;
char ota_pass[parameters_size + 1] = ota_password;
#ifdef USE_MAC_AS_GATEWAY_NAME
# undef WifiManager_ssid
Expand All @@ -204,24 +202,11 @@ bool connectedOnce = false; //indicate if we have been connected once to MQTT
bool connected = false; //indicate whether we are currently connected. Used to detected re-connection
int failure_number_ntwk = 0; // number of failure connecting to network
int failure_number_mqtt = 0; // number of failure connecting to MQTT
#ifdef ZmqttDiscovery
bool disc = true; // Auto discovery with Home Assistant convention
unsigned long lastDiscovery = 0; // Time of the last discovery to trigger automaticaly to off after DiscoveryAutoOffTimer
#endif

unsigned long timer_led_measures = 0;
static void* eClient = nullptr;
static unsigned long last_ota_activity_millis = 0;
#if defined(ESP8266) || defined(ESP32)
# include <vector>
// Flags definition for white list, black list, discovery management
# define device_flags_init 0 << 0
# define device_flags_isDisc 1 << 0
# define device_flags_isWhiteL 1 << 1
# define device_flags_isBlackL 1 << 2
# define device_flags_connect 1 << 3
# define isWhite(device) device->isWhtL
# define isBlack(device) device->isBlkL
# define isDiscovered(device) device->isDisc

static bool mqtt_secure = MQTT_SECURE_DEFAULT;
static bool mqtt_cert_validate = MQTT_CERT_VALIDATE_DEFAULT;
Expand Down Expand Up @@ -255,9 +240,7 @@ static bool esp32EthConnected = false;
# include <WiFiClientSecure.h>
# include <WiFiMulti.h>
WiFiMulti wifiMulti;
# include <Preferences.h>
# include <WiFiManager.h>
Preferences preferences;
# ifdef MDNS_SD
# include <ESPmDNS.h>
# endif
Expand All @@ -284,9 +267,6 @@ ESP8266WiFiMulti wifiMulti;
# include <Ethernet.h>
#endif

#define convertTemp_CtoF(c) ((c * 1.8) + 32)
#define convertTemp_FtoC(f) ((f - 32) * 5 / 9)

// client link to pubsub MQTT
PubSubClient client;

Expand Down

0 comments on commit bf004b0

Please sign in to comment.