Flipper Zero Firmware
Loading...
Searching...
No Matches
furi_hal_bt.h File Reference

BT/BLE HAL API. More...

#include <furi.h>
#include <stdbool.h>
#include <gap.h>
#include <extra_beacon.h>
#include <furi_ble/profile_interface.h>
#include <ble_glue.h>
#include <ble_app.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define FURI_HAL_BT_STACK_VERSION_MAJOR   (1)
 
#define FURI_HAL_BT_STACK_VERSION_MINOR   (12)
 
#define FURI_HAL_BT_C2_START_TIMEOUT   (1000)
 

Enumerations

enum  FuriHalBtStack { FuriHalBtStackUnknown , FuriHalBtStackLight , FuriHalBtStackFull }
 

Functions

void furi_hal_bt_init (void)
 Initialize.
 
void furi_hal_bt_lock_core2 (void)
 Lock core2 state transition.
 
void furi_hal_bt_unlock_core2 (void)
 Lock core2 state transition.
 
bool furi_hal_bt_start_radio_stack (void)
 Start radio stack.
 
FuriHalBtStack furi_hal_bt_get_radio_stack (void)
 Get radio stack type.
 
bool furi_hal_bt_is_gatt_gap_supported (void)
 Check if radio stack supports BLE GAT/GAP.
 
bool furi_hal_bt_is_testing_supported (void)
 Check if radio stack supports testing.
 
bool furi_hal_bt_check_profile_type (FuriHalBleProfileBase *profile, const FuriHalBleProfileTemplate *profile_template)
 Check if particular instance of profile belongs to given type.
 
FURI_WARN_UNUSED FuriHalBleProfileBasefuri_hal_bt_start_app (const FuriHalBleProfileTemplate *profile_template, FuriHalBleProfileParams params, GapEventCallback event_cb, void *context)
 Start BLE app.
 
void furi_hal_bt_reinit (void)
 Reinitialize core2.
 
FURI_WARN_UNUSED FuriHalBleProfileBasefuri_hal_bt_change_app (const FuriHalBleProfileTemplate *profile_template, FuriHalBleProfileParams profile_params, GapEventCallback event_cb, void *context)
 Change BLE app Restarts 2nd core.
 
void furi_hal_bt_update_battery_level (uint8_t battery_level)
 Update battery level.
 
void furi_hal_bt_update_power_state (bool charging)
 Update battery power state.
 
bool furi_hal_bt_is_active (void)
 Checks if BLE state is active.
 
void furi_hal_bt_start_advertising (void)
 Start advertising.
 
void furi_hal_bt_stop_advertising (void)
 Stop advertising.
 
void furi_hal_bt_dump_state (FuriString *buffer)
 Get BT/BLE system component state.
 
bool furi_hal_bt_is_alive (void)
 Get BT/BLE system component state.
 
void furi_hal_bt_get_key_storage_buff (uint8_t **key_buff_addr, uint16_t *key_buff_size)
 Get key storage buffer address and size.
 
void furi_hal_bt_nvm_sram_sem_acquire (void)
 Get SRAM2 hardware semaphore.
 
void furi_hal_bt_nvm_sram_sem_release (void)
 Release SRAM2 hardware semaphore.
 
bool furi_hal_bt_clear_white_list (void)
 Clear key storage.
 
void furi_hal_bt_set_key_storage_change_callback (BleGlueKeyStorageChangedCallback callback, void *context)
 Set key storage change callback.
 
void furi_hal_bt_start_tone_tx (uint8_t channel, uint8_t power)
 Start ble tone tx at given channel and power.
 
void furi_hal_bt_stop_tone_tx (void)
 Stop ble tone tx.
 
void furi_hal_bt_start_packet_tx (uint8_t channel, uint8_t pattern, uint8_t datarate)
 Start sending ble packets at a given frequency and datarate.
 
uint16_t furi_hal_bt_stop_packet_test (void)
 Stop sending ble packets.
 
void furi_hal_bt_start_packet_rx (uint8_t channel, uint8_t datarate)
 Start receiving packets.
 
void furi_hal_bt_start_rx (uint8_t channel)
 Set up the RF to listen to a given RF channel.
 
void furi_hal_bt_stop_rx (void)
 Stop RF listenning.
 
float furi_hal_bt_get_rssi (void)
 Get RSSI.
 
uint32_t furi_hal_bt_get_transmitted_packets (void)
 Get number of transmitted packets.
 
