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 :

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 " );
}

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 ) )
{
}
}
}

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.


rx_response
uint8_t rx_response[PROCESS_BUFFER_SIZE]
Definition: main.c:54
ble6_parser_rsp
void ble6_parser_rsp(ble6_t *ctx, ble6_rsp_t *response)
Response parser function.
BLE6_MAP_MIKROBUS
#define BLE6_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: ble6.h:85
ble6_set_response_handler
void ble6_set_response_handler(void(*handler)(uint8_t *), ble6_hdl_t driver_hdl)
Set response handlers function.
ble6_response_handler
void ble6_response_handler(void)
BLE 6 response handler.
Definition: main.c:310
hci_read_local_version_information
uint8_t hci_read_local_version_information[4]
Definition: main.c:59
hci_le_set_scan_response_data
uint8_t hci_le_set_scan_response_data[36]
Definition: main.c:75
ble6_hdl_t
void(* ble6_hdl_t)(uint8_t *)
BLE 6 Click driver handler.
Definition: ble6.h:221
ble6_handler
void ble6_handler(void)
BLE 6 handler.
Definition: main.c:229
ble6_display_log
void ble6_display_log(void)
BLE 6 display log.
Definition: main.c:499
ble6_handler_t
void(* ble6_handler_t)(uint8_t *message_buf, uint32_t message_len)
BLE 6 Click driver handler.
Definition: ble6.h:215
application_task
void application_task(void)
Definition: main.c:204
PROCESS_BUFFER_SIZE
#define PROCESS_BUFFER_SIZE
Definition: main.c:46
ble6_cfg_t
BLE 6 Click configuration object.
Definition: ble6.h:122
ble6_init
err_t ble6_init(ble6_t *ctx, ble6_cfg_t *cfg)
BLE 6 initialization function.
ble6_t
BLE 6 Click context object.
Definition: ble6.h:100
ble6_power_on
void ble6_power_on(ble6_t *ctx, uint8_t en_pwr)
Set Power On function.
ble6_module_init
void ble6_module_init(void)
BLE 6 module initialisation.
Definition: main.c:538
ble6_event_handler
void ble6_event_handler(void)
BLE 6 event handler.
Definition: main.c:519
aci_gatt_update_value
uint8_t aci_gatt_update_value[21]
Definition: main.c:70
ble6_strncmp
int8_t ble6_strncmp(uint8_t *string1, uint8_t *string2, uint8_t len)
Lexicographically compares function.
aci_gap_set_discoverable
uint8_t aci_gap_set_discoverable[30]
Definition: main.c:81
ble6_cfg_setup
void ble6_cfg_setup(ble6_cfg_t *cfg)
BLE 6 configuration object setup function.
application_init
void application_init(void)
Definition: main.c:135
BLE6_MODULE_POWER_ON
#define BLE6_MODULE_POWER_ON
Definition: ble6.h:60
ble6_rsp_t
Driver Default Response type.
Definition: ble6.h:146
device_connected_flag
uint8_t device_connected_flag
Definition: main.c:55
ble6_send_command
void ble6_send_command(ble6_t *ctx, uint8_t *tx_data, uint8_t n_bytes)
Send command function.
ble6_generic_read
err_t ble6_generic_read(ble6_t *ctx, char *data_buf, uint16_t max_len)
BLE 6 data reading function.
hci_le_serverwrite_event
uint8_t hci_le_serverwrite_event[1]
Definition: main.c:58
ble6_set_handlers
void ble6_set_handlers(ble6_handler_t event_handler, ble6_handler_t eve_hdlr)
Set handlers function.
ble6_local_version_info
void ble6_local_version_info(void)
BLE 6 local version info.
Definition: main.c:370