ble6 2.0.0.0
Main Page

BLE 6 click

‍BLE 6 Click is a Bluetooth low energy system-on-chip application processor certified module, compliant with BT specifications v5.0 and BQE qualified. The featured BlueNRG-M2 module developed by STMicroelectronics supports multiple roles simultaneously and can act at the same time as Bluetooth master and slave device.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Sep 2021.
  • Type : UART type

Software Support

We provide a library for the BLE6 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

‍This library contains API for BLE6 Click driver.

Standard key functions :

  • ble6_cfg_setup Config Object Initialization function.
    void ble6_cfg_setup ( ble6_cfg_t *cfg );
    void ble6_cfg_setup(ble6_cfg_t *cfg)
    BLE 6 configuration object setup function.
    BLE 6 Click configuration object.
    Definition ble6.h:136
  • ble6_init Initialization function.
    err_t ble6_init ( ble6_t *ctx, ble6_cfg_t *cfg );
    err_t ble6_init(ble6_t *ctx, ble6_cfg_t *cfg)
    BLE 6 initialization function.
    BLE 6 Click context object.
    Definition ble6.h:114

Example key functions :

Example Description

‍This example reads and processes data from BLE 6 clicks.

The demo application is composed of two sections :

Application Init

‍Initialization driver enables - UART, sets handlers initialize and enable UART interrupt, reset and configures BLE module, initialize BLE Server Profile ( Services and Characteristics ).

void application_init ( void )
{
log_cfg_t log_cfg;
ble6_cfg_t ble6_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
ble6_cfg_setup( &ble6_cfg );
BLE6_MAP_MIKROBUS( ble6_cfg, MIKROBUS_1 );
err_t init_flag = ble6_init( &ble6, &ble6_cfg );
if ( UART_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 100 );
log_printf( &logger, "-> Local Version Information: \r\n" );
Delay_ms ( 100 );
Delay_ms ( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> ACI GAP Update Value: \r\n" );
Delay_ms ( 10 );
Delay_ms ( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> HCI Set Scan. Response Data: \r\n" );
Delay_ms ( 10 );
Delay_ms ( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> ACI GAP Set Discoverable: \r\n" );
Delay_ms ( 10 );
Delay_ms ( 100 );
log_info( &logger, " Application Task " );
}
#define BLE6_MODULE_POWER_ON
Definition ble6.h:74
#define BLE6_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition ble6.h:99
void ble6_power_on(ble6_t *ctx, uint8_t en_pwr)
Set Power On function.
void ble6_send_command(ble6_t *ctx, uint8_t *tx_data, uint8_t n_bytes)
Send command function.
void application_init(void)
Definition main.c:135
void ble6_module_init(void)
BLE 6 module initialisation.
Definition main.c:545
void ble6_handler(void)
BLE 6 handler.
Definition main.c:236
void ble6_display_log(void)
BLE 6 display log.
Definition main.c:506
uint8_t aci_gatt_update_value[21]
Definition main.c:70
uint8_t hci_read_local_version_information[4]
Definition main.c:59
uint8_t aci_gap_set_discoverable[30]
Definition main.c:81
void ble6_local_version_info(void)
BLE 6 local version info.
Definition main.c:377
uint8_t hci_le_set_scan_response_data[36]
Definition main.c:75

Application Task

‍The app starts by checking the system ready flag and returns the Bluetooth device address. After that, the chain of commands creates Primary Server Profiles: Device Information, Generic Access and Custom Service to Start Advertising. For transmit messages, we use Generic Access Primary Service with Write permissions of the characteristic Element. In this example, transmitting message is limited to a maximum of 11 characters. Results are being sent to the Usart Terminal where you can track their changes.

void application_task ( void )
{
{
Delay_ms ( 100 );
if ( ( ble6_strncmp( rx_response, hci_le_serverwrite_event, 1 ) == 0 ) && ( cnt > 13 ) )
{
}
}
}
int8_t ble6_strncmp(uint8_t *string1, uint8_t *string2, uint8_t len)
Lexicographically compares function.
err_t ble6_generic_read(ble6_t *ctx, char *data_buf, uint16_t max_len)
BLE 6 data reading function.
void application_task(void)
Definition main.c:204
uint8_t hci_le_serverwrite_event[1]
Definition main.c:58
void ble6_event_handler(void)
BLE 6 event handler.
Definition main.c:526
void ble6_response_handler(void)
BLE 6 response handler.
Definition main.c:317
uint8_t rx_response[PROCESS_BUFFER_SIZE]
Definition main.c:54
uint8_t device_connected_flag
Definition main.c:55
#define PROCESS_BUFFER_SIZE
Definition main.c:46

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.BLE6

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.