The TCP class manages connection with devices over the network via TCP/IP. Upon successful connection, reads & writes from and to the device are performed via the returned file descriptor using standard UNIX read/write functions.
More...
#include <connectiontcp.h>
|
| | TCP (INDI::DefaultDevice *dev, IPerm permission=IP_RW) |
| |
| virtual | ~TCP ()=default |
| |
| virtual bool | Connect () override |
| | Connect Connect to device via the implemented communication medium. Do not perform any handshakes.
|
| |
| virtual bool | Disconnect () override |
| | Disconnect Disconnect from device.
|
| |
| virtual void | Activated () override |
| | Activated Function called by the framework when the plugin is activated (i.e. selected by the user). It is usually used to define properties pertaining to the specific plugin functionalities.
|
| |
| virtual void | Deactivated () override |
| | Deactivated Function called by the framework when the plugin is deactivated. It is usually used to delete properties by were defined previously since the plugin is no longer active.
|
| |
| virtual std::string | name () override |
| |
| virtual std::string | label () override |
| |
| virtual const char * | host () const |
| |
| virtual uint32_t | port () const |
| |
| ConnectionType | connectionType () const |
| |
| virtual bool | ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) override |
| |
| virtual bool | ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) override |
| |
| virtual bool | saveConfigItems (FILE *fp) override |
| |
| int | getPortFD () const |
| |
| void | setDefaultHost (const char *addressHost) |
| |
| void | setDefaultPort (uint32_t addressPort) |
| |
| void | setConnectionType (int type) |
| | TODO should be renamed to setDefaultConnectionType.
|
| |
| void | setLANSearchEnabled (bool enabled) |
| |
| virtual Type | type () |
| | type Return connection type
|
| |
| virtual bool | ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) |
| |
| virtual bool | ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) |
| |
| void | registerHandshake (std::function< bool()> callback) |
| | registerHandshake Register a handshake function to be called once the initial connection to the device is established.
|
| |
The TCP class manages connection with devices over the network via TCP/IP. Upon successful connection, reads & writes from and to the device are performed via the returned file descriptor using standard UNIX read/write functions.
Definition at line 39 of file connectiontcp.h.
◆ ConnectionType
◆ TCP()
◆ ~TCP()
| virtual Connection::TCP::~TCP |
( |
| ) |
|
|
virtualdefault |
◆ Activated()
| void Connection::TCP::Activated |
( |
| ) |
|
|
overridevirtual |
Activated Function called by the framework when the plugin is activated (i.e. selected by the user). It is usually used to define properties pertaining to the specific plugin functionalities.
Implements Connection::Interface.
Definition at line 353 of file connectiontcp.cpp.
◆ Connect()
| bool Connection::TCP::Connect |
( |
| ) |
|
|
overridevirtual |
Connect Connect to device via the implemented communication medium. Do not perform any handshakes.
- Returns
- True if successful, false otherwise.
Implements Connection::Interface.
Definition at line 208 of file connectiontcp.cpp.
◆ connectionType()
◆ Deactivated()
| void Connection::TCP::Deactivated |
( |
| ) |
|
|
overridevirtual |
Deactivated Function called by the framework when the plugin is deactivated. It is usually used to delete properties by were defined previously since the plugin is no longer active.
Implements Connection::Interface.
Definition at line 366 of file connectiontcp.cpp.
◆ Disconnect()
| bool Connection::TCP::Disconnect |
( |
| ) |
|
|
overridevirtual |
◆ establishConnection()
| bool Connection::TCP::establishConnection |
( |
const std::string & |
hostname, |
|
|
const std::string & |
port, |
|
|
int |
timeout = -1 |
|
) |
| |
|
protected |
establishConnection Create a socket connection to the host and port. If successful, set the socket variable.
- Parameters
-
| hostname | fully qualified hostname or IP address to host |
| port | Port |
| timeout | timeout in seconds. If not sent, use default 5 seconds timeout. |
- Returns
- Success if connection established, false otherwise.
- Note
- Connection type (TCP vs UDP) is fetched from the TcpUdpSP property.
Definition at line 140 of file connectiontcp.cpp.
◆ getPortFD()
| int Connection::TCP::getPortFD |
( |
| ) |
const |
|
inline |
◆ host()
| virtual const char * Connection::TCP::host |
( |
| ) |
const |
|
inlinevirtual |
◆ ISNewSwitch()
| bool Connection::TCP::ISNewSwitch |
( |
const char * |
dev, |
|
|
const char * |
name, |
|
|
ISState * |
states, |
|
|
char * |
names[], |
|
|
int |
n |
|
) |
| |
|
overridevirtual |
◆ ISNewText()
| bool Connection::TCP::ISNewText |
( |
const char * |
dev, |
|
|
const char * |
name, |
|
|
char * |
texts[], |
|
|
char * |
names[], |
|
|
int |
n |
|
) |
| |
|
overridevirtual |
◆ label()
| virtual std::string Connection::TCP::label |
( |
| ) |
|
|
inlineoverridevirtual |
◆ name()
| virtual std::string Connection::TCP::name |
( |
| ) |
|
|
inlineoverridevirtual |
◆ port()
| virtual uint32_t Connection::TCP::port |
( |
| ) |
const |
|
inlinevirtual |
◆ saveConfigItems()
| bool Connection::TCP::saveConfigItems |
( |
FILE * |
fp | ) |
|
|
overridevirtual |
◆ setConnectionType()
| void Connection::TCP::setConnectionType |
( |
int |
type | ) |
|
TODO should be renamed to setDefaultConnectionType.
Definition at line 416 of file connectiontcp.cpp.
◆ setDefaultHost()
| void Connection::TCP::setDefaultHost |
( |
const char * |
addressHost | ) |
|
◆ setDefaultPort()
| void Connection::TCP::setDefaultPort |
( |
uint32_t |
addressPort | ) |
|
◆ setLANSearchEnabled()
| void Connection::TCP::setLANSearchEnabled |
( |
bool |
enabled | ) |
|
◆ AddressTP
◆ LANSearchSP
◆ m_ConfigConnectionType
| int Connection::TCP::m_ConfigConnectionType {-1} |
|
protected |
◆ m_ConfigHost
| std::string Connection::TCP::m_ConfigHost |
|
protected |
◆ m_ConfigPort
| std::string Connection::TCP::m_ConfigPort |
|
protected |
◆ m_Permission
◆ m_SockFD
| int Connection::TCP::m_SockFD {-1} |
|
protected |
◆ PortFD
| int Connection::TCP::PortFD = -1 |
|
protected |
◆ SOCKET_TIMEOUT
| constexpr uint8_t Connection::TCP::SOCKET_TIMEOUT {5} |
|
staticconstexprprotected |
◆ TcpUdpSP
The documentation for this class was generated from the following files: