Repository navigation
Expand file tree
/
Copy pathw1.h
More file actions
72 lines (55 loc) · 1.69 KB
/
Copy pathw1.h
File metadata and controls
72 lines (55 loc) · 1.69 KB
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
67
68
69
70
71
72
//***************************************************************************
// 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"
#define confDir "/etc/" TARGET
//***************************************************************************
// Class W1
//***************************************************************************
class W1
{
public:
struct SensorData
{
double value {0.0};
std::vector<double> values;
bool active {false};
};
typedef std::map<std::string,SensorData> SensorList;
W1(const char* aUrl, const char* topic);
~W1();
const char* myName() { return "w1-MQTT1"; }
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;
static int min;
static int max;
protected:
int mqttConnection();
Gpio* gpio {};
char* w1Path {};
SensorList sensors;
const char* mqttUrl {};
std::string mqttTopic;
std::string mqttPingTopic;
Mqtt* mqttW1Writer {};
static bool shutdown;
};