Connectino Library
Public Member Functions | List of all members
ConnectinoArrowConnect Class Reference

ArrowConnect module. More...

#include <ConnectinoArrowConnect.h>

Inheritance diagram for ConnectinoArrowConnect:
ConnectinoModule

Public Member Functions

 ConnectinoArrowConnect (StxHwSerial &refSerial)
 ArrowConnect module constructor. More...
 
bool moduleCallback (uint8_t subId, uint8_t reqId, uint16_t dataSize, uint8_t *data)
 Callback function for serial frames of the ArrowConnect module. More...
 
uint8_t getModId ()
 Get the ID of the ArrowConnect module. More...
 
bool connect (char *server, uint16_t port, char *vHost, char *gatewayHid, char *apiKey, char *deviceHid, bool waitConnected)
 Connect to the configured server and gateway. More...
 
bool disconnect (bool waitDisconnected=false)
 Disconnect from the configured server. More...
 
bool isConnected (void)
 Check the connection state of the ArrowConnect module. More...
 
bool available (void)
 Check if data is available. More...
 
bool read (char *command, uint16_t *commandLen, char *payload, uint16_t *payloadLen)
 Receive commands sent by the server. More...
 
void clear (void)
 Clear the receive buffer. More...
 
bool publish (char *varName, char *data)
 Publish data. More...
 
bool publish (char *varName, bool data)
 Publish data. More...
 
bool publish (char *varName, long int data)
 Publish data. More...
 
bool publish (char *varName1, long int data1, char *varName2, long int data2)
 Publish data. More...
 
- Public Member Functions inherited from ConnectinoModule
void begin ()
 Starts the module.
 

Additional Inherited Members

- Protected Member Functions inherited from ConnectinoModule
bool append (uint8_t **buffer, uint16_t *bufferSize, const char data[], const uint8_t numOfSizeBytes=1)
 Append a string to the frames payload. More...
 
bool append (uint8_t **buffer, uint16_t *bufferSize, const uint8_t data[], const uint16_t dataSize, const uint8_t numOfSizeBytes=1)
 Append binary data to the frames payload. More...
 
bool append (uint8_t **buffer, uint16_t *bufferSize, const bool data)
 Append a boolean to the frames payload. More...
 
bool append (uint8_t **buffer, uint16_t *bufferSize, const uint8_t data)
 Append a uint8_t variable to the frames payload. More...
 
bool append (uint8_t **buffer, uint16_t *bufferSize, const uint16_t data)
 Append a uint16_t variable to the frames payload. More...
 
bool append (uint8_t **buffer, uint16_t *bufferSize, const uint32_t data)
 Append a uint32_t variable to the frames payload. More...
 

Detailed Description

ArrowConnect module.

The ArrowConnect module can be used to publish data on the Arrow Connect Portal. Therefore the module needs to be configured with a gateway HID, the API key for the gateway and the device HID. Server address, port and vHost also needs to be configured.

Constructor & Destructor Documentation

◆ ConnectinoArrowConnect()

ConnectinoArrowConnect::ConnectinoArrowConnect ( StxHwSerial &  refSerial)

ArrowConnect module constructor.

Instantiates the ArrowConnect module and connects it to the hardware serial.

Parameters
refSerialA reference to the hardware serial.

Member Function Documentation

◆ moduleCallback()

bool ConnectinoArrowConnect::moduleCallback ( uint8_t  subId,
uint8_t  reqId,
uint16_t  dataSize,
uint8_t *  data 
)
virtual

Callback function for serial frames of the ArrowConnect module.

This function will be called for messages sent by the WiFi module which are targeted at the ArrowConnect module.

Parameters
subIdSub ID of the message.
reqIdRequest ID of the message.
dataSizeSize of the received data.
dataReference to the received data.
Return values
Returnswhether or not to block the current frame.

Implements ConnectinoModule.

◆ getModId()

uint8_t ConnectinoArrowConnect::getModId ( )
virtual

Get the ID of the ArrowConnect module.

This function will return the module ID of the ArrowConnect module defined in MODULE.h.

Return values
Themodule ID.

Implements ConnectinoModule.

◆ connect()

bool ConnectinoArrowConnect::connect ( char *  server,
uint16_t  port,
char *  vHost,
char *  gatewayHid,
char *  apiKey,
char *  deviceHid,
bool  waitConnected 
)

Connect to the configured server and gateway.

This function will configure the ArrowConnect client with the given parameters and try to establish a connection. It will be informed about the connection state in the modules callback function.

Parameters
serverServer address.
portServer port.
vHostVirtual host.
gatewayHidGateway HID.
apiKeyGateway API key.
deviceHidDevice HID.
waitConnectedIf true this function is a blocking wait until connected.
Return values
Trueif success, false otherwise.

◆ disconnect()

bool ConnectinoArrowConnect::disconnect ( bool  waitDisconnected = false)

Disconnect from the configured server.

This function will disconnect the ArrowConnect module from the configured server. Connect function needs to be called again to establish connection.

Parameters
waitDisconnectedIf true this function is a blocking wait until disconnected.
Return values
Trueif success, false otherwise.

◆ isConnected()

bool ConnectinoArrowConnect::isConnected ( void  )

Check the connection state of the ArrowConnect module.

Checks if the ArrowConnect module is connected to the configured server.

Return values
Trueif connected, false otherwise.

◆ available()

bool ConnectinoArrowConnect::available ( void  )

Check if data is available.

With this function the user can check if data is available for this device.

Return values
Trueif data available, false otherwise.
Note
When data was received the receive buffer is blocked and no other messages can be received. Be sure to read out or clear the data when there is data available.

◆ read()

bool ConnectinoArrowConnect::read ( char *  command,
uint16_t *  commandLen,
char *  payload,
uint16_t *  payloadLen 
)

Receive commands sent by the server.

This function will read out received commands together with their payload.

Parameters
commandReceived command.
commandLenLength of received command.
payloadReceived Payload.
payloadLenSize of received payload.
Return values
Trueif success, false otherwise.

◆ clear()

void ConnectinoArrowConnect::clear ( void  )

Clear the receive buffer.

Clears the receive buffer if there is an entry available.

◆ publish() [1/4]

bool ConnectinoArrowConnect::publish ( char *  varName,
char *  data 
)

Publish data.

This publishes the given string on the configured server if the ArrowConnect module has an active connection.

Parameters
varNameName of the variable which is sent.
dataThe string which should be sent.
Return values
Trueif success, false otherwise.

◆ publish() [2/4]

bool ConnectinoArrowConnect::publish ( char *  varName,
bool  data 
)

Publish data.

This publishes the given boolean on the configured server if the ArrowConnect module has an active connection.

Parameters
varNameName of the variable which is sent.
dataThe boolean which should be sent.
Return values
Trueif success, false otherwise.

◆ publish() [3/4]

bool ConnectinoArrowConnect::publish ( char *  varName,
long int  data 
)

Publish data.

This publishes the given integer on the configured server if the ArrowConnect module has an active connection.

Parameters
varNameName of the variable which is sent.
dataThe integer which should be sent.
Return values
Trueif success, false otherwise.

◆ publish() [4/4]

bool ConnectinoArrowConnect::publish ( char *  varName1,
long int  data1,
char *  varName2,
long int  data2 
)

Publish data.

This publishes the given integers on the configured server if the ArrowConnect module has an active connection.

Parameters
varName1Name of the first variable which is sent.
data1The first integer which should be sent.
varName2Name of the second variable which is sent.
data2The second integer which should be sent.
Return values
Trueif success, false otherwise.

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