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

Common logic for remote and bsb devices. More...

#include <furi.h>

Go to the source code of this file.

Macros

#define BLE_DEVICE_ADDRESS_LEN   (6)
 Device address length.
 

Typedefs

typedef struct BleDeviceBase BleDeviceBase
 Opaque BleDeviceBase type declaration.
 

Enumerations

enum  BleDeviceRole { BleDeviceRoleUnknown , BleDeviceRoleRemote , BleDeviceRoleCentral , BleDeviceRoleCount }
 Enumeration of device roles. More...
 
enum  BleDeviceAddressType { BleDeviceAddressTypeUnknown , BleDeviceAddressTypeOrigin , BleDeviceAddressTypeResolvable , BleDeviceAddressTypeCount }
 Enumeration of device address types. More...
 
enum  BleDeviceFeatures {
  BleDeviceFeaturesLEEncryption = 0 , BleDeviceFeaturesConnectionParametersRequestProcedure = 1 , BleDeviceFeaturesExtendedRejectIndication = 2 , BleDeviceFeaturesPeripheralInitiatedFeaturesExchange = 3 ,
  BleDeviceFeaturesLEPing = 4 , BleDeviceFeaturesLEDataPacketLengthExtension = 5 , BleDeviceFeaturesLLPrivacy = 6 , BleDeviceFeaturesExtendedScanningFilterPolicies = 7 ,
  BleDeviceFeaturesLE2MPhy = 8 , BleDeviceFeaturesStableModulationIndexTransmitter = 9 , BleDeviceFeaturesStableModulationIndexReceiver = 10 , BleDeviceFeaturesLECodedPhy = 11 ,
  BleDeviceFeaturesLEExtendedAdvertising = 12 , BleDeviceFeaturesLEPeriodicAdvertising = 13 , BleDeviceFeaturesChannelSelectionAlgorithm2 = 14 , BleDeviceFeaturesLEPowerClass1 = 15
}
 Features bits enumeration from ble spec. More...
 

Functions

BleDeviceBase * ble_device_base_alloc (BleDeviceRole role)
 Create base device instance with desired role.
 
void ble_device_base_free (BleDeviceBase *instance)
 Free base device instance.
 
const uint8_t * ble_device_base_get_address (BleDeviceBase *instance, BleDeviceAddressType type)
 Get address of desired type from device.
 
void ble_device_base_set_address (BleDeviceBase *instance, BleDeviceAddressType type, const uint8_t *const addr)
 Set address and type.
 
void ble_device_base_format_address (BleDeviceBase *instance, BleDeviceAddressType type, FuriString *output)
 Converts address to string.
 
void ble_device_base_set_features (BleDeviceBase *instance, const uint8_t *features)
 Store device features received from nwp internally.
 
bool ble_device_base_is_feature_supported (BleDeviceBase *instance, BleDeviceFeatures feature)
 Checks if mentioned feature is supported by device or not.
 

Detailed Description

Common logic for remote and bsb devices.

Enumeration Type Documentation

◆ BleDeviceAddressType

Enumeration of device address types.

Currently only origin is used because this enum added for future logic implementation

Enumerator
BleDeviceAddressTypeUnknown 

Stub to avoid zero value.

BleDeviceAddressTypeOrigin 

Public address provided to the device during manufacturing.

BleDeviceAddressTypeResolvable 

Random address generated using rpa.

BleDeviceAddressTypeCount 

Address count.

◆ BleDeviceFeatures

Features bits enumeration from ble spec.

In spec there is much more feature bits, but they are not used in case of this device, so this enum is limited

◆ BleDeviceRole

Enumeration of device roles.

This roles match with devices roles in ble spec Currently BSB is a remote and phone is a central

Enumerator
BleDeviceRoleUnknown 

Stub to avoid zero value.

BleDeviceRoleRemote 

Remote device, can only advertise itself but cannot establish any connections.

BleDeviceRoleCentral 

Central device, controls connection establishing and all parameters.

BleDeviceRoleCount 

Roles count.

Function Documentation

◆ ble_device_base_alloc()

BleDeviceBase * ble_device_base_alloc ( BleDeviceRole role)

Create base device instance with desired role.

Parameters
[in]roleof a new device
Returns
pointer to device instance

◆ ble_device_base_format_address()

void ble_device_base_format_address ( BleDeviceBase * instance,
BleDeviceAddressType type,
FuriString * output )

Converts address to string.

Parameters
[in]instanceof base device
[in]typeaddress type
[out]outputpointer to string where result will be placed

◆ ble_device_base_free()

void ble_device_base_free ( BleDeviceBase * instance)

Free base device instance.

Parameters
[in]instanceof base device

◆ ble_device_base_get_address()

const uint8_t * ble_device_base_get_address ( BleDeviceBase * instance,
BleDeviceAddressType type )

Get address of desired type from device.

If device does not have address it will return array of zeros

Parameters
[in]instanceof base device
[in]typedesired address type
Returns
pointer to an array with address

◆ ble_device_base_is_feature_supported()

bool ble_device_base_is_feature_supported ( BleDeviceBase * instance,
BleDeviceFeatures feature )

Checks if mentioned feature is supported by device or not.

Parameters
[in]instanceof base device
[in]featureto be tested
Returns
true if mentioned feature is supported, otherwise false

◆ ble_device_base_set_address()

void ble_device_base_set_address ( BleDeviceBase * instance,
BleDeviceAddressType type,
const uint8_t *const addr )

Set address and type.

Parameters
[in]instanceof base device
[in]typeaddress type
[in]addrarray with address bytes must be of BLE_DEVICE_ADDRESS_LEN

◆ ble_device_base_set_features()

void ble_device_base_set_features ( BleDeviceBase * instance,
const uint8_t * features )

Store device features received from nwp internally.

Parameters
[in]instanceof base device
[in]featuresarray received from nwp during connection establishing