无论您是在外出还是在家中,我们的蓝牙解决方案都确保您始终保持连接,为您提供对您最喜爱的设备的不间断访问。
A
A
硬件概览
它是如何工作的?
BLE 6 Click基于STMicroelectronics的BlueNRG-M2,这是一款符合Bluetooth® v5.0标准的蓝牙低功耗应用处理器模块。BlueNRG-M2模块围绕ST BlueNRG-2 SoC设计,其Cortex-M0核心可以执行蓝牙协议和客户应用程序。优化的存储器架构包括256 kB的Flash存储器和24 kB的超低漏电RAM(具有完全的数据保留)。BLUENRG-M2模块具有32 MHz和32 kHz晶振。它被设计为利用BlueNRG-2集成的DC-DC降压转换器,以实现最佳的活动模式下的功耗。它还嵌入了高效的芯片天线。它可以配置为支持应用处
理器(无主机)和网络处理器(托管)模式。BlueNRG-M2模块在微小的尺寸(11.5 x 13.5 x 2.0 mm)上提供了完整的射频应用平台,并且作为认证解决方案优化了最终应用的上市时间。BlueNRG-M2模块允许应用程序满足使用标准纽扣电池时所需的严格建议的峰值电流要求。有两种可能的软件架构:无主机模式(应用处理器 - 客户应用程序在BlueNRG-M2模块上运行)和托管模式(网络处理器 - 该模块配置为由通过SPI或UART连接的外部主机控制的网络模块)。该模块配备了预编程的UART引导加载程序。
BlueNRG-M2嵌入了ARM串行线调试(SWD)端口,路由到SWD头连接器。它是一个具有两个引脚(时钟和单向双向数据)的调试接口,提供了所有调试功能以及对系统内存的实时访问,无需停止处理器或需要任何目标驻留代码。由于SPI外设可以用作主机或从机,因此标记为MODE SEL的板载SMD跳线允许在两者之间切换。此Click Board™仅设计为使用3.3V逻辑电平。在将Click Board™与具有5V逻辑电平的MCU一起使用之前,应进行适当的逻辑电压级转换。
功能概述
开发板
PIC32MZ Clicker 是一款紧凑型入门开发板,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位带有浮点单元的 Microchip PIC32MZ 微控制器,一个 USB 连接器,LED 指示灯,按钮,一个 mikroProg 连接器,以及一个用于与外部电子设备接口的头部。得益于其紧凑的设计和清晰易识别的丝网标记,它提供了流畅且沉浸式的工作体验,允许在任
何情况下、任何地方都能访问。PIC32MZ Clicker 开 发套件的每个部分都包含了使同一板块运行最高效的必要组件。除了可以选择 PIC32MZ Clicker 的编程方式,使用 USB HID mikroBootloader 或通过外部 mikroProg 连接器为 PIC,dsPIC 或 PIC32 编程外,Clicker 板还包括一个干净且调节过的开发套件电源供应模块。USB Micro-B 连接可以提供多达 500mA 的电流,这足以操作所有板载和附加模块。所有
mikroBUS™ 本身支持的通信方法都在这块板上,包 括已经建立良好的 mikroBUS™ 插槽、重置按钮以及若干按钮和 LED 指示灯。PIC32MZ Clicker 是 Mikroe 生态系统的一个组成部分,允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。
微控制器概述
MCU卡片 / MCU

