Instrument Neutral Distributed Interface INDI 2.2.5
uranusmeteo.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2022 Jasem Mutlaq. All rights reserved.
3
4 Pegasus Uranus Meteo Sensor Driver.
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 "indigps.h"
29
30#include <vector>
31#include <stdint.h>
32
33namespace Connection
34{
35class Serial;
36}
37
39{
40 public:
42
43 virtual bool initProperties() override;
44 virtual bool updateProperties() override;
45
46 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
47 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
48
49 protected:
50 const char *getDefaultName() override;
51 virtual bool saveConfigItems(FILE *fp) override;
52
53 // Event loop
54 virtual void TimerHit() override;
55
56 // GPS Override
57 virtual IPState updateGPS() override;
58
59 // Weather Overrides
60 virtual IPState updateWeather() override;
61
62 private:
63 bool Handshake();
64
68 bool readSensors();
69 enum
70 {
71 AmbientTemperature,
72 RelativeHumidity,
73 DewPoint,
74 AbsolutePressure,
75 RelativePressure,
76 BarometricAltitude,
77 SkyTemperature,
78 InfraredTemperature,
79 BatteryUsage,
80 BatteryVoltage,
81 };
82 INDI::PropertyNumber SensorNP {10};
83
87 bool readSkyQuality();
88 void measureSkyQuality();
89 enum
90 {
91 MPAS,
92 NELM,
93 FullSpectrum,
94 VisualSpectrum,
95 InfraredSpectrum,
96 Lux,
97 };
98 INDI::PropertyNumber SkyQualityNP {6};
99 INDI::PropertyNumber SkyQualityUpdateNP {1};
100
104 bool readClouds();
105 enum
106 {
107 TemperatureDifference,
108 CloudIndex,
109 CloudSkyTemperature,
110 CloudAmbientTemperature,
111 InfraredEmissivity,
112 };
113 INDI::PropertyNumber CloudsNP {5};
114
118 enum
119 {
120 GPSFix,
121 GPSTime,
122 UTCOffset,
123 Latitude,
124 Longitude,
125 SatelliteNumber,
126 Altitude,
127 GPSSpeed,
128 GPSBearing
129 };
130 INDI::PropertyNumber GPSNP {9};
131
135 bool readMoon();
136 enum
137 {
138 MoonPhase,
139 MoonType,
140 MoonVisibility
141 };
142 INDI::PropertyNumber MoonNP {3};
143
147 bool readTwilight();
148 enum
149 {
150 TwilightSunrise,
151 TwilightSunset,
152 TwilightMoonPhase,
153 };
154 INDI::PropertyNumber TwilightNP {3};
155
159 bool readConfig();
160 enum
161 {
162 CONFIG_UNITS,
163 CONFIG_NMEA_RJ12,
164 CONFIG_OLED_ON,
165 CONFIG_RESERVED_1,
166 CONFIG_SLEEP,
167 CONFIG_SQM_OFFSET,
168 CONFIG_TIMEZONE_OFFSET,
169 CONFIG_RESERVED_2,
170 CONFIG_LAST_ID,
171 CONFIG_TIMEZONE_ID,
172 };
173 INDI::PropertyNumber ConfigNP {10};
174
178 bool reset();
179 INDI::PropertySwitch ResetSP {1};
180
181 INDI::PropertyText DeviceInfoTP {2};
182 enum
183 {
184 DEVICE_RELEASE,
185 DEVICE_SERIAL
186 };
187
191
197 bool sendCommand(const char *cmd, char *res);
198 std::vector<std::string> split(const std::string &input, const std::string &regex);
199
203
204 int PortFD { -1 };
205 bool m_SetupComplete { false };
206 Connection::Serial *serialConnection { nullptr };
207
208 INDI::Timer m_SkyQualityUpdateTimer;
209 std::vector<std::string> m_Sensors;
210 std::vector<std::string> m_Clouds;
211 std::vector<std::string> m_SkyQuality;
212 std::vector<std::string> m_GPS;
213
214 static constexpr const uint8_t PEGASUS_STOP_CHAR {0xA};
215 static constexpr const uint8_t PEGASUS_TIMEOUT {3};
216 static constexpr const uint8_t PEGASUS_LEN {128};
217 static constexpr const char *SENSORS_TAB {"Sensors"};
218 static constexpr const char *SKYQUALITY_TAB {"Sky Quality"};
219 static constexpr const char *CLOUDS_TAB {"Clouds"};
220 static constexpr const char *ENVIRONMENT_TAB {"Environment"};
221 static constexpr const char *GPS_TAB {"GPS"};
222};
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
The Timer class provides repetitive and single-shot timers.
Definition inditimer.h:41
Provides interface to implement weather reporting and safety monitoring functionality.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save refresh period
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
const char * getDefaultName() override
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual IPState updateGPS() override
updateGPS Retrieve Location & Time from GPS. Update LocationNP & TimeTP properties (value and state) ...
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
uint8_t cmd[4]
Definition pwc-ioctl.h:2