Fix teleinfo configuration
This commit is contained in:
parent
8f471fc0bf
commit
1b52a80b15
@ -4,18 +4,18 @@
|
|||||||
#ifdef CONFIG_ENABLE_TELEINFO
|
#ifdef CONFIG_ENABLE_TELEINFO
|
||||||
#include <LibTeleinfo.h>
|
#include <LibTeleinfo.h>
|
||||||
int TeleinfoSetup();
|
int TeleinfoSetup();
|
||||||
//int TeleinfoProcess();
|
|
||||||
int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo);
|
int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo);
|
||||||
|
int TeleinfoProcess(float &iinst, float &papp, float &base);
|
||||||
#else
|
#else
|
||||||
typedef struct _ValueList {
|
|
||||||
} ValueList;
|
|
||||||
int TeleinfoSetup() {
|
int TeleinfoSetup() {
|
||||||
SKETCH_DEBUG_PRINTLN("Teleinfo is disabled at build time");
|
SKETCH_DEBUG_PRINTLN("Teleinfo is disabled at build time");
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
//int TeleinfoProcess(){
|
inline int TeleinfoProcess(std::vector<struct mqttInfo> &){
|
||||||
int TeleinfoProcess(std::vector<struct mqttInfo> &){
|
return 0;
|
||||||
|
};
|
||||||
|
int TeleinfoProcess(float &iinst, float &papp, float &base){
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
#ifdef CONFIG_ENABLE_TELEINFO
|
#ifdef CONFIG_ENABLE_TELEINFO
|
||||||
#include "Teleinfo.h"
|
#include "Teleinfo.h"
|
||||||
#include <LibTeleinfo.h>
|
#include <LibTeleinfo.h>
|
||||||
|
#define TELESerial Serial
|
||||||
TInfo tinfo;
|
TInfo tinfo;
|
||||||
void onNewFrame(ValueList *me)
|
|
||||||
{
|
|
||||||
SKETCH_DEBUG_PRINTLN("New Frame available");
|
|
||||||
}
|
|
||||||
|
|
||||||
int TeleinfoSetup()
|
int TeleinfoSetup()
|
||||||
{
|
{
|
||||||
Serial.begin(1200, SERIAL_7E1);
|
TELESerial.begin(1200, SERIAL_7E1);
|
||||||
|
|
||||||
tinfo.init();
|
tinfo.init();
|
||||||
tinfo.attachNewFrame(onNewFrame);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -22,11 +17,10 @@ int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo)
|
|||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = Serial.read()) >= 0) {
|
while ((c = TELESerial.read()) >= 0) {
|
||||||
tinfo.process(c);
|
tinfo.process(c);
|
||||||
}
|
}
|
||||||
ValueList *me = tinfo.getList();
|
ValueList *me = tinfo.getList();
|
||||||
//std::vector<struct mqttInfo> batchInfo;
|
|
||||||
if (me)
|
if (me)
|
||||||
me = me->next;
|
me = me->next;
|
||||||
while (me) {
|
while (me) {
|
||||||
@ -44,8 +38,32 @@ int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo)
|
|||||||
}
|
}
|
||||||
me = me->next;
|
me = me->next;
|
||||||
}
|
}
|
||||||
//if (mode == BOOTMODE_NORMAL)
|
|
||||||
// MqttBatchPublish(batchInfo, conf.mqttUser, conf.host);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TeleinfoProcess(float &iinst, float &papp, float &base )
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
while ((c = TELESerial.read()) >= 0) {
|
||||||
|
tinfo.process(c);
|
||||||
|
}
|
||||||
|
ValueList *me = tinfo.getList();
|
||||||
|
if (me)
|
||||||
|
me = me->next;
|
||||||
|
while (me) {
|
||||||
|
if (strcmp(me->name, "IINST") == 0) {
|
||||||
|
iinst = atof(me->value);
|
||||||
|
}
|
||||||
|
if (strcmp(me->name, "PAPP") == 0) {
|
||||||
|
papp = atof(me->value);
|
||||||
|
}
|
||||||
|
if (strcmp(me->name, "BASE") == 0) {
|
||||||
|
base = atof(me->value);
|
||||||
|
}
|
||||||
|
me = me->next;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,8 @@ void OTASetup() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup()
|
||||||
|
{
|
||||||
#ifdef CONFIG_SETUP_BUTTON
|
#ifdef CONFIG_SETUP_BUTTON
|
||||||
new HIB(CONFIG_SETUP_BUTTON, HIGH, NULL, NULL, onLongButtonPressed);
|
new HIB(CONFIG_SETUP_BUTTON, HIGH, NULL, NULL, onLongButtonPressed);
|
||||||
#endif
|
#endif
|
||||||
@ -230,16 +231,16 @@ void setup() {
|
|||||||
SKETCH_DEBUG_PRINTLN();
|
SKETCH_DEBUG_PRINTLN();
|
||||||
|
|
||||||
// Get GPIO 3 Status
|
// Get GPIO 3 Status
|
||||||
//#if CONFIG_SERIAL_SHOULD_SWAP
|
#if CONFIG_SERIAL_SHOULD_SWAP
|
||||||
// SKETCH_DEBUG_PRINTLN("SWAP UART");
|
SKETCH_DEBUG_PRINTLN("SWAP UART");
|
||||||
// Serial.swap(); //Switch Serial on GPIO 13 & 15
|
Serial.swap(); // Switch Serial on GPIO 13 & 15
|
||||||
//#endif
|
#endif
|
||||||
pinMode(CONFIG_SETUP_GPIO, INPUT_PULLUP);
|
pinMode(CONFIG_SETUP_GPIO, INPUT_PULLUP);
|
||||||
int txStatus = digitalRead(CONFIG_SETUP_GPIO);
|
int txStatus = digitalRead(CONFIG_SETUP_GPIO);
|
||||||
//#if !defined(CONFIG_ENABLE_EXTRA_GPIO) && CONFIG_SERIAL_SHOULD_SWAP
|
#if !defined(CONFIG_ENABLE_EXTRA_GPIO) && CONFIG_SERIAL_SHOULD_SWAP
|
||||||
// Serial.swap(); // Switch back on GPIO 1 & 3
|
Serial.swap(); // Switch back on GPIO 1 & 3
|
||||||
// SKETCH_DEBUG_PRINTLN("SWAP UART");
|
SKETCH_DEBUG_PRINTLN("SWAP UART");
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
EEPROM.begin(CONFIG_EEPROM_SIZE);
|
EEPROM.begin(CONFIG_EEPROM_SIZE);
|
||||||
EepromReadConfig(conf);
|
EepromReadConfig(conf);
|
||||||
@ -368,6 +369,5 @@ void loop() {
|
|||||||
MqttBatchPublish(batchInfo, conf.mqttUser, conf.host);
|
MqttBatchPublish(batchInfo, conf.mqttUser, conf.host);
|
||||||
nbCycle = 0;
|
nbCycle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,6 @@
|
|||||||
#define CONFIG_DHT_PIN 0
|
#define CONFIG_DHT_PIN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_ENABLE_TELEINFO)
|
|
||||||
#warning "TELEINFO is using SERIAL for communication. Debug will be on Serial1 (D4)"
|
|
||||||
#define DEBUG_PRINTER_WIFICONTROLSENSOR Serial1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONFIG_DRY_POWER_PIN
|
#ifndef CONFIG_DRY_POWER_PIN
|
||||||
#define CONFIG_DRY_POWER_PIN -1
|
#define CONFIG_DRY_POWER_PIN -1
|
||||||
#endif
|
#endif
|
||||||
@ -69,7 +64,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_SETUP_GPIO
|
#ifndef CONFIG_SETUP_GPIO
|
||||||
#define CONFIG_SETUP_GPIO 3
|
#define CONFIG_SETUP_GPIO 14
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_DHT_TYPE
|
#ifndef CONFIG_DHT_TYPE
|
||||||
@ -79,3 +74,14 @@
|
|||||||
#if CONFIG_SETUP_GPIO == 3 || CONFIG_SETUP_GPIO == 1
|
#if CONFIG_SETUP_GPIO == 3 || CONFIG_SETUP_GPIO == 1
|
||||||
#define CONFIG_SERIAL_SHOULD_SWAP
|
#define CONFIG_SERIAL_SHOULD_SWAP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_ENABLE_TELEINFO)
|
||||||
|
#warning "TELEINFO is using SERIAL for communication. Debug will be on Serial1 (D4)"
|
||||||
|
#define DEBUG_PRINTER_WIFICONTROLSENSOR Serial1
|
||||||
|
#if defined(CONFIG_SERIAL_SHOULD_SWAP)
|
||||||
|
#error "When enabling TELEINFO, SERIAL_SHOULD_SWAP cannot be enabled (SETUP_GPIO == 1 or 3)"
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_ENABLE_EXTRA_GPIO)
|
||||||
|
#error "When enabling TELEINFO, ENABLE_EXTRA_CPIO cannot be enabled"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// Enable the temperature, pressure, humidity and gaz Sensor BME680 on standard i2c esp8266 pins
|
// Enable the temperature, pressure, humidity and gaz Sensor BME680 on standard i2c esp8266 pins
|
||||||
// It use default i2c pin GPIO4(D2): SDA, GPIO5(D1):SCL
|
// It use default i2c pin GPIO4(D2): SDA, GPIO5(D1):SCL
|
||||||
// Should be powered by 3.3v and sampled every 3sec or 300s (Or you should adapt bsec_config_iaq in BME680_BSEC.ino )
|
// Should be powered by 3.3v and sampled every 3sec or 300s (Or you should adapt bsec_config_iaq in BME680_BSEC.ino )
|
||||||
#define CONFIG_BME680_BSEC_ENABLE
|
//#define CONFIG_BME680_BSEC_ENABLE
|
||||||
#define CONFIG_BME680_BSEC_I2C_ADDR 0x77
|
#define CONFIG_BME680_BSEC_I2C_ADDR 0x77
|
||||||
|
|
||||||
// Enable the temperature, pressure, humidity and gaz Sensor BME680 on standard i2c esp8266 pins
|
// Enable the temperature, pressure, humidity and gaz Sensor BME680 on standard i2c esp8266 pins
|
||||||
|
Loading…
Reference in New Issue
Block a user