建筑
PIC32
MCU 内存 (KB)
1024
硅供应商
Microchip
引脚数
64
RAM (字节)
524288
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
实时跟踪您的结果
应用程序输出
1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程。

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持
库描述
该库包含 BLE 6 Click 驱动程序的 API。
关键功能:
ble6_set_response_handler
- 设置响应处理函数。ble6_set_handlers
- 设置处理函数。ble6_parser_rsp
- 响应解析器函数。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief BLE 6 Click 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 ).
*
* ## 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.
*
* ## Additional Function
* - void ble6_module_init ( void );
* - void ble6_event_handler ( void );
* - void ble6_display_log ( void );
* - void ble6_aci_gap_init ( void );
* - void ble6_le_meta_event ( void );
* - void ble6_handler ( void );
* - void ble6_response_handler ( void );
* - void ble6_local_version_info ( void );
*
* @note
* For communication with BLE 6 click use the android application on the link:
* https://play.google.com/store/apps/details?id=com.macdom.ble.blescanner
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "ble6.h"
#define PROCESS_BUFFER_SIZE 256
static ble6_t ble6;
static log_t logger;
static ble6_rsp_t rsp_data;
static ble6_le_meta_event_t le_meta_event_data;
static ble6_rx_rsp_t ble6_rx_rsp;
uint8_t app_buf [ PROCESS_BUFFER_SIZE ];
uint8_t rx_response [ PROCESS_BUFFER_SIZE ];
uint8_t device_connected_flag = 0;
uint8_t hci_le_meta_event_connect [ 5 ] = { 0x04, 0x3E, 0x13, 0x01, 0x00 };
uint8_t hci_le_serverwrite_event [ 1 ] = { 0x04 };
uint8_t hci_read_local_version_information [ 4 ] = { 0x01, 0x01, 0x10, 0x00 };
uint8_t hci_info_confirm [ 4 ] = { 0xFF, 0x01, 0x00, 0x00 };
uint8_t aci_hal_get_fw_version [ 4 ] = { 0x01, 0x01, 0xFC, 0x00 };
uint8_t hci_reset [ 4 ] = { 0x01, 0x03, 0x0C, 0x00 };
uint8_t aci_hal_write_config_data [ 12 ] =
{
0x01, 0x0C, 0xFC, 0x08, 0x00, 0x06, 0x03, 0xEE, 0x00, 0xE1, 0x80, 0x02
};
uint8_t aci_hal_set_tx_power_level [ 6 ] = { 0x01, 0x0F, 0xFC, 0x02, 0x01, 0x04 };
uint8_t aci_gatt_init [ 4 ] = { 0x01, 0x01, 0xFD, 0x00 };
uint8_t aci_gap_init [ 7 ] = { 0x01, 0x8A, 0xFC, 0x03, 0x0F, 0x00, 0x0B };
uint8_t aci_gatt_update_value [ 21 ] =
{
0x01, 0x06, 0xFD, 0x11, 0x05, 0x00, 0x06, 0x00, 0x00, 0x0B,
'B', 'L', 'E', ' ', '6', ' ', 'c', 'l', 'i', 'c', 'k'
};
uint8_t hci_le_set_scan_response_data [ 36 ] =
{
0x01, 0x09, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
uint8_t aci_gap_set_discoverable [ 30 ] =
{
0x01, 0x83, 0xFC, 0x19, 0x00, 0x00, 0x08, 0x00, 0x09, 0x00, 0x00, 0x0C, 0x09,
'B', 'L', 'E', ' ', '6', ' ', 'c', 'l', 'i', 'c', 'k', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/**
* @brief BLE 6 module initialisation.
* @details This function is used for initialisation of BLE 6 Click.
*/
void ble6_module_init ( void );
/**
* @brief BLE 6 event handler.
* @details This function is used for checking conncection of BLE 6 Click.
*/
void ble6_event_handler ( void );
/**
* @brief BLE 6 display log.
* @details This function is used for displaying log of BLE 6 Click.
*/
void ble6_display_log ( void );
/**
* @brief BLE 6 aci gap initialisation.
* @details This function is used for aci gap initialisation of BLE 6 Click.
*/
void ble6_aci_gap_init ( void );
/**
* @brief BLE 6 le meta event.
* @details This function is used for low energy events of BLE 6 Click.
*/
void ble6_le_meta_event ( void );
/**
* @brief BLE 6 handler.
* @details This function is used for getting data of BLE 6 Click.
*/
void ble6_handler ( void );
/**
* @brief BLE 6 response handler.
* @details This function is used for displaying data response of BLE 6 Click.
*/
void ble6_response_handler ( void );
/**
* @brief BLE 6 local version info.
* @details This function is used for displaying local version info of BLE 6 Click.
*/
void ble6_local_version_info ( void );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
ble6_cfg_t ble6_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
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 );
ble6_power_on( &ble6, BLE6_MODULE_POWER_ON );
Delay_ms( 1000 );
ble6_module_init( );
Delay_ms( 100 );
log_printf( &logger, "-> Local Version Information: \r\n" );
ble6_send_command( &ble6, &hci_read_local_version_information[ 0 ], 4 );
Delay_ms( 100 );
ble6_handler( );
ble6_display_log( );
ble6_local_version_info( );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> ACI GAP Update Value: \r\n" );
ble6_send_command( &ble6, &aci_gatt_update_value[ 0 ], 21 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> HCI Set Scan. Response Data: \r\n" );
ble6_send_command( &ble6, &hci_le_set_scan_response_data[ 0 ], 36 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> ACI GAP Set Discoverable: \r\n" );
ble6_send_command( &ble6, &aci_gap_set_discoverable[ 0 ], 30 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 100 );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
ble6_event_handler( );
while ( device_connected_flag )
{
int32_t cnt = ble6_generic_read( &ble6, rx_response, PROCESS_BUFFER_SIZE );
Delay_ms( 100 );
if ( ( ble6_strncmp( rx_response, hci_le_serverwrite_event, 1 ) == 0 ) && ( cnt > 13 ) )
{
ble6_response_handler( );
}
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
void ble6_handler ( void )
{
uint16_t tmp;
uint8_t cnt;
ble6_generic_read( &ble6, rx_response, PROCESS_BUFFER_SIZE );
tmp = rx_response[ 5 ];
tmp <<= 8;
tmp |= rx_response[ 4 ];
rsp_data.event_code = rx_response[ 1 ];
rsp_data.length = rx_response[ 2 ];
rsp_data.cmd_opcode = tmp;
rsp_data.status = rx_response[ 6 ];
for ( cnt = 0; cnt < rsp_data.length - 4; cnt++ )
{
rsp_data.payload[ cnt ] = rx_response[ cnt + 7 ];
}
memset( &rx_response[ 0 ], 0, PROCESS_BUFFER_SIZE );
}
void ble6_connect_handler ( void )
{
uint8_t cr_len;
uint16_t tmp;
uint8_t cnt;
ble6_generic_read( &ble6, rx_response, PROCESS_BUFFER_SIZE );
Delay_ms( 100 );
cr_len = 0;
log_printf( &logger, "\r\n" );
le_meta_event_data.le_event_code = rx_response[ 1 ];
le_meta_event_data.le_length = rx_response[ 2 ];
le_meta_event_data.le_subevent_code = rx_response[ 3 ];
le_meta_event_data.le_status = rx_response[ 4 ];
tmp = rx_response[ 6 ];
tmp <<= 8;
tmp |= rx_response[ 5 ];
if ( le_meta_event_data.le_subevent_code == 0x01 )
{
cr_len = 8;
}
le_meta_event_data.le_conn_hdl = tmp;
le_meta_event_data.le_role = rx_response[ 7 ];
le_meta_event_data.le_peer_addr_type = rx_response[ 8 ];
for ( cnt = 0; cnt < 6; cnt++ )
{
le_meta_event_data.le_peer_addr[ cnt ] = rx_response[ cnt + 9 ];
}
tmp = rx_response[ 16 - cr_len ];
tmp <<= 8;
tmp |= rx_response[ 15 - cr_len ];
le_meta_event_data.le_conn_interval = tmp;
tmp = rx_response[ 18 - cr_len ];
tmp <<= 8;
tmp |= rx_response[ 17 - cr_len ];
le_meta_event_data.le_conn_latency = tmp;
tmp = rx_response[ 20 - cr_len ];
tmp <<= 8;
tmp |= rx_response[ 19 - cr_len ];
le_meta_event_data.le_sup_timeout = tmp;
le_meta_event_data.le_master_clk_accuracy = rx_response[ 21 ];
memset( rx_response, 0, PROCESS_BUFFER_SIZE );
}
void ble6_response_handler ( void )
{
uint16_t attr_pos;
uint16_t tmp;
ble6_rx_rsp.event_code = rx_response[ 1 ];
log_printf( &logger, " Event Code : 0x%.4X\r\n", ( uint16_t ) ble6_rx_rsp.event_code );
ble6_rx_rsp.length = rx_response[ 2 ];
log_printf( &logger, " Length : 0x%.4X\r\n", ( uint16_t ) ble6_rx_rsp.length );
tmp = rx_response[ 4 ];
tmp <<= 8;
tmp |= rx_response[ 3 ];
ble6_rx_rsp.e_code = tmp;
log_printf( &logger, " Ecode : 0x%.4X\r\n", ( uint16_t ) ble6_rx_rsp.e_code );
tmp = rx_response[ 6 ];
tmp <<= 8;
tmp |= rx_response[ 5 ];
ble6_rx_rsp.conn_hdl = tmp;
log_printf( &logger, " Connection Handle : 0x%.4X\r\n", ( uint16_t ) ble6_rx_rsp.conn_hdl );
tmp = rx_response[ 8 ];
tmp <<= 8;
tmp |= rx_response[ 7 ];
ble6_rx_rsp.attr_hdl = tmp;
log_printf( &logger, " Attr. Handle : 0x%.2X\r\n", ( uint16_t ) ble6_rx_rsp.attr_hdl );
tmp = rx_response[ 10 ];
tmp <<= 8;
tmp |= rx_response[ 9 ];
ble6_rx_rsp.offset = tmp;
log_printf( &logger, " Offset : 0x%.2X\r\n", ( uint16_t ) ble6_rx_rsp.offset );
tmp = rx_response[ 12 ];
tmp <<= 8;
tmp |= rx_response[ 11 ];
ble6_rx_rsp.attr_data_len = tmp;
log_printf( &logger, " Attr. Data Length : 0x%.2X\r\n", ( uint16_t ) ble6_rx_rsp.attr_data_len );
for ( attr_pos = 0; attr_pos < ble6_rx_rsp.attr_data_len; attr_pos++ )
{
ble6_rx_rsp.attr_data[ attr_pos ] = rx_response[ attr_pos + 13 ];
app_buf[ attr_pos ] = ble6_rx_rsp.attr_data[ attr_pos ];
}
log_printf( &logger, "- - - - - - - - - - - - - - - - \r\n" );
log_printf( &logger, " <--- RX DATA : %s \r\n", app_buf );
log_printf( &logger, "--------------------------------\r\n" );
memset( app_buf, 0, PROCESS_BUFFER_SIZE );
memset( rx_response, 0, PROCESS_BUFFER_SIZE );
memset( ble6_rx_rsp.attr_data, 0, PROCESS_BUFFER_SIZE );
}
void ble6_local_version_info ( void )
{
uint16_t tmp;
log_printf( &logger, "- - - - - - - - - - - - - - - - \r\n" );
log_printf( &logger, " Local Version Information \r\n" );
log_printf( &logger, " HCI Version : 0x%.4X\r\n", ( uint16_t ) rsp_data.payload[ 0 ] );
tmp = rsp_data.payload[ 2 ];
tmp <<= 8;
tmp |= rsp_data.payload[ 1 ];
log_printf( &logger, " HCI Revision : 0x%.2X\r\n", ( uint16_t ) tmp );
log_printf( &logger, " LMP/PAL Version : 0x%.2X\r\n", ( uint16_t ) rsp_data.payload[ 3 ] );
tmp = rsp_data.payload[ 5 ];
tmp <<= 8;
tmp |= rsp_data.payload[ 4 ];
log_printf( &logger, " Manufacture Name: 0x%.2X\r\n", ( uint16_t ) tmp );
tmp = rsp_data.payload[ 7 ];
tmp <<= 8;
tmp |= rsp_data.payload[ 6 ];
log_printf( &logger, " LMP/PAL Sub Ver : 0x%.2X\r\n", ( uint16_t ) tmp );
memset( rsp_data.payload, 0, PROCESS_BUFFER_SIZE );
}
void ble6_le_meta_event ( void )
{
uint8_t cnt;
log_printf( &logger, " CONNECT LE META EVENT \r\n" );
log_printf( &logger, " Event Code : 0x%.4X\r\n",
( uint16_t ) le_meta_event_data.le_event_code );
log_printf( &logger, " Length : 0x%.2X\r\n",
( uint16_t ) le_meta_event_data.le_length );
log_printf( &logger, " Subevent Code : 0x%.2X\r\n",
( uint16_t ) le_meta_event_data.le_subevent_code );
log_printf( &logger, " Status : " );
if ( le_meta_event_data.le_status == 0x00 )
{
log_printf( &logger, "OK\r\n" );
}
else
{
log_printf( &logger, "ERROR 0x%.4X\r\n", ( uint16_t ) le_meta_event_data.le_status );
}
log_printf( &logger, " Connection Handle : 0x%.4X\r\n",
( uint16_t ) le_meta_event_data.le_conn_hdl );
if ( le_meta_event_data.le_subevent_code == 0x01 )
{
log_printf( &logger, " Role : " );
if ( le_meta_event_data.le_role == 0x00 )
{
log_printf( &logger, " Master\r\n" );
}
else
{
log_printf( &logger, "Slave\r\n" );
}
log_printf( &logger, " Peer Address Type : " );
if ( le_meta_event_data.le_role == 0x00 )
{
log_printf( &logger, "Specific\r\n" );
}
else
{
log_printf( &logger, "Random\r\n" );
}
log_printf( &logger, " Peer Address : " );
for ( cnt = 0; cnt < 5; cnt++ )
{
log_printf( &logger, "%.2X:", ( uint16_t ) le_meta_event_data.le_peer_addr[ cnt ] );
}
log_printf( &logger, "%.2X\r\n", ( uint16_t ) le_meta_event_data.le_peer_addr[ 5 ] );
}
log_printf( &logger, " Connection Interval : 0x%.4X\r\n",
( uint16_t ) le_meta_event_data.le_conn_interval );
log_printf( &logger, " Connection Latency : 0x%.4X\r\n",
( uint16_t ) le_meta_event_data.le_conn_latency );
log_printf( &logger, " Supervision Timeout : 0x%.4X\r\n",
( uint16_t ) le_meta_event_data.le_sup_timeout );
if ( le_meta_event_data.le_subevent_code == 0x01 )
{
log_printf( &logger, " Master Clock Accurancy: 0x%.2X\r\n",
( uint16_t ) le_meta_event_data.le_master_clk_accuracy );
}
}
void ble6_aci_gap_init ( void )
{
uint16_t tmp;
log_printf( &logger, "- - - - - - - - - - - - - - - - \r\n" );
log_printf( &logger, " ACI GAP Initialization \r\n" );
tmp = rsp_data.payload[ 1 ];
tmp <<= 8;
tmp |= rsp_data.payload[ 0 ];
log_printf( &logger, " Service Handle : 0x%.2X\r\n", ( uint16_t ) tmp );
tmp = rsp_data.payload[ 3 ];
tmp <<= 8;
tmp |= rsp_data.payload[ 2 ];
log_printf( &logger, " Dev Name Char Hdl.: 0x%.2X\r\n", ( uint16_t ) tmp );
tmp = rsp_data.payload[ 5 ];
tmp <<= 8;
tmp |= rsp_data.payload[ 4 ];
log_printf( &logger, " Appearance Handle : 0x%.2X\r\n", ( uint16_t ) tmp );
memset( rsp_data.payload, 0, PROCESS_BUFFER_SIZE );
}
void ble6_display_log ( void )
{
log_printf( &logger, "<- New Response:\r\n" );
log_printf( &logger, " Opcode: 0x%.4X\r\n", ( uint16_t ) rsp_data.cmd_opcode );
log_printf( &logger, " Length: 0x%.2X\r\n", ( uint16_t ) rsp_data.length );
log_printf( &logger, " Status: " );
if ( rsp_data.status == 0x00 )
{
log_printf( &logger, "OK\r\n" );
}
else
{
log_printf( &logger, "0x%.4X\r\n", ( uint16_t ) rsp_data.status );
}
}
void ble6_event_handler ( void )
{
ble6_generic_read( &ble6, rx_response, PROCESS_BUFFER_SIZE );
Delay_ms( 100 );
if ( ble6_strncmp( rx_response, hci_le_meta_event_connect, 5 )
== 0 )
{
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, " *** Device connected *** \r\n" );
log_printf( &logger, "--------------------------------\r\n" );
ble6_connect_handler( );
ble6_le_meta_event( );
log_printf( &logger, "--------------------------------\r\n" );
Delay_ms( 100 );
device_connected_flag = 1;
}
}
void ble6_module_init ( void )
{
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, " *** SW Reset *** \r\n" );
ble6_send_command( &ble6, hci_info_confirm, 4 );
Delay_ms( 10 );
memset( rx_response, 0, 255 );
Delay_ms( 100 );
ble6_generic_read( &ble6, rx_response, PROCESS_BUFFER_SIZE );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> Firmware Details: \r\n" );
ble6_send_command( &ble6, aci_hal_get_fw_version, 4 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> HCI Reset: \r\n" );
ble6_send_command( &ble6, hci_reset, 4 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> ACI HAL Write Configuration: \r\n" );
ble6_send_command( &ble6, aci_hal_write_config_data, 12 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> ACI Set Tx Power Level: \r\n" );
ble6_send_command( &ble6, aci_hal_set_tx_power_level, 6 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> ACI GATT Init.: \r\n" );
ble6_send_command( &ble6, aci_gatt_init, 4 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log( );
Delay_ms( 100 );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, "-> ACI GAP Init.: \r\n" );
ble6_send_command( &ble6, aci_gap_init, 7 );
Delay_ms( 10 );
ble6_handler( );
ble6_display_log ();
ble6_aci_gap_init( );
Delay_ms( 100 );
}
// ------------------------------------------------------------------------ END