bool furi_hal_bt_ensure_c2_mode (BleGlueC2Mode mode)
 Check & switch C2 to given mode.
 
bool furi_hal_bt_extra_beacon_set_data (const uint8_t *data, uint8_t len)
 Extra BLE beacon API.
 
uint8_t furi_hal_bt_extra_beacon_get_data (uint8_t *data)
 Get last configured extra beacon data.
 
bool furi_hal_bt_extra_beacon_set_config (const GapExtraBeaconConfig *config)
 Configure extra beacon.
 
bool furi_hal_bt_extra_beacon_start (void)
 Start extra beacon.
 
bool furi_hal_bt_extra_beacon_stop (void)
 Stop extra beacon.
 
bool furi_hal_bt_extra_beacon_is_active (void)
 Check if extra beacon is active.
 
const GapExtraBeaconConfigfuri_hal_bt_extra_beacon_get_config (void)
 Get last configured extra beacon config.
 

Detailed Description

BT/BLE HAL API.

Function Documentation

◆ furi_hal_bt_change_app()

FURI_WARN_UNUSED FuriHalBleProfileBase * furi_hal_bt_change_app ( const FuriHalBleProfileTemplate * profile_template,
FuriHalBleProfileParams profile_params,
GapEventCallback event_cb,
void * context )

Change BLE app Restarts 2nd core.

Parameters
profile_templateFuriHalBleProfileTemplate instance
profile_paramsParameters to pass to the profile. Can be NULL
event_cbGapEventCallback instance
contextpointer to context
Returns
instance of profile, NULL on failure

◆ furi_hal_bt_check_profile_type()

bool furi_hal_bt_check_profile_type ( FuriHalBleProfileBase * profile,
const FuriHalBleProfileTemplate * profile_template )

Check if particular instance of profile belongs to given type.

Parameters
profileFuriHalBtProfile instance. If NULL, uses current profile
profile_templatebasic profile template to check against
Returns
true on success

◆ furi_hal_bt_clear_white_list()

bool furi_hal_bt_clear_white_list ( void )

Clear key storage.

Returns
true on success

◆ furi_hal_bt_dump_state()

void furi_hal_bt_dump_state ( FuriString * buffer)

Get BT/BLE system component state.

Parameters
[in]bufferFuriString* buffer to write to

◆ furi_hal_bt_ensure_c2_mode()

bool furi_hal_bt_ensure_c2_mode ( BleGlueC2Mode mode)

Check & switch C2 to given mode.

Parameters
[in]modemode to switch into

◆ furi_hal_bt_extra_beacon_get_config()

const GapExtraBeaconConfig * furi_hal_bt_extra_beacon_get_config ( void )

Get last configured extra beacon config.

Returns
extra beacon config. NULL if beacon had never been configured.

◆ furi_hal_bt_extra_beacon_get_data()

uint8_t furi_hal_bt_extra_beacon_get_data ( uint8_t * data)

Get last configured extra beacon data.

Parameters
datadata buffer to write to. Must be at least EXTRA_BEACON_MAX_DATA_SIZE bytes long
Returns
valid data length

◆ furi_hal_bt_extra_beacon_is_active()

bool furi_hal_bt_extra_beacon_is_active ( void )

Check if extra beacon is active.

Returns
extra beacon state

◆ furi_hal_bt_extra_beacon_set_config()

bool furi_hal_bt_extra_beacon_set_config ( const GapExtraBeaconConfig * config)

Configure extra beacon.

Parameters
[in]configextra beacon config: interval, power, address, etc.
Returns
true on success

◆ furi_hal_bt_extra_beacon_set_data()

bool furi_hal_bt_extra_beacon_set_data ( const uint8_t * data,
uint8_t len )

Extra BLE beacon API.

Set extra beacon data. Can be called in any state

Parameters
[in]datadata to set
[in]lendata length. Must be <= EXTRA_BEACON_MAX_DATA_SIZE
Returns
true on success

◆ furi_hal_bt_extra_beacon_start()

bool furi_hal_bt_extra_beacon_start ( void )

Start extra beacon.

Beacon must configured with furi_hal_bt_extra_beacon_set_config() and in stopped state before calling this function.

Returns
true on success

◆ furi_hal_bt_extra_beacon_stop()

bool furi_hal_bt_extra_beacon_stop ( void )

Stop extra beacon.

Returns
true on success

◆ furi_hal_bt_get_key_storage_buff()

