50#define CHEAPODC_VERSION_MAJOR 2
51#define CHEAPODC_VERSION_MINOR 0
54#define CDC_CMD_ATPQ "ATPQ"
55#define CDC_CMD_HU "HU"
56#define CDC_CMD_DP "DP"
57#define CDC_CMD_SP "SP"
58#define CDC_CMD_TPO "TPO"
59#define CDC_CMD_TKR "TKR"
60#define CDC_CMD_DCO "DCO"
61#define CDC_CMD_WS "WS"
62#define CDC_CMD_QN "QN"
63#define CDC_CMD_FW "FW"
64#define CDC_CMD_DCM "DCM"
65#define CDC_CMD_DCTM "DCTM"
66#define CDC_CMD_SPM "SPM"
67#define CDC_CMD_WQE "WQE"
68#define CDC_CMD_UOE "UOE"
69#define CDC_CMD_WAPI "WAPI"
70#define CDC_CMD_WKEY "WKEY"
71#define CDC_CMD_LAT "LAT"
72#define CDC_CMD_LON "LON"
73#define CDC_CMD_CDT "CDT"
74#define CDC_CMD_TMZ "TMZ"
75#define CDC_CMD_DST "DST"
76#define CDC_CMD_OMIN "OMIN"
77#define CDC_CMD_OMAX "OMAX"
78#define CDC_CMD_ATPX "ATPX"
79#define CDC_CMD_CTP "CTP"
80#define CDC_CMD_WUL "WUL"
81#define CDC_CMD_LWUD "LWUD"
82#define CDC_CMD_LWUT "LWUT"
83#define CDC_CMD_WQEN "WQEN"
86#define CDC_CMD_CPM "CPM%d"
87#define CDC_CMD_CPO "CPO%d"
88#define CDC_CMD_SDAP "SDAP"
90#define CDC_GET_COMMAND "{\"GET\":\"%s\"}"
91#define CDC_SET_COMMAND "{\"SET\":{\"%s\":\"%s\"}}"
92#define CDC_RESPONSE_LENGTH 512
93#define CDC_COMMAND_LENGTH 512
94#define CDC_SET_VALUE_LENGTH 256
95#define CDC_INT_VALUE "%d"
96#define CDC_FLOAT_VALUE "%3.2f"
97#define CDC_TEXT_VALUE "%s"
98#define CDC_DEFAULT_POLLING_PERIOD 30000
99#define CDC_DEFAULT_HOST "cheapodc.local"
100#define CDC_DEFAULT_PORT 58000
101#define CDC_MIN_ADDITIONAL_OUTPUT 2
102#define CDC_TOTAL_ADDITIONAL_OUTPUTS 4
106#define CDC_SNOOP_LOCATION_PROPERTY "GEOGRAPHIC_COORD"
107#define CDC_SNOOP_LOCATION_LATITUDE "LAT"
108#define CDC_SNOOP_LOCATION_LONGITUDE "LONG"
109#define CDC_SNOOP_TIME_PROPERTY "TIME_UTC"
110#define CDC_SNOOP_TIME_OFFSET "OFFSET"
111#define CDC_SNOOP_FOCUSER_PROPERTY "FOCUS_TEMPERATURE"
112#define CDC_SNOOP_FOCUSER_TEMPERATURE "TEMPERATURE"
113#define CDC_SNOOP_WEATHER_PROPERTY "WEATHER_PARAMETERS"
114#define CDC_SNOOP_WEATHER_TEMPERATURE "WEATHER_TEMPERATURE"
115#define CDC_SNOOP_WEATHER_HUMIDITY "WEATHER_HUMIDITY"
129 virtual bool ISNewNumber(
const char *dev,
const char *name,
double values[],
char *names[],
int n)
override;
130 virtual bool ISNewSwitch(
const char *dev,
const char *name,
ISState *states,
char *names[],
int n)
override;
131 virtual bool ISNewText(
const char *dev,
const char *name,
char *texts[],
char *names[],
int n)
override;
136 virtual bool SetPowerPort(
size_t port,
bool enabled)
override;
137 virtual bool SetDewPort(
size_t port,
bool enabled,
double dutyCycle)
override;
138 virtual bool SetVariablePort(
size_t port,
bool enabled,
double voltage)
override;
142 virtual bool SetUSBPort(
size_t port,
bool enabled)
override;
184 enum CheapoDCLocation
186 LOCATION_LATITUDE = 0,
198 ACTIVE_TELESCOPE = 0,
203 enum controllerPinModes
205 CONTROLLER_PIN_MODE_DISABLED = 0,
206 CONTROLLER_PIN_MODE_CONTROLLER,
207 CONTROLLER_PIN_MODE_PWM,
208 CONTROLLER_PIN_MODE_BOOLEAN,
212 const char* pinModeText[MAX_PIN_MODES] = {
"Disabled",
"Controller",
"PWM",
"Boolean"};
213 const char* channelLabels[MAX_PIN_MODES] = {
"Output %d (Disabled)",
"Output %d (Controller)",
214 "Output %d (PWM)",
"Output %d (On/Off)"};
219 CONTROLLER_PIN_MODE_DISABLED, CONTROLLER_PIN_MODE_DISABLED };
221 bool fwVOneDetected =
false;
222 bool internalHumiditySensorSupported =
false;
223 bool additionalOutputsSupported =
false;
224 int fwMajorVersion = 0;
225 int fwMinorVersion = 0;
226 int fwPatchVersion = 0;
228 unsigned int previousControllerMode = MANUAL;
229 unsigned int prevMinOutput = 0;
230 unsigned int prevMaxOutput = 100;
231 unsigned int previousTemperatureMode = WEATHER_QUERY;
232 char activeTelescopeDevice[
MAXINDINAME] = {
"Telescope Simulator"};
233 char activeFocuserDevice[
MAXINDINAME] = {
"Focuser Simulator"};
234 char activeWeatherDevice[
MAXINDINAME] = {
"Weather Simulator"};
235 bool usingExternalWeatherSource =
false;
236 bool previuoslyUsingExternalWeatherSource = usingExternalWeatherSource;
238 int msleep(
long duration);
239 bool sendCommand(
const char *
cmd,
char *response);
240 bool sendGetCommand(
const char *
cmd,
char *resp);
241 bool sendSetCommand(
const char *
cmd,
char *value);
245 void refreshSettings(
bool delayRefresh =
false);
246 void getWeatherSource();
247 bool setWeatherSource(
int value);
248 bool setControllerMode(
int value);
249 bool setTemperatureMode(
int value);
250 bool setSetPointMode(
int value);
251 bool setSetPoint(
float value);
252 bool setTrackPointOffset(
float value);
253 bool setTrackingRange(
float value);
254 bool setOutput(
int value);
255 bool setMinimumOutput(
int value);
256 bool setMaximumOutput(
int value);
257 bool setUpdateOutputEvery(
int value);
258 bool setWeatherQueryEvery(
int value);
259 bool setWeatherQueryAPIKey(
const char *key);
260 bool setWeatherQueryEnabled(
bool enabled);
261 bool setUTCOffset(
int offset);
262 bool setLatitude(
float value);
263 bool setLongitude(
float value);
264 bool setLocation(
float latitude,
float longitude);
265 bool setExternalTemperature(
float value);
266 bool setWeatherTemperature(
float value);
267 bool setWeatherHumidity(
float value);
268 bool setSnoopLocationDevice(
const char *
device,
const char *property,
const char *latAttribute,
const char *lonAttribute);
269 bool setSnoopTemperatureDevice(
const char *
device,
const char *property,
const char *attribute);
270 bool setSnoopWeatherDevice(
const char *
device,
const char *property,
const char *temperatureAttribute,
271 const char *humidityAttribute);
272 void setActiveDevice(
const char *telescopeDevice,
const char *focuserDevice,
const char *weatherDevice);
273 bool setAdditionalOutput(
int outputPin,
int output );
274 bool checkOutputConfiguration();
284 static const uint8_t CDC_READ_TIMEOUT{10};
285 static const long CDC_SMALL_DELAY{50};
#define CDC_MIN_ADDITIONAL_OUTPUT
#define CDC_TOTAL_ADDITIONAL_OUTPUTS
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool SetPowerPort(size_t port, bool enabled) override
SetPowerPort Set power port on/off.
virtual ~CheapoDC()=default
virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle) override
SetDewPort Set DEW/Dew port duty cycle.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool CyclePower() override
CyclePower Cycle power to all ports.
virtual bool SetAutoDewEnabled(size_t port, bool enabled) override
SetAutoDewEnabled Enable/disable automatic dew control.
virtual const char * getDefaultName() override
virtual bool SetUSBPort(size_t port, bool enabled) override
SetUSBPort Set USB port on/off.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool SetLEDEnabled(bool enabled) override
SetLEDEnabled Enable/disable power LEDs.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool SetVariablePort(size_t port, bool enabled, double voltage) override
SetVariablePort Set variable voltage port.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
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 bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
The TCP class manages connection with devices over the network via TCP/IP. Upon successful connection...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...