Bitbrain SDK 2.8.6
Bitbrain SDK
Loading...
Searching...
No Matches
Manage the connection to the device

Functions to manage the status of the connection to the device. More...

Functions

BBT_SDK_API int bbt_device_run_connection_server (const char *connection_server_folder)
 Starts the servers needed to stablish the connections to the devices.
BBT_SDK_API int bbt_device_kill_connection_server ()
 Kills the connection servers.
BBT_SDK_API int bbt_device_connect (bbt_device_t *device)
 Initiates the connection to the device.
BBT_SDK_API int bbt_device_disconnect (bbt_device_t *device)
 Disconnects from the device and clears the information from the device.
BBT_SDK_API int bbt_device_reconnect (bbt_device_t *device)
 Recovers from accidental disconnection.
BBT_SDK_API int bbt_device_is_connected (const bbt_device_t *device)
 Returns the state of the connection with the device.

Detailed Description

Functions to manage the status of the connection to the device.

Connnections to Bitbrain devices are managed by processes that run in the background. The rationale behind this decission is to be able to manage multiple connections coordinately. The functions in this SDK interact with the servers to communicate with the devices through them. So, in order to communicate with the devices, the servers must be running as long as any connection is active. Thus, make sure that you start them before any call to bbt_device_connect is performed. After all the devices are disconnected, servers can be safely killed.

Important
A single set of connection servers are required per machine. If you plan to have multiple programs connecting to multiple devices, only a single call to bbt_device_run_connection_server is needed.

Wireless connections can fail if the conditions are not optimal. A failure in the connection will provoke a failure in most of the other functions, as a connection is required to communicate to the device. After a failure in one of the calls, it is important to check the connection status and reconnect if needed (check bbt_device_reconnect). The status of the connection to a Bitbrain device does not change the state of the device acquisition, it just breaks the data stream comming and going. So, if a device was configured, the configuration keeps the same after a reconnection. During acquisition, a disconnection may cause data loss in the live stream of data. But if the SD card is enabled, all the data keeps being recorded in the device even during disconnections.

Function Documentation

◆ bbt_device_run_connection_server()

BBT_SDK_API int bbt_device_run_connection_server ( const char * connection_server_folder)

Starts the servers needed to stablish the connections to the devices.

This servers are mandatory to have a successful connection. Run this function before any call to bbt_device_connect.

Parameters
connection_server_folderThe folder where the execuables (bthserver and bbt-connection-server) are in the hard drive
Returns
True on successful launch of the servers. False otherwise.

◆ bbt_device_kill_connection_server()

BBT_SDK_API int bbt_device_kill_connection_server ( )

Kills the connection servers.

Returns
True on success. False otherwise

◆ bbt_device_connect()

BBT_SDK_API int bbt_device_connect ( bbt_device_t * device)

Initiates the connection to the device.

Parameters
deviceThe handler to the device
Returns
True on success

◆ bbt_device_disconnect()

BBT_SDK_API int bbt_device_disconnect ( bbt_device_t * device)

Disconnects from the device and clears the information from the device.

Use this function to make a full disconnection to the device. To solve accidental disconnections, use bbt_device_reconnect.

Parameters
deviceThe handler to the device
Returns
True on success

◆ bbt_device_reconnect()

BBT_SDK_API int bbt_device_reconnect ( bbt_device_t * device)

Recovers from accidental disconnection.

This function will reconnect the device, keeping all the configurations.

Parameters
deviceThe handler to the device
Returns
True on success

◆ bbt_device_is_connected()

BBT_SDK_API int bbt_device_is_connected ( const bbt_device_t * device)

Returns the state of the connection with the device.

Parameters
deviceThe handle to the device
Returns
True if connected, false othersiwe.