Instrument Neutral Distributed Interface INDI 2.2.5
waveshare_modbus_relay.h
Go to the documentation of this file.
1/*
2 Waveshare ModBUS POE Relay
3 Copyright (C) 2024 Jasem Mutlaq
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
12 You should have received a copy of the GNU Lesser General Public
13 License along with this library; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15*/
16
17#pragma once
18
19#include "indiinputinterface.h" // Added for InputInterface
20#include "indioutputinterface.h"
21#include "defaultdevice.h"
22#include "inditimer.h"
23#include "../../libs/modbus/nanomodbus.h"
24
26 public INDI::InputInterface // Added InputInterface
27{
28 public:
30 virtual ~WaveshareRelay() override = default;
31
32 const char *getDefaultName() override;
33 virtual bool initProperties() override;
34 virtual bool updateProperties() override;
35
36 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
37 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
38 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
39
40 protected:
41 bool Handshake();
42
43 // Relay
44
53 virtual bool UpdateDigitalOutputs() override;
54
59 virtual bool UpdateDigitalInputs() override;
60
61 virtual bool UpdateAnalogInputs() override;
62
67 virtual bool CommandOutput(uint32_t index, OutputState command) override;
68
69 virtual void TimerHit() override;
70 virtual bool saveConfigItems(FILE *fp) override;
71
72 private:
73 Connection::TCP *tcpConnection {nullptr};
74 INDI::PropertyText FirmwareVersionTP {1};
75 int PortFD{-1};
76 bool m_HaveInput {false};
77 nmbs_t nmbs;
78
79};
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...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
const char * getDefaultName() override
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 ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool UpdateAnalogInputs() override
Update all analog inputs.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool UpdateDigitalInputs() override
Update all digital inputs.
virtual bool CommandOutput(uint32_t index, OutputState command) override
Send command to relay.
virtual bool UpdateDigitalOutputs() override
Update all digital outputs.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual ~WaveshareRelay() override=default
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
ISState
Switch state.
Definition indiapi.h:148