Instrument Neutral Distributed Interface INDI 2.2.5
wandererbox_plus_v3.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2024 Frank Wang. All rights reserved.
3
4 WandererBox Plus V3
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 The full GNU General Public License is included in this distribution in the
22 file called LICENSE.
23*******************************************************************************/
24
25#pragma once
26
27#include "defaultdevice.h"
29#include <vector>
30#include <stdint.h>
31
32namespace Connection
33{
34class Serial;
35}
36
38{
39public:
41 virtual ~WandererBoxPlusV3() = default;
42
43 virtual bool initProperties() override;
44 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
45 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
46 virtual bool updateProperties() override;
47
48
49
50protected:
51 const char *getDefaultName() override;
52 virtual bool saveConfigItems(FILE *fp) override;
53 virtual void TimerHit() override;
54 virtual IPState updateWeather() override;
55
56
57private:
58
59 int firmware=0;
60 bool sendCommand(std::string command);
61 bool DC3DIFFMODE=false;
62 bool DC3CONSTMODE=false;
63 bool getData();
64 static constexpr const char *ENVIRONMENT_TAB {"Environment"};
65 static constexpr const char *SENSORS_TAB {"Sensors"};
66 static constexpr const char *DC3_TAB {"DC3"};
67 //Current Calibrate
68 INDI::PropertySwitch CalibrateSP{1};
69
70
71 //Temp1
72 double temp1read = 0;
73 //DHTH
74 double DHTHread = 0;
75 //DHTT
76 void updateENV(double temp1,double DHTH,double DHTT);
77 double DHTTread = 0;
78 //Total Current
79 double Tcurrentread = 0;
80 //Power Monitor
81 void updatePower(double Tcurrent,double voltage);
82 double voltageread = 0;
83 //USB
84 void updateUSB(int value);
85 int USBread = 0;
86 //DC2
87 void updateDC2(int value);
88 int DC2read = 0;
89 //DC3
90 void updateDC3(int value);
91 int DC3read = 0;
92 //DC4_6
93 void updateDC4_6(int value);
94 int DC4_6read = 0;
95 //DC2set
96 void updateDC2SET(double value);
97 int DC2SETread = 0;
98
99 bool setDewPWM(uint8_t id, uint8_t value);
100
101 //DC Control//////////////////////////////////////////////////////////////////////////////////
102 INDI::PropertySwitch dc2ControlSP{2};
103 INDI::PropertySwitch DC4_6ControlSP{2};
104 //USB Control//////////////////////////////////////////////////////////////////////////////////
105 INDI::PropertySwitch USBControlSP{2};
106 //DC3 Control////////////////////////////////////////////////////////////////
107 INDI::PropertyNumber DC3ControlNP{1};
108 enum
109 {
110 DC3,
111 };
112 //DC3 DIFF////////////////////////////////////////////////////////////////
113 INDI::PropertySwitch DC3diffSP{3};
114 enum
115 {
116 DC3_Manual,
117 DC3_DPD_Mode,
118 DC3_CT_Mode,
119 };
120
121 INDI::PropertyNumber DC3diffSETNP{1};
122 enum
123 {
124 DC3DIFFSET,
125 };
126 INDI::PropertyNumber DC3constSETNP{1};
127 enum
128 {
129 DC3CONSTSET,
130 };
131
132
133
134 //DC2 Voltage Control////////////////////////////////////////////////////////////////
135 INDI::PropertyNumber setDC2voltageNP{1};
136 enum
137 {
138 setDC2voltage,
139 };
140
141 // Power Monitor
142
143 INDI::PropertyNumber PowerMonitorNP{2};
144 enum
145 {
146 VOLTAGE,
147 TOTAL_CURRENT,
148 };
149
150 // ENV Monitor
151
152 INDI::PropertyNumber ENVMonitorNP{4};
153 enum
154 {
155 Probe1_Temp,
156 ENV_Humidity,
157 ENV_Temp,
158 DEW_Point,
159 };
160
161
162
163 int PortFD{ -1 };
164
165 Connection::Serial *serialConnection{ nullptr };
166};
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides interface to implement weather reporting and safety monitoring functionality.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual ~WandererBoxPlusV3()=default
const char * getDefaultName() override
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition arduino_st4.h:34