Add missing files

This commit is contained in:
Mathieu Maret 2021-02-18 15:51:49 +01:00
parent 9110ae3589
commit 8fed8bedf4
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,19 @@
#pragma once
#include "debug_sketch.h"
#ifdef CONFIG_ENABLE_TELEINFO
#include <LibTeleinfo.h>
int TeleinfoSetup();
int TeleinfoProcess();
#else
typedef struct _ValueList {
} ValueList;
int TeleinfoSetup() {
SKETCH_DEBUG_PRINTLN("Teleinfo is disabled at build time");
return -1;
};
int TeleinfoProcess(){
return 0;
};
#endif

View File

@ -0,0 +1,47 @@
#ifdef CONFIG_ENABLE_TELEINFO
#include "Teleinfo.h"
#include <LibTeleinfo.h>
TInfo tinfo;
void onNewFrame(ValueList *me)
{
SKETCH_DEBUG_PRINTLN("New Frame available");
}
int TeleinfoSetup() {
Serial.begin(1200, SERIAL_7E1);
tinfo.init();
tinfo.attachNewFrame(onNewFrame);
return 0;
}
int TeleinfoProcess() {
int c;
while ((c = Serial.read()) >= 0) {
SKETCH_DEBUG_PRINTF("Got char %c\n", (char)c);
tinfo.process(c);
}
ValueList * me = tinfo.getList();
std::vector<struct mqttInfo> batchInfo;
while (me) {
SKETCH_DEBUG_PRINTF("info %s\n", me->name);
if (strcmp(me->name, "IINST") == 0) {
float val = atof(me->value);
batchInfo.push_back({val, TELEINFO_IINST_FEED_FORMAT, 0, 0});
}
if (strcmp(me->name, "PAPP") == 0) {
float val = atof(me->value);
batchInfo.push_back({val, TELEINFO_PAPP_FEED_FORMAT, 0, 0});
}
me = me->next;
}
if (mode == BOOTMODE_NORMAL)
MqttBatchPublish(batchInfo, conf.mqttUser, conf.host);
return 0;
}
#endif