![]() |
BSB Developer Docs
|
Public api for ble services. More...
#include "../ble_log.h"#include "../ble_intercom_types.h"#include "ble_service_config_types.h"#include <furi.h>Go to the source code of this file.
Data Structures | |
| struct | BleServiceObjectResult |
| Represents service processing result. More... | |
Functions | |
| BleServiceObject * | ble_service_alloc (const BleServiceConfig *service_config, FuriMessageQueue *message_queue, IntercomChannel *intercom_ch) |
| Allocate service instance using predefined config. | |
| BleServiceObjectResult | ble_service_process (BleServiceObjectMessage *instance) |
| Process events related to service. | |
| void | ble_service_process_mailbox (BleServiceObject *instance, const BleIntercomFrameGeneric *input_frame) |
| Process intercom frames addressed to the service from other side. | |
| bool | ble_service_is_ready (BleServiceObject *instance) |
| Returns service status. | |
| const char * | ble_service_get_name (BleServiceObject *instance) |
| Returns service name. | |
| void | ble_service_get_error (BleServiceObject *instance, FuriString *error) |
| Returns error message. | |
| void | ble_service_enqueue_init (BleServiceObject *instance) |
| Enqueue initialize command during startup in order to init service. | |
| void | ble_service_enqueue_run (BleServiceObject *instance) |
| Enqueue run command in order to call service specific logic. | |
| void | ble_service_deinit (BleServiceObject *instance) |
| Enqueue deinit command. | |
| void | ble_service_write_data (BleServiceObject *instance, uint8_t index, const void *data, const size_t data_size) |
| Write data to service. | |
| void | ble_service_register_update_callback (BleServiceObject *instance, uint16_t index, BleDataUpdatedCallback cb, void *ctx) |
| Register update callback for selected characteristic inside of a service. | |
| void | ble_service_register_transmission_done_callback (BleServiceObject *instance, uint16_t index, BleDataTransmitDoneCallback cb, void *ctx) |
| Register transmission done callback for selected characteristic inside of a service. | |
Public api for ble services.
| BleServiceObject * ble_service_alloc | ( | const BleServiceConfig * | service_config, |
| FuriMessageQueue * | message_queue, | ||
| IntercomChannel * | intercom_ch ) |
Allocate service instance using predefined config.
| [in] | service_config | predefined config which describes service and its internals |
| [in] | message_queue | queue which all services use for processing events |
| [in] | intercom_ch | intercom channel for sending data to other side |
| void ble_service_deinit | ( | BleServiceObject * | instance | ) |
Enqueue deinit command.
This is used on unrecoverable error handling in order to shut down service with all internals.
| [in] | instance | pointer to the BleServiceObject instance |
| void ble_service_enqueue_init | ( | BleServiceObject * | instance | ) |
Enqueue initialize command during startup in order to init service.
Init command is emulated using pre-filled input frame buffer which after that will be processed ble_service_process and result in BleServiceCommandInit execution
| [in] | instance | pointer to the BleServiceObject instance |
| void ble_service_enqueue_run | ( | BleServiceObject * | instance | ) |
Enqueue run command in order to call service specific logic.
| [in] | instance | pointer to the BleServiceObject instance |
| void ble_service_get_error | ( | BleServiceObject * | instance, |
| FuriString * | error ) |
Returns error message.
Called when service processing ends up with an error, error message is then printed to logs
| [in] | instance | pointer to the BleServiceObject instance |
| [out] | error | pre-allocated error string buffer |
| const char * ble_service_get_name | ( | BleServiceObject * | instance | ) |
Returns service name.
| [in] | instance | pointer to the BleServiceObject instance |
| bool ble_service_is_ready | ( | BleServiceObject * | instance | ) |
Returns service status.
Used during init in order to check that all services initialized correctly and are ready to run
| [in] | instance | pointer to the BleServiceObject instance |
| BleServiceObjectResult ble_service_process | ( | BleServiceObjectMessage * | instance | ) |
Process events related to service.
This method is called from message queue handler and it can be called in three cases:
| [in] | instance | pointer to the BleServiceObjectMessage instance which is used internally |
| void ble_service_process_mailbox | ( | BleServiceObject * | instance, |
| const BleIntercomFrameGeneric * | input_frame ) |
Process intercom frames addressed to the service from other side.
This method if called from intercom_rx callback which must be as fast as possible, therefore it only copies frame payload to internal service frame buffer, enqueues further service processing and returns
| [in] | instance | pointer to the BleServiceObject instance |
| [in] | input_frame | pointer to frame received from other side |
| void ble_service_register_transmission_done_callback | ( | BleServiceObject * | instance, |
| uint16_t | index, | ||
| BleDataTransmitDoneCallback | cb, | ||
| void * | ctx ) |
Register transmission done callback for selected characteristic inside of a service.
| [in] | instance | pointer to the BleServiceObject instance |
| [in] | index | characteristic index where data should be placed |
| [in] | cb | pointer to transmission done callback function |
| [in] | ctx | transmission done callback context |
| void ble_service_register_update_callback | ( | BleServiceObject * | instance, |
| uint16_t | index, | ||
| BleDataUpdatedCallback | cb, | ||
| void * | ctx ) |
Register update callback for selected characteristic inside of a service.
| [in] | instance | pointer to the BleServiceObject instance |
| [in] | index | characteristic index where data should be placed |
| [in] | cb | pointer to update callback function |
| [in] | ctx | update callback context |
| void ble_service_write_data | ( | BleServiceObject * | instance, |
| uint8_t | index, | ||
| const void * | data, | ||
| const size_t | data_size ) |
Write data to service.
Calling this method stores data inside of selected characteristic and enqueues service processing, which then will send data the other side
| [in] | instance | pointer to the BleServiceObject instance |
| [in] | index | characteristic index where data should be placed |
| [in] | data | payload |
| [in] | data_size | payload size |