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

System command engine. More...

Go to the source code of this file.

Typedefs

typedef struct BleCommandEngine BleCommandEngine
 Opaque command engine handle.
 

Functions

BleCommandEngine * ble_command_engine_alloc (Ble *ble, const BleCommandItem *commands, uint8_t commands_count, FuriEventLoop *event_loop)
 Allocates command engine instance with command array provided from the outside.
 
bool ble_command_engine_run (BleCommandEngine *instance, BleIntercomFrameGeneric *frame)
 Perform command processing, command frame can be extracted from command buffer or from intercom for U5 and only from intercom for 917.
 
bool ble_command_engine_put_command (BleCommandEngine *instance, BleSystemCommand code, void *data, size_t data_size)
 Put command into queue and wait until it is processed by ble thread.
 
void ble_command_engine_put_command_no_wait (BleCommandEngine *instance, BleSystemCommand code, void *data, size_t data_size)
 Put command into queue and return.
 
void ble_command_engine_unblock_with_result (BleCommandEngine *instance, const void *const data, const size_t data_size, bool result)
 Unblocks command engine when command is done.
 

Detailed Description

System command engine.

Function Documentation

◆ ble_command_engine_alloc()

BleCommandEngine * ble_command_engine_alloc ( Ble * ble,
const BleCommandItem * commands,
uint8_t commands_count,
FuriEventLoop * event_loop )

Allocates command engine instance with command array provided from the outside.

Parameters
[in]blePointer to ble instance
[in]commandsPredefined command array
[in]commands_countAmount of commands in array
[in]event_loopEvent loop used for queue processing
Returns
Pointer to command engine instance

◆ ble_command_engine_put_command()

bool ble_command_engine_put_command ( BleCommandEngine * instance,
BleSystemCommand code,
void * data,
size_t data_size )

Put command into queue and wait until it is processed by ble thread.

Data and data_size fields are used as input/output fields depending on command. In case when command requires input data, they must be provided in data, and size must be data_size. In case when command returns data, a buffer of appropriate size must be provided, then it will be filled with data. Currently there is no any commands which require both input and output data, in such case this function will return output data only if its size is equal to data_size provided by caller, otherwise it will return false, despite the actual command result.

Parameters
[in]instancePointer to engine instance
[in]codeCommand code from enum
dataData required for command processing, must be NULL if command doesn't require input data and doesn't return any data
data_sizeData size, must be 0 if command doesn't require input data and doesn't return any data
Returns
true if command processed successfully, otherwise false

◆ ble_command_engine_put_command_no_wait()

void ble_command_engine_put_command_no_wait ( BleCommandEngine * instance,
BleSystemCommand code,
void * data,
size_t data_size )

Put command into queue and return.

There are some commands (BleCommandInit, BleCommandSetStatus for example) which are not exposed to api. They perform internally as a reaction to some events or state change. This function enqueues those commands and they will be performed non-blocking way.

Parameters
[in]instancePointer to engine instance
[in]codeCommand code from enum
dataData required for command processing, must be NULL if command doesn't require input data and doesn't return any data
data_sizeData size, must be 0 if command doesn't require input data and doesn't return any data

◆ ble_command_engine_run()

bool ble_command_engine_run ( BleCommandEngine * instance,
BleIntercomFrameGeneric * frame )

Perform command processing, command frame can be extracted from command buffer or from intercom for U5 and only from intercom for 917.

Parameters
[in]instancePointer to engine instance
[in]frameframe with data to be processed
Returns
true when command was processed successfully, otherwise false

◆ ble_command_engine_unblock_with_result()

void ble_command_engine_unblock_with_result ( BleCommandEngine * instance,
const void *const data,
const size_t data_size,
bool result )

Unblocks command engine when command is done.

Parameters
[in]instancepointer to the ble instance
[in]datadata which command can provide
[in]data_sizesize of the data buffer
[in]resultresult of command processing, which will be transferred to public api call and become its return value