CANpie FD
CAN programming interface environment - Version 3.08
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Modules Pages
Public Types | Signals | Public Member Functions
QCanServerSettings Class Reference

Detailed Description

The QCanServerSettings provides the functionality to test the current state of a QCanServer, its version number and the number of supported CAN networks. Communication between an instance of the QCanServer class and the QCanServerSettings class is done via WebSockets using JSON.

The following code shows an example how to establish a connection to a local QCanServer:

QCanServerSettings clServerSettingsT;
clServerSettingsT.connectToServer(); // connect to local server

Connection to a QCanServer running on a different machine is only possible if remote access was granted by calling QCanServer::setServerAddress().

QCanServerSettings clServerSettingsT;
clServerSettingsT.connectToServer(QHostAddress("192.168.2.12")); // connect to remote server

A state change of the QCanServer class is signalled via stateChanged(). Data from the QCanServer class is in JSON format, new data can be inspected via objectReceived().

Inherits QObject.

Public Types

enum  State_e {
  eSTATE_UNKNOWN = -1,
  eSTATE_INACTIVE = 0,
  eSTATE_CLOSED = 1,
  eSTATE_ACTIVE = 2
}
 

Signals

void stateChanged (enum QCanServerSettings::State_e teStateV)
 
void objectReceived (QJsonObject clServerSettingsV)
 

Public Member Functions

 QCanServerSettings (QObject *pclParentV=Q_NULLPTR)
 
void connectToServer (const QHostAddress clServerAddressV=QHostAddress::LocalHost, const uint16_t uwPortV=QCAN_WEB_SOCKET_DEFAULT_PORT, const QString &clOriginR="", const uint32_t flags=0)
 
bool isValid (void)
 
int32_t networkCount (void)
 
State_e state (void)
 
QString stateString (void)
 
int32_t versionBuild (void)
 
int32_t versionMajor (void)
 
int32_t versionMinor (void)
 

Member Enumeration Documentation

◆ State_e

This enumeration describes possible states of the server.

Enumerator
eSTATE_UNKNOWN 

Server is in unknown state.

eSTATE_INACTIVE 

Server is not running.

eSTATE_CLOSED 

Server has been closed

eSTATE_ACTIVE 

Server is active

Constructor & Destructor Documentation

◆ QCanServerSettings()

QCanServerSettings::QCanServerSettings ( QObject *  pclParentV = Q_NULLPTR)
Parameters
[in]pclParentV- Pointer to QObject parent class

Construct a QCanServerSettings object

Member Function Documentation

◆ connectToServer()

void QCanServerSettings::connectToServer ( const QHostAddress  clServerAddressV = QHostAddress::LocalHost,
const uint16_t  uwPortV = QCAN_WEB_SOCKET_DEFAULT_PORT,
const QString &  clOriginR = "",
const uint32_t  flags = 0 
)
Parameters
[in]clServerAddressV- IPv4 or IPv6 address of QCanServer class
[in]uwPortV- port number of QCanServer class
[in]clOriginR- origin of the client
[in]flags- reserved

The method opens a WebSocket connection to a QCanServer class defined by clServerAddressV and uwPortV.

The origin of the client defined by clOriginR is as specified in RFC 6454. The origin is not required for non-web browser clients (see RFC 6455). The origin may not contain new line characters, otherwise the connection will be aborted immediately during the handshake phase.

◆ isValid()

bool QCanServerSettings::isValid ( void  )
Returns
True if valid data available

The function returns True if a connection has been established to a QCanServer and the received JSON data has a vaild format.

◆ networkCount()

int32_t QCanServerSettings::networkCount ( void  )
Returns
Number of CAN networks

Return the number of networks (i.e. QCanNetwork) managed by the QCanServer class.

◆ objectReceived

void QCanServerSettings::objectReceived ( QJsonObject  clServerSettingsV)
signal
Parameters
[in]clServerSettingsV- JSON data

This signal is emitted after a new object was received from an active QCanServer. The JSON data has the following format:

{
"allowBitrateChange": true,
"allowBusOffRecovery": true,
"allowModeChange": true,
"apiVersion": "1.0",
"networkCount": 8,
"serverLocalTime": "2020-01-21T16:30:36",
"serverUptime": 15010,
"versionBuild": 0,
"versionMajor": 1,
"versionMinor": 0
}

◆ state()

State_e QCanServerSettings::state ( void  )
Returns
State of local QCanServer
See also
stateString()

Return the state of a local QCanServer, possible values are listed by QCanServerSettings::State_e.

◆ stateChanged

void QCanServerSettings::stateChanged ( enum QCanServerSettings::State_e  teStateV)
signal
Parameters
[in]teStateV- Server state
See also
state()

This signal is emitted after a state change from a QCanServer.

◆ stateString()

QString QCanServerSettings::stateString ( void  )
Returns
State of local QCanServer
See also
state()

Return the state of a local QCanServer as a QString object.

◆ versionBuild()

int32_t QCanServerSettings::versionBuild ( void  )
Returns
Build version
See also
isValid()

Return the build version of the active QCanServer. A return value of -1 denotes that either no connection could be establed to a QCanServer or the received JSON object was not valid.

◆ versionMajor()

int32_t QCanServerSettings::versionMajor ( void  )
Returns
Major version
See also
isValid()

Return the major version of the active QCanServer. A return value of -1 denotes that either no connection could be establed to a QCanServer or the received JSON object was not valid.

◆ versionMinor()

int32_t QCanServerSettings::versionMinor ( void  )
Returns
Minor version
See also
isValid()

Return the minor version of the active QCanServer. A return value of -1 denotes that either no connection could be establed to a QCanServer or the received JSON object was not valid.

QCanServerSettings::connectToServer
void connectToServer(const QHostAddress clServerAddressV=QHostAddress::LocalHost, const uint16_t uwPortV=QCAN_WEB_SOCKET_DEFAULT_PORT, const QString &clOriginR="", const uint32_t flags=0)
QCanServerSettings
Definition: qcan_server_settings.hpp:81