Mbed OS Reference
Loading...
Searching...
No Matches
CordioHCIDriver Class Referenceabstract

Base class of the HCI driver use by the BLE port of the Cordio stack. More...

#include <CordioHCIDriver.h>

Inheritance diagram for CordioHCIDriver:
AP3CordioHCIDriver NRFCordioHCIDriver

Public Types

typedef mbed::Callback< void(bool, uint16_t)> test_end_handler_t
 Callback to inform the caller of the result of the test, the parameters are success and the number of packets received. More...
 

Public Member Functions

 CordioHCIDriver (CordioHCITransportDriver &transport_driver)
 Construct a new instance of an HCI driver. More...
 
virtual ~CordioHCIDriver ()=default
 Driver destructor. More...
 
virtual buf_pool_desc_t get_buffer_pool_description ()=0
 Return the set of memory pool which will be used by the Cordio stack. More...
 
void initialize ()
 Initialize the HCI driver. More...
 
void terminate ()
 Termination of the driver. More...
 
virtual void start_reset_sequence ()
 Start the reset sequence of the BLE module. More...
 
virtual void handle_reset_sequence (uint8_t *msg)
 Handle HCI messages received during the reset sequence. More...
 
virtual bool get_random_static_address (ble::address_t &address)
 Get the random static address of the controller. More...
 
void signal_reset_sequence_done ()
 Signal to the stack that the reset sequence has been done. More...
 
uint16_t write (uint8_t type, uint16_t len, uint8_t *pData)
 Write data in the transport channel. More...
 
virtual void on_host_stack_inactivity ()
 React to host stack inactivity. More...
 
void handle_test_end (bool success, uint16_t packets)
 This will be called by host part of the stack to indicate the end of the test. More...
 
ble_error_t rf_test_start_le_receiver_test (test_end_handler_t test_end_handler, uint8_t channel)
 Start BLE receiver test. More...
 
ble_error_t rf_test_start_le_transmitter_test (test_end_handler_t test_end_handler, uint8_t channel, uint8_t length, uint8_t type)
 Start BLE transmitter test. More...
 
ble_error_t rf_test_end ()
 Complete the test. More...
 
virtual ble_error_t set_tx_power (int8_t level_db)
 Set desired transmit power. More...
 

Protected Member Functions

buf_pool_desc_t get_default_buffer_pool_description ()
 Return a default set of memory pool that the Cordio stack can use. More...
 
void set_random_static_address (const ble::address_t &random_static_address)
 Allows the driver to set a random static address. More...
 

Detailed Description

Base class of the HCI driver use by the BLE port of the Cordio stack.

This class provide to the stack:

  • The buffer necessary to run BLE API
  • The reset sequence of the BLE module
  • Access to the write function of the underlying HCITransport driver.

Definition at line 64 of file CordioHCIDriver.h.

Member Typedef Documentation

◆ test_end_handler_t

typedef mbed::Callback<void(bool, uint16_t)> test_end_handler_t

Callback to inform the caller of the result of the test, the parameters are success and the number of packets received.

Definition at line 165 of file CordioHCIDriver.h.

Constructor & Destructor Documentation

◆ CordioHCIDriver()

CordioHCIDriver ( CordioHCITransportDriver transport_driver)

Construct a new instance of an HCI driver.

Parameters
transport_driverThe driver used to communicate with the chip.

◆ ~CordioHCIDriver()

virtual ~CordioHCIDriver ( )
virtualdefault

Driver destructor.

Member Function Documentation

◆ get_buffer_pool_description()

virtual buf_pool_desc_t get_buffer_pool_description ( )
pure virtual

Return the set of memory pool which will be used by the Cordio stack.

Implemented in AP3CordioHCIDriver, and NRFCordioHCIDriver.

◆ initialize()

void initialize ( )

Initialize the HCI driver.

This function start by initializing the transport driver then it delegates what's remain of the initialization to the function do_initialize.

◆ terminate()

