BLEClient Class

BLEClient Class

Description
A class used for discovering and accessing BLE GATT services on a connected remote device.

Syntax
class BLEClient

Members

Public Constructors
No public constructor is available for this class. You can get a pointer to an instance of this class using BLEDevice::addClient().
Public Methods 
BLEClient::connectedCheck if the corresponding remote device for the client is connected
BLEClient::discoverServicesStart service discovery process for connected device
BLEClient::discoveryDoneDetermine if service discovery process has been completed
BLEClient::printServicesFormat and print discovered services to serial port
BLEClient::getServiceGet a specific service on the remote device
BLEClient::getConnId 
BLEClient::getClientIdGet corresponding client ID
BLEClient::setDisconnectCallbackSet a user function to be called when the remote device is disconnected

BLEClient::connected

Description
Check if the remote device associated with the client is still connected.

Syntax
bool connected();

Parameters
The function requires no input parameter.

Returns
The function returns TRUE if the remote device is connected.

Example Code
NA

Notes and Warnings
NA
 

BLEClient::discoverServices

Description
Start the service discovery process for the connected remote device.

Syntax
void discoverServices();

Parameters
The function requires no input parameter.

Returns
The function returns nothing.

Example Code
Example: BLEUartClient

Notes and Warnings
NA
 

BLEClient::discoveryDone

Description
Check if the service discovery process has been completed.

Syntax
bool discoveryDone();

Parameters
The function requires no input parameter.

Returns
TThe function returns TRUE if the service discovery process has been completed successfully, FALSE if the service discovery process failed, is still in progress, or has yet to start.

Example Code
Example: BLEUartClient

Notes and Warnings
NA
 

BLEClient::printServices

Description
Print out a formatted list of discovered services to the serial port.

Syntax
void printServices();

Parameters
The function requires no input parameter.

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
NA
 

BLEClient::getService

Description
Get a service with the specified UUID on the remote device.

Syntax
BLERemoteService* getService(const char* uuid);
BLERemoteService* getService(BLEUUID uuid);

Parameters
uuid: the desired service UUID, expressed as a character array or a BLEUUID object.

Returns
The function returns the found service as a BLERemoteService object pointer, otherwise nullptr is returned if a service with the UUID is not found.

Example Code
Example: BLEUartClient

Notes and Warnings
NA
 

BLEClient::getConnId

Description
Get the connection ID associated with the remote device.

Syntax
uint8_t getConnId;

Parameters
The function requires no input parameter.

Returns
The function returns the connection ID for the connected remote device.

Example Code
NA

Notes and Warnings
NA
 

BLEClient::getClientId

Description
Get the client ID for the BLEClient object.

Syntax
T_CLIENT_ID getClientId();;

Parameters
The function requires no input parameter.

Returns
The function returns the BLEClient object’s client ID.

Example Code
NA

Notes and Warnings
The client ID is used when calling internal GATT client API.
 

BLEClient::setDisconnectCallback

Description
Set a user function as a callback function when the remote device is disconnected.

Syntax
void setDisconnectCallback(void (*fCallback) (BLEClient* client));

Parameters
fCallback: A user callback function that returns void and takes one argument.
client: A pointer to the BLEClient object corresponding to the disconnected remote device

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
The user callback function will be called after the remote device has disconnected, before the characteristics, services and client associated with the remote device are deleted.
 

Copyrights ©瑞晟微电子(苏州)有限公司 2021. All rights reserved.
請先確認已安裝QQ通訊軟體