-
Notifications
You must be signed in to change notification settings - Fork 22
/
w1.h
66 lines (50 loc) · 1.54 KB
/
w1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//***************************************************************************
// Automation Control
// File w1.h
// This code is distributed under the terms and conditions of the
// GNU GENERAL PUBLIC LICENSE. See the file LICENSE for details.
// Date 10.08.2020 - Jörg Wendel
//***************************************************************************
#pragma once
#include <stdio.h>
#include <map>
#include <limits>
#include "lib/common.h"
#include "lib/mqtt.h"
//***************************************************************************
// Class W1
//***************************************************************************
class W1
{
public:
struct SensorData
{
double value;
std::vector<double> values;
bool active {false};
};
typedef std::map<std::string,SensorData> SensorList;
W1(const char* aUrl, const char* topic);
~W1();
static void downF(int aSignal) { shutdown = true; }
int init() { return success; }
int loop();
int show();
int scan();
int check();
int update();
bool doShutDown() { return shutdown; }
const SensorList* getList() { return &sensors; }
size_t getCount() { return sensors.size(); }
static int w1PowerPin;
static int w1Count;
protected:
int mqttConnection();
char* w1Path {};
SensorList sensors;
const char* mqttUrl {};
std::string mqttTopic;
std::string mqttPingTopic;
Mqtt* mqttW1Writer {};
static bool shutdown;
};