Instrument Neutral Distributed Interface INDI  1.9.2
Public Types | Public Member Functions | Protected Attributes | List of all members
Connection::TCP Class Reference

The TCP class manages connection with devices over the network via TCP/IP. Upon successfull 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>

Inheritance diagram for Connection::TCP:
Connection::Interface

Public Types

enum  ConnectionType { TYPE_TCP = 0, TYPE_UDP }
 
- Public Types inherited from Connection::Interface
enum  Type {
  CONNECTION_NONE = 1 << 0, CONNECTION_SERIAL = 1 << 1, CONNECTION_TCP = 1 << 2, CONNECTION_USB = 1 << 3,
  CONNECTION_CUSTOM = 1 << 15
}
 

Public Member Functions

 TCP (INDI::DefaultDevice *dev)
 
virtual ~TCP ()=default
 
virtual bool Connect () override
 Connect Connect to device via the implemented communication medium. Do not perform any handshakes. More...
 
virtual bool Disconnect () override
 Disconnect Disconnect from device. More...
 
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. More...
 
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. More...
 
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)
 
- Public Member Functions inherited from Connection::Interface
virtual Type type ()
 type Return connection type More...
 
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 intial connection to the device is established. More...
 

Protected Attributes

ITextVectorProperty AddressTP
 
IText AddressT [2] {}
 
ISwitch TcpUdpS [2]
 
ISwitchVectorProperty TcpUdpSP
 
int sockfd = -1
 
const uint8_t SOCKET_TIMEOUT = 5
 
int PortFD = -1
 
- Protected Attributes inherited from Connection::Interface
std::function< bool()> Handshake
 
INDI::DefaultDevicem_Device { nullptr }
 
Type m_Type { CONNECTION_NONE }
 

Additional Inherited Members

- Protected Member Functions inherited from Connection::Interface
 Interface (INDI::DefaultDevice *dev, Type type=CONNECTION_NONE)
 
virtual ~Interface ()
 
const char * getDeviceName ()
 

Detailed Description

The TCP class manages connection with devices over the network via TCP/IP. Upon successfull connection, reads & writes from and to the device are performed via the returned file descriptor using standard UNIX read/write functions.

Definition at line 55 of file connectiontcp.h.

Member Enumeration Documentation

◆ ConnectionType

Enumerator
TYPE_TCP 
TYPE_UDP 

Definition at line 76 of file connectiontcp.h.

Constructor & Destructor Documentation

◆ TCP()

Connection::TCP::TCP ( INDI::DefaultDevice dev)

Definition at line 55 of file connectiontcp.cpp.

◆ ~TCP()

virtual Connection::TCP::~TCP ( )
virtualdefault

Member Function Documentation

◆ 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 209 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 112 of file connectiontcp.cpp.

◆ connectionType()

ConnectionType Connection::TCP::connectionType ( ) const
inline

Definition at line 99 of file connectiontcp.h.

◆ 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 217 of file connectiontcp.cpp.

◆ Disconnect()

bool Connection::TCP::Disconnect ( )
overridevirtual

Disconnect Disconnect from device.

Returns
True if successful, false otherwise.

Implements Connection::Interface.

Definition at line 198 of file connectiontcp.cpp.

◆ getPortFD()

int Connection::TCP::getPortFD ( ) const
inline

Definition at line 105 of file connectiontcp.h.

◆ host()

virtual const char* Connection::TCP::host ( ) const
inlinevirtual

Definition at line 97 of file connectiontcp.h.

◆ ISNewSwitch()

bool Connection::TCP::ISNewSwitch ( const char *  dev,
const char *  name,
ISState states,
char *  names[],
int  n 
)
overridevirtual

Reimplemented from Connection::Interface.

Definition at line 94 of file connectiontcp.cpp.

◆ ISNewText()

bool Connection::TCP::ISNewText ( const char *  dev,
const char *  name,
char *  texts[],
char *  names[],
int  n 
)
overridevirtual

Reimplemented from Connection::Interface.

Definition at line 77 of file connectiontcp.cpp.

◆ label()

virtual std::string Connection::TCP::label ( )
inlineoverridevirtual
Returns
Plugin friendly label presented to the client/user.

Implements Connection::Interface.

Definition at line 95 of file connectiontcp.h.

◆ name()

virtual std::string Connection::TCP::name ( )
inlineoverridevirtual
Returns
Plugin name

Implements Connection::Interface.

Definition at line 93 of file connectiontcp.h.

◆ port()

virtual uint32_t Connection::TCP::port ( ) const
inlinevirtual

Definition at line 98 of file connectiontcp.h.

◆ saveConfigItems()

bool Connection::TCP::saveConfigItems ( FILE *  fp)
overridevirtual

Reimplemented from Connection::Interface.

Definition at line 223 of file connectiontcp.cpp.

◆ setConnectionType()

void Connection::TCP::setConnectionType ( int  type)

Definition at line 243 of file connectiontcp.cpp.

◆ setDefaultHost()

void Connection::TCP::setDefaultHost ( const char *  addressHost)

Definition at line 231 of file connectiontcp.cpp.

◆ setDefaultPort()

void Connection::TCP::setDefaultPort ( uint32_t  addressPort)

Definition at line 236 of file connectiontcp.cpp.

Member Data Documentation

◆ AddressT

IText Connection::TCP::AddressT[2] {}
protected

Definition at line 113 of file connectiontcp.h.

◆ AddressTP

ITextVectorProperty Connection::TCP::AddressTP
protected

Definition at line 112 of file connectiontcp.h.

◆ PortFD

int Connection::TCP::PortFD = -1
protected

Definition at line 121 of file connectiontcp.h.

◆ SOCKET_TIMEOUT

const uint8_t Connection::TCP::SOCKET_TIMEOUT = 5
protected

Definition at line 119 of file connectiontcp.h.

◆ sockfd

int Connection::TCP::sockfd = -1
protected

Definition at line 118 of file connectiontcp.h.

◆ TcpUdpS

ISwitch Connection::TCP::TcpUdpS[2]
protected

Definition at line 115 of file connectiontcp.h.

◆ TcpUdpSP

ISwitchVectorProperty Connection::TCP::TcpUdpSP
protected

Definition at line 116 of file connectiontcp.h.


The documentation for this class was generated from the following files: