Instrument Neutral Distributed Interface INDI 2.2.5
pegasus_flatmaster_neo.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2026 Dominik Merkel. All rights reserved.
3
4 Pegasus FlatMaster Neo
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
28#include "defaultdevice.h"
31
32#include <vector>
33#include <string>
34
35
38{
39 public:
41 virtual ~PegasusFlatMasterNeo() override = default;
42
43 const char *getDefaultName() override;
44 void ISGetProperties(const char *dev) override;
45 virtual bool initProperties() override;
46 virtual bool updateProperties() override;
47
48 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
49 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
50 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
51 virtual bool ISSnoopDevice(XMLEle *root) override;
52
53 protected:
54 virtual bool SetLightBoxBrightness(uint16_t value) override;
55 virtual bool EnableLightBox(bool enable) override;
56 virtual bool saveConfigItems(FILE *fp) override;
57
58 virtual IPState ParkCap() override;
59 virtual IPState UnParkCap() override;
60 virtual IPState AbortCap() override;
61
62 virtual IPState updateWeather() override { return IPS_OK; }
63 virtual void TimerHit() override;
64
65 private:
66 bool Ack();
67 bool getStatusData();
68 bool getWeatherData();
69 bool getWeatherOffsets();
70 bool getUptime();
71 bool getThreshold();
72 bool getWifiChannel();
73 bool getAutoClose();
74 bool getHotspotStatus();
75 bool getHotspot();
76 bool getCurrentWifi();
77 bool setTemperatureOffset(double value);
78 bool setHumidityOffset(double value);
79 bool setDewHeater(uint8_t value);
80 bool setAutoDew(bool enable);
81 bool setDewAggressiveness(uint8_t level);
82 bool saveDewLevels();
83 bool setThreshold(uint8_t value);
84 bool setCapAngle(uint16_t angle);
85 bool setAutoClose(bool enable);
86 bool setHotspotStatus(bool enable);
87 bool setHotspot(const char *ssid, const char *password);
88 bool connectToWifi(const char *ssid, const char *password);
89 bool scanWifiNetworks();
90 bool setWifiChannel(uint8_t channel);
91 bool wifiFactoryReset();
92 std::vector<std::string> split(const std::string &input, const std::string &sep);
93
94 int PortFD{ -1 };
95 bool sendCommand(const char *cmd, char *response, int timeout_sec = 3);
96 void updateFirmwareVersion();
97
98 // Firmware version
99 ITextVectorProperty FirmwareTP;
100 IText FirmwareT[1] {};
101
102 // Dew Control
103 INDI::PropertyNumber DewHeaterNP {1};
104 INDI::PropertySwitch AutoDewSP {2};
105 INDI::PropertyNumber DewAggressivenessNP {1};
106 INDI::PropertyNumber ThresholdNP {1};
107 INDI::PropertySwitch SaveDewSP {1};
108
109 // Auto-close (DC command)
110 INDI::PropertySwitch AutoCloseSP {2};
111
112 // Cap angle
113 INDI::PropertyNumber CapAngleNP {1};
114
115 // Weather offsets (CT / CH / CR)
116 INDI::PropertyNumber WeatherOffsetNP {2};
117
118 // Device overview status (FA command)
119 INDI::PropertyNumber DeviceStatusNP {9};
120
121 // Uptime (FU command)
122 INDI::PropertyNumber UptimeNP {1};
123
124 // Reboot (FQ command)
125 INDI::PropertySwitch RebootSP {1};
126
127 // WiFi channel (AC command)
128 INDI::PropertyNumber WifiChannelNP {1};
129
130 // Hotspot control (A? / AE commands)
131 INDI::PropertySwitch HotspotStatusSP {2};
132
133 // Hotspot credentials (AL / AN / AP commands)
134 INDI::PropertyText HotspotCredentialsTP {2};
135
136 // Current WiFi connection (WI command)
137 INDI::PropertyText CurrentWifiTP {1};
138
139 // WiFi scan (WS command)
140 INDI::PropertySwitch WifiScanSP {1};
141 INDI::PropertyText WifiScanTP {1};
142
143 // WiFi connect (WN / WP commands)
144 INDI::PropertyText WifiConnectTP {2};
145 INDI::PropertySwitch WifiConnectSP {1};
146
147 // WiFi factory reset (WZ command)
148 INDI::PropertySwitch WifiFactoryResetSP {1};
149
150 Connection::Serial *serialConnection{ nullptr };
151
152 std::vector<std::string> lastWeatherData;
153 std::vector<std::string> lastStatusData;
154
155 static constexpr const char *ENVIRONMENT_TAB {"Environment"};
156 static constexpr const char *LIGHTBOX_TAB {"Light Box"};
157 static constexpr const char *DUSTCAP_TAB {"Dust Cap"};
158 static constexpr const char *DEW_TAB {"Dew Control"};
159 static constexpr const char *STATUS_TAB {"Overview"};
160 static constexpr const char *NETWORK_TAB {"Network"};
161 static constexpr const uint8_t NEO_LEN {64};
162
163 // FA response field indices
164 // FA response: "FMNEO:lightIntensity:lightActive:capActual:capTarget:capStatus:v6:autoDew:v8:v9"
165 enum
166 {
167 FA_NAME = 0,
168 FA_LIGHT_INTENSITY,
169 FA_LIGHT_ACTIVE,
170 FA_CAP_ACTUAL_ANGLE,
171 FA_CAP_TARGET_ANGLE,
172 FA_CAP_STATUS,
173 FA_DEW_POWER,
174 FA_AUTO_DEW_STATUS,
175 FA_DEW_AGGRESSIVE,
176 FA_LIGHT_SENSOR,
177 FA_N,
178 };
179
180 enum CapMotionStatus
181 {
182 CAP_STATUS_PARKED = 1,
183 CAP_STATUS_UNPARKED = 3,
184 };
185
186 // DeviceStatusNP indices (FA[1..9])
187 enum
188 {
189 STATUS_LIGHT_INTENSITY = 0,
190 STATUS_LIGHT_ACTIVE,
191 STATUS_CAP_ACTUAL_ANGLE,
192 STATUS_CAP_TARGET_ANGLE,
193 STATUS_CAP_STATUS,
194 STATUS_DEW_POWER,
195 STATUS_AUTO_DEW,
196 STATUS_DEW_AGGRESSIVE,
197 STATUS_LIGHT_SENSOR,
198 };
199
200 // ES response field indices
201 enum
202 {
203 WI_NAME = 0,
204 WI_TEMPERATURE,
205 WI_HUMIDITY,
206 WI_DEWPOINT,
207 WI_N,
208 };
209
210 // CR response field indices
211 enum
212 {
213 CR_PREFIX = 0,
214 CR_TEMP_OFFSET,
215 CR_HUM_OFFSET,
216 CR_N,
217 };
218
219 // WeatherOffsetNP indices
220 enum
221 {
222 OFFSET_TEMPERATURE = 0,
223 OFFSET_HUMIDITY,
224 };
225};
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 SetLightBoxBrightness(uint16_t value) override
setBrightness Set light level. Must be implemented in the child class, if supported.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState UnParkCap() override
unPark dust cap (open cover). Must be implemented by child.
virtual IPState ParkCap() override
Park dust cap (close cover). Must be implemented by child.
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
virtual IPState AbortCap() override
Abort motion. Must be implemented by child.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
const char * getDefaultName() override
virtual bool EnableLightBox(bool enable) override
EnableLightBox Turn on/off on a light box. Must be implemented in the child class.
virtual ~PegasusFlatMasterNeo() override=default
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
@ IPS_OK
Definition indiapi.h:160
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One text descriptor.
Text vector property descriptor.
Definition indiapi.h:244