void terminate ( )

Termination of the driver.

It call in sequence:

  • do_terminate
  • terminate the transport driver.

◆ start_reset_sequence()

virtual void start_reset_sequence ( )
virtual

Start the reset sequence of the BLE module.

Reimplemented in NRFCordioHCIDriver.

◆ handle_reset_sequence()

virtual void handle_reset_sequence ( uint8_t *  msg)
virtual

Handle HCI messages received during the reset sequence.

Parameters
msgThe HCI message received.
Note
The driver should signal to the stack that the initialization sequence is done by calling the function: signal_reset_sequence_done.

◆ get_random_static_address()

virtual bool get_random_static_address ( ble::address_t address)
virtual

Get the random static address of the controller.

Parameters
[out]addressMAC address is written here.
Returns
false if the address has not been set and true otherwise.

Reimplemented in NRFCordioHCIDriver.

◆ signal_reset_sequence_done()

void signal_reset_sequence_done ( )

Signal to the stack that the reset sequence has been done.

◆ write()

uint16_t write ( uint8_t  type,
uint16_t  len,
uint8_t *  pData 
)

Write data in the transport channel.

Parameters
typeThe type of packet to transmit. It might be an HCI command packet, ACL packet or EVT packet. Depending on the type of transport it can prefix the packet itself.
lenNumber of bytes to transmit.
pDatapointer to the data to transmit.
Returns
The number of bytes which have been transmited.

◆ on_host_stack_inactivity()

virtual void on_host_stack_inactivity ( )
virtual

React to host stack inactivity.

The host stack invoke this function when it is inactive. It allows a driver to put its controller to sleep if all the conditions are met.

Any call to write signals to the driver that the host stack is active.

◆ handle_test_end()

void handle_test_end ( bool  success,
uint16_t  packets 
)

This will be called by host part of the stack to indicate the end of the test.

Parameters
successTrue if the TEST END command was a success.
packetsNumber of packets received during the test.

◆ rf_test_start_le_receiver_test()

ble_error_t rf_test_start_le_receiver_test ( test_end_handler_t  test_end_handler,
uint8_t  channel 
)

Start BLE receiver test.

Call rf_test_end when you want to stop.

Parameters
test_end_handlerHandler that will be called with the number of packets received.
channelChannel to use.
Returns
BLE_ERROR_NONE on success.

◆ rf_test_start_le_transmitter_test()

ble_error_t rf_test_start_le_transmitter_test ( test_end_handler_t  test_end_handler,
uint8_t  channel,
uint8_t  length,
uint8_t  type 
)

Start BLE transmitter test.

Call rf_test_end when you want to stop.

Parameters
test_end_handlerHandler that will be called with status and the number of packets set to 0.
channelChannel to use.
lengthSize of payload.
typeType of pattern to transmit
See also
BLE spec Volume 6 Part F, Section 4.1.5.
Returns
BLE_ERROR_NONE on success.

◆ rf_test_end()

ble_error_t rf_test_end ( )

Complete the test.

This will trigger the end test event which will call handle_test_end

Returns
BLE_ERROR_NONE on success.

◆ set_tx_power()

virtual ble_error_t set_tx_power ( int8_t  level_db)
virtual

Set desired transmit power.

Value equal or bigger will be used from available levels. Consult chip documentation for available values. Actual TX power is not guaranteed and is down to the implementation.

Parameters
level_dbSignal level in dBm.
Returns
BLE_ERROR_NONE on success.

◆ get_default_buffer_pool_description()

buf_pool_desc_t get_default_buffer_pool_description ( )
protected

Return a default set of memory pool that the Cordio stack can use.

This function can be used to implement get_buffer_pool_description().

◆ set_random_static_address()

void set_random_static_address ( const ble::address_t random_static_address)
protected

Allows the driver to set a random static address.

Unlike the HCI command this function reports the random static address to the whole BLE system.

Parameters
random_static_addressThe random static address to set.