BSB Developer Docs
Loading...
Searching...
No Matches
ble_worker.h File Reference

Responsible for all operations with ble and exists only on 917. More...

Go to the source code of this file.

Macros

#define BLE_REMOTE_ADDRESS_STRING_SIZE   (18)
 

Typedefs

typedef struct BleWorker BleWorker
 Opaque BleWorker type declaration.
 
typedef void(* BleConnectionStateChanged) (void *context, bool connected, const uint8_t *remote_dev_address)
 Type definition for connection state change.
 

Functions

BleWorker * ble_worker_init (BleConnectionStateChanged connect_callback, void *ctx)
 Initializes worker when BleCommandInit is process by 917 at startup.
 
bool ble_worker_register_service (BleServiceObject *service)
 Performs registration of each inner ble service during service initialization.
 
void ble_worker_send (uint16_t handle, uint16_t data_size, const uint8_t *data, uint16_t cccd_value)
 Send payload to characteristic set by handle.
 
void ble_worker_receive_confirm (uint16_t handle, uint8_t cccd_value)
 Used by services in order to confirm data receiving.
 
void ble_worker_start ()
 Starts ble on BleCommandEnable from U5.
 
void ble_worker_stop ()
 Stops ble on BleCommandDisable from U5.
 
bool ble_worker_forget_pairing ()
 Forgets pairing with remote device on BleCommandForgetPairing.
 
bool ble_worker_pairing_exists ()
 Checks whether pairing with remote device exists.
 
void ble_worker_set_name (const char *new_name)
 Sets new device name used for advertising.
 

Detailed Description

Responsible for all operations with ble and exists only on 917.

Typedef Documentation

◆ BleConnectionStateChanged

typedef void( * BleConnectionStateChanged) (void *context, bool connected, const uint8_t *remote_dev_address)

Type definition for connection state change.

Worker will trigger this callback if connection state was changed

Parameters
[in]contextused for this call
[in]connectedactual connection state
[in]remote_dev_addressaddress of connected remote device

Function Documentation

◆ ble_worker_forget_pairing()

bool ble_worker_forget_pairing ( )

Forgets pairing with remote device on BleCommandForgetPairing.

Returns
true when pairing removed

◆ ble_worker_init()

BleWorker * ble_worker_init ( BleConnectionStateChanged connect_callback,
void * ctx )

Initializes worker when BleCommandInit is process by 917 at startup.

Parameters
[in]connect_callbackcallback which will be used by worker for connection events
[in]ctxcontext for connect_callback
Returns
pointer to the instance of BleWorker

TODO:Remove this in future

◆ ble_worker_pairing_exists()

bool ble_worker_pairing_exists ( )

Checks whether pairing with remote device exists.

This function returns value nevertheless of actual connection state.

Returns
true when paired, otherwise false

◆ ble_worker_receive_confirm()

void ble_worker_receive_confirm ( uint16_t handle,
uint8_t cccd_value )

Used by services in order to confirm data receiving.

This function is called only by U5 response that it received data

Parameters
[in]handleunique pointer to particular ble characteristic
[in]cccd_valuespecial field with properties which each characteristic in ble has

◆ ble_worker_register_service()

bool ble_worker_register_service ( BleServiceObject * service)

Performs registration of each inner ble service during service initialization.

During this process each service and characteristics inside are registered in nwp and get their own handles which are then used as indexes during requesting those fields

Parameters
[in]serviceinstance to service object
Returns
true if registration success

◆ ble_worker_send()

void ble_worker_send ( uint16_t handle,
uint16_t data_size,
const uint8_t * data,
uint16_t cccd_value )

Send payload to characteristic set by handle.

Parameters
[in]handleunique pointer to particular ble characteristic. BleServiceObject and all inner BleCharacteristicObject get such handle during ble_worker_register_service call
[in]data_sizesize of payload to be send
[in]datapayload
[in]cccd_valuespecial field with properties which each characteristic in ble has

◆ ble_worker_set_name()

void ble_worker_set_name ( const char * new_name)

Sets new device name used for advertising.

Parameters
[in]new_namename got from U5 side