1#ifndef BLUETOE_LINK_LAYER_SCHEDULED_RADIO_HPP
2#define BLUETOE_LINK_LAYER_SCHEDULED_RADIO_HPP
7#include <ll_data_pdu_buffer.hpp>
26 template < std::
size_t TransmitSize, std::
size_t ReceiveSize,
typename CallBack >
258 void radio_set_phy( details::phy_ll_encoding receiving_encoding, details::phy_ll_encoding transmiting_c_encoding );
290 template < std::
size_t TransmitSize, std::
size_t ReceiveSize,
typename CallBack >
330 bluetoe::details::uint128_t
c1(
331 const bluetoe::details::uint128_t& temp_key,
332 const bluetoe::details::uint128_t& rand,
333 const bluetoe::details::uint128_t& p1,
334 const bluetoe::details::uint128_t& p2 )
const;
346 bluetoe::details::uint128_t
s1(
347 const bluetoe::details::uint128_t& temp_key,
348 const bluetoe::details::uint128_t& prand,
349 const bluetoe::details::uint128_t& crand );
362 std::pair< std::uint64_t, std::uint32_t >
setup_encryption( bluetoe::details::uint128_t key, std::uint64_t skdm, std::uint32_t ivm );
372 std::pair< bluetoe::details::ecdh_public_key_t, bluetoe::details::ecdh_private_key_t >
generate_keys();
382 bluetoe::details::ecdh_shared_secret_t
p256(
const std::uint8_t* private_key,
const std::uint8_t* public_key );
387 bluetoe::details::uint128_t
f4(
const std::uint8_t* u,
const std::uint8_t* v,
const std::array< std::uint8_t, 16 >& k, std::uint8_t z );
392 std::pair< bluetoe::details::uint128_t, bluetoe::details::uint128_t >
f5(
393 const bluetoe::details::ecdh_shared_secret_t dh_key,
394 const bluetoe::details::uint128_t& nonce_central,
395 const bluetoe::details::uint128_t& nonce_periperal,
402 bluetoe::details::uint128_t
f6(
403 const bluetoe::details::uint128_t& key,
404 const bluetoe::details::uint128_t& n1,
405 const bluetoe::details::uint128_t& n2,
406 const bluetoe::details::uint128_t& r,
407 const bluetoe::details::io_capabilities_t& io_caps,
415 const std::uint8_t* u,
416 const std::uint8_t* v,
417 const bluetoe::details::uint128_t& x,
418 const bluetoe::details::uint128_t& y );
477 static std::uint16_t
header(
const std::uint8_t* pdu );
487 static void header( std::uint8_t* pdu, std::uint16_t header_value );
497 static std::pair< const std::uint8_t*, const std::uint8_t* >
body(
const write_buffer& pdu );
positiv time quantum used to express distance in time.
Definition: delta_time.hpp:14
data type containing a device address and the address type (public or random).
Definition: address.hpp:107
ring buffers for ingoing and outgoing LL Data PDUs
Definition: ll_data_pdu_buffer.hpp:38
extension of a scheduled_radio with functions to support encryption
Definition: scheduled_radio.hpp:292
bluetoe::details::uint128_t create_srand()
Function to create the Srand according to 2.3.5.5 Part H, Vol 3, Core Spec.
void stop_receive_encrypted()
stop receiving encrypted with the next connection event.
bluetoe::details::ecdh_shared_secret_t p256(const std::uint8_t *private_key, const std::uint8_t *public_key)
p256() security toolbox function, as specified in the core spec
static constexpr bool hardware_supports_legacy_pairing
indicates the support for legacy pairing
Definition: scheduled_radio.hpp:302
std::uint32_t g2(const std::uint8_t *u, const std::uint8_t *v, const bluetoe::details::uint128_t &x, const bluetoe::details::uint128_t &y)
g2() security toolbox function, as specified in the core spec
std::pair< std::uint64_t, std::uint32_t > setup_encryption(bluetoe::details::uint128_t key, std::uint64_t skdm, std::uint32_t ivm)
setup the hardware with all data required for encryption
void start_transmit_encrypted()
start to encrypt transmitted PDUs with the next connection event.
bluetoe::details::uint128_t create_passkey()
bluetoe::details::longterm_key_t create_long_term_key()
Function to create a random long term key and random Rand and EDIV values to identify this newly crea...
bluetoe::details::uint128_t s1(const bluetoe::details::uint128_t &temp_key, const bluetoe::details::uint128_t &prand, const bluetoe::details::uint128_t &crand)
Key generation function s1 for LE Legacy Pairing.
void start_receive_encrypted()
start the encryption of received PDUs with the next connection event.
bluetoe::details::uint128_t c1(const bluetoe::details::uint128_t &temp_key, const bluetoe::details::uint128_t &rand, const bluetoe::details::uint128_t &p1, const bluetoe::details::uint128_t &p2) const
Confirm value generation function c1 for LE Legacy Pairing.
static constexpr bool hardware_supports_lesc_pairing
indicates the support for LESC pairing
Definition: scheduled_radio.hpp:297
bluetoe::details::uint128_t f4(const std::uint8_t *u, const std::uint8_t *v, const std::array< std::uint8_t, 16 > &k, std::uint8_t z)
f4() security toolbox function, as specified in the core spec
bluetoe::details::uint128_t f6(const bluetoe::details::uint128_t &key, const bluetoe::details::uint128_t &n1, const bluetoe::details::uint128_t &n2, const bluetoe::details::uint128_t &r, const bluetoe::details::io_capabilities_t &io_caps, const bluetoe::link_layer::device_address &addr_controller, const bluetoe::link_layer::device_address &addr_peripheral)
f6() security toolbox function, as specified in the core spec
bluetoe::details::uint128_t select_random_nonce()
random nonce required for LESC pairing
std::pair< bluetoe::details::uint128_t, bluetoe::details::uint128_t > f5(const bluetoe::details::ecdh_shared_secret_t dh_key, const bluetoe::details::uint128_t &nonce_central, const bluetoe::details::uint128_t &nonce_periperal, const bluetoe::link_layer::device_address &addr_controller, const bluetoe::link_layer::device_address &addr_peripheral)
f5() security toolbox function, as specified in the core spec
void stop_transmit_encrypted()
stop transmitting encrypted with the next connection event.
std::pair< bluetoe::details::ecdh_public_key_t, bluetoe::details::ecdh_private_key_t > generate_keys()
generate public private key pair for DH
static constexpr bool hardware_supports_encryption
indication no support for encryption
Definition: scheduled_radio.hpp:307
bool is_valid_public_key(const std::uint8_t *public_key) const
Type responsible for radio I/O and timing.
Definition: scheduled_radio.hpp:28
void radio_set_phy(details::phy_ll_encoding receiving_encoding, details::phy_ll_encoding transmiting_c_encoding)
change the used PHY encoding for the transmitting and receiving side
void set_access_address_and_crc_init(std::uint32_t access_address, std::uint32_t crc_init)
set the access address initial CRC value for transmitted and received PDU
static constexpr std::size_t radio_package_overhead
a number of bytes that are additional required by the hardware to handle an over the air package/PDU.
Definition: scheduled_radio.hpp:266
bool cancel_synchronized_user_timer()
cancel the user timer
void run()
allocates the CPU to the scheduled_radio
std::size_t radio_white_list_free_size() const
returns the number of addresses that could be added to the white list before add_to_white_list() woul...
bool radio_add_to_white_list(const device_address &addr)
add the given address to the white list.
bool connection_request_filter() const
current value of the property.
static constexpr bool hardware_supports_encryption
indication no support for encryption
Definition: scheduled_radio.hpp:271
void request_event_cancelation()
forces the call of CallBack::try_event_cancelation() from the context of the run() function
static constexpr bool hardware_supports_synchronized_user_timer
indicates support for schedule_synchronized_user_timer()
Definition: scheduled_radio.hpp:281
static constexpr std::size_t radio_maximum_white_list_entries
giving the maximum number of white list entries, the scheduled radio supports by hardware
Definition: scheduled_radio.hpp:173
bool radio_is_connection_request_in_filter(const device_address &addr) const
returns true, if a connection request from the given address should be answered.
bool schedule_synchronized_user_timer(bluetoe::link_layer::delta_time timeout, bluetoe::link_layer::delta_time max_cb_runtime)
sets up a timer
static constexpr bool hardware_supports_2mbit
indicates support for 2Mbit
Definition: scheduled_radio.hpp:276
void wake_up()
forces the run() function to return at least once
void radio_clear_white_list()
remove all entries from the white list
void radio_scan_request_filter(bool b)
Accept scan requests only from devices within the white list.
std::uint32_t static_random_address_seed() const
function to return a device specific value that is persistent and unique for the device (CPU id or su...
std::pair< bool, bluetoe::link_layer::delta_time > disarm_connection_event()
tries to stop a scheduled connection event
bool radio_is_in_white_list(const device_address &addr) const
returns true, if the given address in within the white list
bool radio_remove_from_white_list(const device_address &addr)
remove the given address from the white list
bool radio_is_scan_request_in_filter(const device_address &addr) const
returns true, if a scan request from the given address should be answered.
void connection_request_filter(bool b)
Accept connection requests only from devices within the white list.
bluetoe::link_layer::delta_time schedule_connection_event(unsigned channel, bluetoe::link_layer::delta_time start_receive, bluetoe::link_layer::delta_time end_receive, bluetoe::link_layer::delta_time connection_interval)
schedules a connection event
void schedule_advertisment(unsigned channel, const bluetoe::link_layer::write_buffer &advertising_data, const bluetoe::link_layer::write_buffer &response_data, bluetoe::link_layer::delta_time when, const bluetoe::link_layer::read_buffer &receive)
schedules for transmission of advertising data and starts to receive 150µs later
bool radio_scan_request_filter() const
current value of the property.
type that provides types and functions to access the differnt parts of a receiving PDU.
Definition: scheduled_radio.hpp:463
static std::pair< const std::uint8_t *, const std::uint8_t * > body(const write_buffer &pdu)
returns the readonly body for advertising channel or for data channel PDUs.
static std::uint16_t header(const std::uint8_t *pdu)
returns the header for advertising channel and for data channel PDUs.
static void header(std::uint8_t *pdu, std::uint16_t header_value)
writes to the header of the given PDU
static constexpr std::size_t data_channel_pdu_memory_size(std::size_t payload_size)
returns the size of the memory buffer that is required to keep a data channel PDU in memory,...
static std::pair< std::uint8_t *, std::uint8_t * > body(const read_buffer &pdu)
returns the writable body for advertising channel or for data channel PDUs.
static std::uint16_t header(const read_buffer &pdu)
returns the header for advertising channel and for data channel PDUs.
static void header(const read_buffer &pdu, std::uint16_t header_value)
writes to the header of the given PDU
static std::uint16_t header(const write_buffer &pdu)
returns the header for advertising channel and for data channel PDUs.
type suitable to store the location and size of a chunk of memory that can be used to receive from th...
Definition: buffer.hpp:18
type suitable to store the location and size of a chunk of memory that can be used to transmit to the...
Definition: buffer.hpp:85