52 FirmwareTP[0].
fill(
"Version",
"Version",
nullptr);
64 UptimeNP[0].
fill(
"UPTIME_SECONDS",
"Uptime (s)",
"%.0f", 0, 1e9, 1, 0);
115 return "Pegasus FlatMaster WiFi";
118void PegasusFlatMasterWifi::updateFirmwareVersion()
120 char response[32] = {0};
122 if (sendCommand(
"FV", response))
125 const char *ver = strstr(response,
"FV:");
126 FirmwareTP[0].setText(ver ? ver + 3 : response);
134 LOG_ERROR(
"Error reading firmware version.");
138bool PegasusFlatMasterWifi::Ack()
142 char response[32] = {0};
143 if (sendCommand(
"F#", response))
145 if (strstr(response,
"FMW") !=
nullptr)
147 updateFirmwareVersion();
151 LOGF_ERROR(
"Ack failed: unexpected response '%s'", response);
158 char response[32] = {0};
160 snprintf(
cmd,
sizeof(
cmd),
"FE:%d", enable ? 1 : 0);
162 if (!sendCommand(
cmd, response))
164 LOGF_ERROR(
"EnableLightBox: send failed. %s", response);
168 if (strstr(response,
"FE:") ==
nullptr)
170 LOGF_ERROR(
"EnableLightBox: unexpected response '%s'", response);
180 char response[32] = {0};
183 snprintf(
cmd,
sizeof(
cmd),
"FL:%d", value);
185 if (!sendCommand(
cmd, response))
187 LOGF_ERROR(
"SetLightBoxBrightness: send failed. %s", response);
191 if (strstr(response,
"FL:") ==
nullptr)
193 LOGF_ERROR(
"SetLightBoxBrightness: unexpected response '%s'", response);
228 char response[32] = {0};
230 sendCommand(
"FQ", response);
233 LOG_INFO(
"Reboot command sent to device.");
253bool PegasusFlatMasterWifi::sendCommand(
const char *command,
char *res)
255 int nbytes_written = 0, nbytes_read = 0, rc = -1;
259 snprintf(
cmd,
sizeof(
cmd),
"%s\n", command);
263 tcflush(PortFD, TCIOFLUSH);
280 res[nbytes_read - 1] = 0;
281 if (nbytes_read > 1 && res[nbytes_read - 2] ==
'\r')
282 res[nbytes_read - 2] = 0;
286 tcflush(PortFD, TCIOFLUSH);
291bool PegasusFlatMasterWifi::getStatusData()
293 char response[32] = {0};
295 if (!sendCommand(
"FA", response))
297 LOG_ERROR(
"Error querying device status.");
303 char *tok = strtok(response,
":");
304 if (tok ==
nullptr)
return false;
306 char *brStr = strtok(
nullptr,
":");
307 char *pwStr = strtok(
nullptr,
":");
309 if (brStr ==
nullptr || pwStr ==
nullptr)
311 LOG_WARN(
"Unexpected FA response format.");
315 const double brightness = atof(brStr);
316 const bool lightOn = (atof(pwStr) != 0);
349 char response[32] = {0};
350 if (sendCommand(
"FU", response))
353 const char *val = strstr(response,
"FU:");
356 UptimeNP[0].setValue(atof(val + 3));
void registerHandshake(std::function< bool()> callback)
registerHandshake Register a handshake function to be called once the initial connection to the devic...
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
void setPortMatchPattern(const std::string &pattern)
setPortMatchPattern Set a regex pattern used to automatically select a serial port from the discovere...
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
const char * getDeviceName() const
virtual bool updateProperties()
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process the client newSwitch command.
void registerConnection(Connection::Interface *newConnection)
registerConnection Add new connection plugin to the existing connection pool. The connection type sha...
virtual void ISGetProperties(const char *dev)
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool ISSnoopDevice(XMLEle *root)
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
void setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
virtual bool initProperties()
Initialize properties initial state and value. The child class must implement this function.
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process the client newNumber command.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
void initProperties(const char *group, uint32_t capabilities)
Initialize light box properties. It is recommended to call this function within initProperties() of y...
void ISGetProperties(const char *deviceName)
isGetLightBoxProperties Get light box properties
INDI::PropertyNumber LightIntensityNP
bool saveConfigItems(FILE *fp)
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process light box switch properties.
bool processText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process light box text properties.
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process light box number properties.
INDI::PropertySwitch LightSP
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isNameMatch(const char *otherName) const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
Provides interface to implement controllable light box/switch device.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
const char * getDefaultName() override
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 SetLightBoxBrightness(uint16_t value) override
setBrightness Set light level. Must be implemented in the child class, if supported.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool EnableLightBox(bool enable) override
EnableLightBox Turn on/off on a light box. Must be implemented in the child class.
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 ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Implementations for common driver routines.
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)