TwiceAsNice  2019-02-18
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. More...

#include <connectiontcp.h>

Inheritance diagram for Connection::TCP:
Inheritance graph
Collaboration diagram for Connection::TCP:
Collaboration graph

Public Types

enum  ConnectionType { TYPE_TCP = 0, TYPE_UDP, TYPE_TCP = 0, TYPE_UDP }
 
enum  ConnectionType { TYPE_TCP = 0, TYPE_UDP, 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, CONNECTION_NONE = 1 << 0, CONNECTION_SERIAL = 1 << 1, CONNECTION_TCP = 1 << 2,
  CONNECTION_USB = 1 << 3, CONNECTION_CUSTOM = 1 << 15
}
 
enum  Type {
  CONNECTION_NONE = 1 << 0, CONNECTION_SERIAL = 1 << 1, CONNECTION_TCP = 1 << 2, CONNECTION_USB = 1 << 3,
  CONNECTION_CUSTOM = 1 << 15, 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 ()
 Connect Connect to device via the implemented communication medium. More...
 
virtual bool Disconnect ()
 Disconnect Disconnect from device. More...
 
virtual void Activated ()
 Activated Function called by the framework when the plugin is activated (i.e. More...
 
virtual void Deactivated ()
 Deactivated Function called by the framework when the plugin is deactivated. More...
 
virtual std::string name ()
 
virtual std::string label ()
 
virtual const char * host ()
 
virtual uint32_t port ()
 
virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
 
virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
 
virtual bool saveConfigItems (FILE *fp)
 
int getPortFD () const
 
void setDefaultHost (const char *addressHost)
 
void setDefaultPort (uint32_t addressPort)
 
void setConnectionType (int type)
 
 TCP (INDI::DefaultDevice *dev)
 
virtual ~TCP ()=default
 
virtual bool Connect ()
 Connect Connect to device via the implemented communication medium. More...
 
virtual bool Disconnect ()
 Disconnect Disconnect from device. More...
 
virtual void Activated ()
 Activated Function called by the framework when the plugin is activated (i.e. More...
 
virtual void Deactivated ()
 Deactivated Function called by the framework when the plugin is deactivated. More...
 
virtual std::string name ()
 
virtual std::string label ()
 
virtual const char * host ()
 
virtual uint32_t port ()
 
virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
 
virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
 
virtual bool saveConfigItems (FILE *fp)
 
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)
 
void registerHandshake (std::function< bool()> callback)
 registerHandshake Register a handshake function to be called once the intial connection to the device is established. More...
 
virtual Type type ()
 type Return connection type More...
 
virtual bool ISNewNumber (const char *dev, const char *name, double values[], 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 ()
 
 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.

Member Enumeration Documentation

◆ ConnectionType [1/2]

Enumerator
TYPE_TCP 
TYPE_UDP 
TYPE_TCP 
TYPE_UDP 

◆ ConnectionType [2/2]

Enumerator
TYPE_TCP 
TYPE_UDP 
TYPE_TCP 
TYPE_UDP 

Constructor & Destructor Documentation

◆ TCP() [1/2]

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

◆ ~TCP() [1/2]

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

◆ TCP() [2/2]

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

◆ ~TCP() [2/2]

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

Member Function Documentation

◆ Activated() [1/2]

void Connection::TCP::Activated ( )
virtual

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.

◆ Activated() [2/2]

virtual void Connection::TCP::Activated ( )
virtual

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.

◆ Connect() [1/2]

virtual bool Connection::TCP::Connect ( )
virtual

Connect Connect to device via the implemented communication medium.

Do not perform any handshakes.

Returns
True if successful, false otherwise.

Implements Connection::Interface.

◆ Connect() [2/2]

bool Connection::TCP::Connect ( )
virtual

Connect Connect to device via the implemented communication medium.

Do not perform any handshakes.

Returns
True if successful, false otherwise.

Implements Connection::Interface.

◆ Deactivated() [1/2]

void Connection::TCP::Deactivated ( )
virtual

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.

◆ Deactivated() [2/2]

virtual void Connection::TCP::Deactivated ( )
virtual

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.

◆ Disconnect() [1/2]

bool Connection::TCP::Disconnect ( )
virtual

Disconnect Disconnect from device.

Returns
True if successful, false otherwise.

Implements Connection::Interface.

◆ Disconnect() [2/2]

virtual bool Connection::TCP::Disconnect ( )
virtual

Disconnect Disconnect from device.

Returns
True if successful, false otherwise.

Implements Connection::Interface.

◆ getPortFD() [1/2]

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

◆ getPortFD() [2/2]

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

◆ host() [1/2]

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

◆ host() [2/2]

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

◆ ISNewSwitch() [1/2]

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

Reimplemented from Connection::Interface.

◆ ISNewSwitch() [2/2]

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

Reimplemented from Connection::Interface.

◆ ISNewText() [1/2]

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

Reimplemented from Connection::Interface.

◆ ISNewText() [2/2]

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

Reimplemented from Connection::Interface.

◆ label() [1/2]

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

Implements Connection::Interface.

◆ label() [2/2]

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

Implements Connection::Interface.

◆ name() [1/2]

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

Implements Connection::Interface.

◆ name() [2/2]

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

Implements Connection::Interface.

◆ port() [1/2]

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

◆ port() [2/2]

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

◆ saveConfigItems() [1/2]

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

Reimplemented from Connection::Interface.

◆ saveConfigItems() [2/2]

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

Reimplemented from Connection::Interface.

◆ setConnectionType() [1/2]

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

◆ setConnectionType() [2/2]

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

◆ setDefaultHost() [1/2]

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

◆ setDefaultHost() [2/2]

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

◆ setDefaultPort() [1/2]

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

◆ setDefaultPort() [2/2]

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

Member Data Documentation

◆ AddressT

IText Connection::TCP::AddressT {}
protected

◆ AddressTP

ITextVectorProperty Connection::TCP::AddressTP
protected

◆ PortFD

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

◆ SOCKET_TIMEOUT

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

◆ sockfd

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

◆ TcpUdpS

ISwitch Connection::TCP::TcpUdpS
protected

◆ TcpUdpSP

ISwitchVectorProperty Connection::TCP::TcpUdpSP
protected

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