void furi_hal_bt_get_key_storage_buff ( uint8_t ** key_buff_addr,
uint16_t * key_buff_size )

Get key storage buffer address and size.

Parameters
key_buff_addrpointer to store buffer address
key_buff_sizepointer to store buffer size

◆ furi_hal_bt_get_radio_stack()

FuriHalBtStack furi_hal_bt_get_radio_stack ( void )

Get radio stack type.

Returns
FuriHalBtStack instance

◆ furi_hal_bt_get_rssi()

float furi_hal_bt_get_rssi ( void )

Get RSSI.

Returns
RSSI in dBm

◆ furi_hal_bt_get_transmitted_packets()

uint32_t furi_hal_bt_get_transmitted_packets ( void )

Get number of transmitted packets.

Returns
packet count

◆ furi_hal_bt_is_active()

bool furi_hal_bt_is_active ( void )

Checks if BLE state is active.

Returns
true if device is connected or advertising, false otherwise

◆ furi_hal_bt_is_alive()

bool furi_hal_bt_is_alive ( void )

Get BT/BLE system component state.

Returns
true if core2 is alive

◆ furi_hal_bt_is_gatt_gap_supported()

bool furi_hal_bt_is_gatt_gap_supported ( void )

Check if radio stack supports BLE GAT/GAP.

Returns
true if supported

◆ furi_hal_bt_is_testing_supported()

bool furi_hal_bt_is_testing_supported ( void )

Check if radio stack supports testing.

Returns
true if supported

◆ furi_hal_bt_nvm_sram_sem_acquire()

void furi_hal_bt_nvm_sram_sem_acquire ( void )

Get SRAM2 hardware semaphore.

Note
Must be called before SRAM2 read/write operations

◆ furi_hal_bt_nvm_sram_sem_release()

void furi_hal_bt_nvm_sram_sem_release ( void )

Release SRAM2 hardware semaphore.

Note
Must be called after SRAM2 read/write operations

◆ furi_hal_bt_reinit()

void furi_hal_bt_reinit ( void )

Reinitialize core2.

Also can be used to prepare core2 for stop modes

◆ furi_hal_bt_set_key_storage_change_callback()

void furi_hal_bt_set_key_storage_change_callback ( BleGlueKeyStorageChangedCallback callback,
void * context )

Set key storage change callback.

Parameters
callbackBleGlueKeyStorageChangedCallback instance
contextpointer to context

◆ furi_hal_bt_start_app()

FURI_WARN_UNUSED FuriHalBleProfileBase * furi_hal_bt_start_app ( const FuriHalBleProfileTemplate * profile_template,
FuriHalBleProfileParams params,
GapEventCallback event_cb,
void * context )

Start BLE app.

Parameters
profile_templateFuriHalBleProfileTemplate instance
paramsParameters to pass to the profile. Can be NULL
event_cbGapEventCallback instance
contextpointer to context
Returns
instance of profile, NULL on failure

◆ furi_hal_bt_start_packet_rx()

void furi_hal_bt_start_packet_rx ( uint8_t channel,
uint8_t datarate )

Start receiving packets.

Parameters
[in]channelRX channel
[in]datarateDatarate

◆ furi_hal_bt_start_packet_tx()

void furi_hal_bt_start_packet_tx ( uint8_t channel,
uint8_t pattern,
uint8_t datarate )

Start sending ble packets at a given frequency and datarate.

Parameters
[in]channelThe channel
[in]patternThe pattern
[in]datarateThe datarate

◆ furi_hal_bt_start_radio_stack()

bool furi_hal_bt_start_radio_stack ( void )

Start radio stack.

Returns
true on successfull radio stack start

◆ furi_hal_bt_start_rx()

void furi_hal_bt_start_rx ( uint8_t channel)

Set up the RF to listen to a given RF channel.

Parameters
[in]channelRX channel

◆ furi_hal_bt_start_tone_tx()

void furi_hal_bt_start_tone_tx ( uint8_t channel,
uint8_t power )

Start ble tone tx at given channel and power.

Parameters
[in]channelThe channel
[in]powerThe power

◆ furi_hal_bt_stop_packet_test()

uint16_t furi_hal_bt_stop_packet_test ( void )

Stop sending ble packets.

Returns
sent packet count

◆ furi_hal_bt_update_battery_level()

void furi_hal_bt_update_battery_level ( uint8_t battery_level)

Update battery level.

Parameters
battery_levelbattery level