gForceSDK
gf::Hub Class Referenceabstract

The abstract of a gForce Hub. More...

#include <Hub.h>

Public Member Functions

virtual GF_RET_CODE init (GF_UINT8 comPort=0)=0
 Initialize the Hub instance. More...
 
virtual GF_RET_CODE deinit ()=0
 De-initialize the Hub instance. More...
 
virtual WorkMode getWorkMode () const =0
 Get work mode. More...
 
virtual void setWorkMode (WorkMode newMode)=0
 Set work mode. More...
 
virtual HubState getState ()=0
 Get hub state. More...
 
virtual tstring getDescString () const =0
 A description text of the hub. More...
 
virtual GF_RET_CODE registerListener (const gfwPtr< HubListener > &listener)=0
 Register HubListener. More...
 
virtual GF_RET_CODE unRegisterListener (const gfwPtr< HubListener > &listener)=0
 Un-register HubListener. More...
 
virtual GF_RET_CODE startScan (GF_UINT8 rssiThreshold=200)=0
 Start gForce scan. More...
 
virtual GF_RET_CODE stopScan ()=0
 Stop gForce scan. More...
 
virtual GF_SIZE getNumOfDevices (bool bConnectedOnly=true) const =0
 Get the number of all devices found. More...
 
virtual void enumDevices (std::function< bool(SPDEVICE)> &funEnum, bool bConnectedOnly=true)=0
 Enumurate devices. More...
 
virtual SPDEVICE findDevice (GF_UINT8 addrType, tstring address)=0
 Find a gForce device. More...
 
virtual GF_RET_CODE run (GF_UINT32 ms, bool once=false)=0
 run message polling More...
 

Detailed Description

The abstract of a gForce Hub.

The Hub is mantained by HubManager as a singleton instance. See HubManager for more detail about the life cycle.

Member Function Documentation

◆ deinit()

virtual GF_RET_CODE gf::Hub::deinit ( )
pure virtual

De-initialize the Hub instance.

Returns
The result of de-initalization.
Remarks
During de-initialization, all gForce devices will be disconnected and dropped.

◆ enumDevices()

virtual void gf::Hub::enumDevices ( std::function< bool(SPDEVICE)> &  funEnum,
bool  bConnectedOnly = true 
)
pure virtual

Enumurate devices.

Parameters
funEnumThe enumurate function
bConnectedOnlytrue if only want to get connected devices,
false if want to get all devices.
Remarks
The return value of funEnum tells gForce if client wants to continue next enumerate true to continue enumerate, otherwise stop it.

◆ findDevice()

virtual SPDEVICE gf::Hub::findDevice ( GF_UINT8  addrType,
tstring  address 
)
pure virtual

Find a gForce device.

Returns
The weak pointer of the device found, nullptr if not found.

◆ getDescString()

virtual tstring gf::Hub::getDescString ( ) const
pure virtual

A description text of the hub.

Returns
A text string

◆ getNumOfDevices()

virtual GF_SIZE gf::Hub::getNumOfDevices ( bool  bConnectedOnly = true) const
pure virtual

Get the number of all devices found.

Parameters
bConnectedOnlytrue if only want to get number of connected devices,
false if want to get all devices.
Returns
The Number of all devices

◆ getState()

virtual HubState gf::Hub::getState ( )
pure virtual

Get hub state.

Returns
The current hub state

◆ getWorkMode()

virtual WorkMode gf::Hub::getWorkMode ( ) const
pure virtual

Get work mode.

Returns
The current work mode
Remarks
Default work mode is Polling

◆ init()

virtual GF_RET_CODE gf::Hub::init ( GF_UINT8  comPort = 0)
pure virtual

Initialize the Hub instance.

Parameters
comPortSpecify the COM port the physical Hub is connecting with. 0 means to enumuate COM ports and find one automatically.
Returns
The result of initalization.
Remarks
Possible conditions that initialize may fail.
  1. The hub is not plugged in the USB port.
  2. Other apps are connected to the hub already.

◆ registerListener()

virtual GF_RET_CODE gf::Hub::registerListener ( const gfwPtr< HubListener > &  listener)
pure virtual

Register HubListener.

Parameters
listenerThe client listener to be registered
Returns
The result of registration.

◆ run()

virtual GF_RET_CODE gf::Hub::run ( GF_UINT32  ms,
bool  once = false 
)
pure virtual

run message polling

Parameters
msThe method will return after ms milliseconds. No matter messages are processed or not.
onceIf true, method will return if one message is processed, or ms milliseconds expired.
Returns
Possible return values:
  1. GF_RET_CODE::GF_ERROR_BAD_STATE: the method already been called in other threads, or not in proper WorkMode.
  2. GF_RET_CODE::GF_ERROR_TIMEOUT: ms milliseconds expired.
  3. GF_RET_CODE::GF_SUCCESS: return with no error.
Remarks
See more in WorkMode.

◆ setWorkMode()

virtual void gf::Hub::setWorkMode ( WorkMode  newMode)
pure virtual

Set work mode.

Returns
The current work mode
Remarks
Default work mode is Polling.
See Hub::run and WorkMode also.

◆ startScan()

virtual GF_RET_CODE gf::Hub::startScan ( GF_UINT8  rssiThreshold = 200)
pure virtual

Start gForce scan.

Parameters
rssiThresholdThe threshold to filter devices.
0 - use preset default value.
Returns
GF_RET_CODE type to indicate if the command sent to hub or not

◆ stopScan()

virtual GF_RET_CODE gf::Hub::stopScan ( )
pure virtual

Stop gForce scan.

Returns
GF_RET_CODE type to indicate if the command succeeded or not

◆ unRegisterListener()

virtual GF_RET_CODE gf::Hub::unRegisterListener ( const gfwPtr< HubListener > &  listener)
pure virtual

Un-register HubListener.

Parameters
listenerThe client listener to be un-registered
Returns
The result of un-registration.

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