Provide Bluetooth® 5.4 connectivity with dual-mode support for industrial IoT and smart home applications
A
A
Hardware Overview
How does it work?
Vela IF820 Click is based on the Vela IF820 (453-00171R) module from Ezurio, offering an advanced solution for Bluetooth® communication with dual-mode support. This allows operation with both classic Bluetooth and Bluetooth Low Energy (LE), enabling an easy transition from legacy Bluetooth standards to modern LE technology within a single hardware solution. The Vela IF820 is powered by the Infineon Technologies AIROC™ CYW20820 chipset, featuring a high-performance Arm® Cortex®-M4 processor running at a maximum clock speed of 96MHz. Its architecture allows for standalone operation without requiring an external microcontroller, thanks to the integrated Bluetooth protocol stack stored in ROM. This module comes with an integrated antenna and complies with the Bluetooth® Core Specification version 5.4. It supports Basic Data Rate (BR) and Enhanced Data Rate (EDR) at 2Mbps and 3Mbps, as well as extended synchronous connection-oriented communication. Additionally, it provides Bluetooth® LE 1M PHY and 2M PHY support, ensuring robust wireless performance. With an output power of up to 10dBm EIRP and excellent receiver sensitivity (-94 dBm for Bluetooth LE at 1 Mbps), the Vela IF820 ensures reliable and efficient connectivity.
Due to its versatile capabilities, this board is suitable for various applications, including industrial automation, wireless sensor networks, IoT devices, smart home systems, medical monitoring, and other embedded solutions requiring stable and high-performance Bluetooth communication. The 453-00171R and the host MCU are communicated through a UART interface, using standard UART RX and TX pins and hardware flow control pins (CTS/RTS- Clear to Send/Ready to Send) for efficient data transfer. The module defaults to a communication speed of 115200bps, allowing for data exchange over AT commands. In addition to the interface pins, this board includes several auxiliary pins that enhance its functionality. The HWE (Host Wake) signal is used by the module to notify the host system when the Bluetooth device requires attention, ensuring efficient power management and responsiveness. The SPP (Serial Port Profile) pin is dedicated to managing Bluetooth SPP connections, typically serving for connection control or status indication, making it particularly useful for applications requiring reliable serial communication over Bluetooth. Additionally, the RST pin is dedicated to resetting the module, offering the same functionality as the onboard
RESET button, ensuring a convenient way to restart the module when necessary. The board features SWD pads designed for use with MIKROE's 6-pin Needle Cable, enabling optional flash programming and debug functionality via the SWD (Serial Wire Debug) interface. This allows for efficient firmware development, debugging, and troubleshooting, making it easier to optimize and maintain the module’s performance. The back side of the board features multiple test points, providing access to 15 GPIO signals from the module, as well as the Bluetooth UART interface required for flashing EZ-Serial and HCI firmware. Additionally, the DWE pin is available, serving as a signal from the host to the module, indicating that the host MCU requires attention, ensuring efficient communication and system responsiveness. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. It also comes equipped with a library containing functions and example code that can be used as a reference for further development.
Features overview
Development board
Nucleo-64 with STM32F103RB MCU offers a cost-effective and adaptable platform for developers to explore new ideas and prototype their designs. This board harnesses the versatility of the STM32 microcontroller, enabling users to select the optimal balance of performance and power consumption for their projects. It accommodates the STM32 microcontroller in the LQFP64 package and includes essential components such as a user LED, which doubles as an ARDUINO® signal, alongside user and reset push-buttons, and a 32.768kHz crystal oscillator for precise timing operations. Designed with expansion and flexibility in mind, the Nucleo-64 board features an ARDUINO® Uno V3 expansion connector and ST morpho extension pin
headers, granting complete access to the STM32's I/Os for comprehensive project integration. Power supply options are adaptable, supporting ST-LINK USB VBUS or external power sources, ensuring adaptability in various development environments. The board also has an on-board ST-LINK debugger/programmer with USB re-enumeration capability, simplifying the programming and debugging process. Moreover, the board is designed to simplify advanced development with its external SMPS for efficient Vcore logic supply, support for USB Device full speed or USB SNK/UFP full speed, and built-in cryptographic features, enhancing both the power efficiency and security of projects. Additional connectivity is
provided through dedicated connectors for external SMPS experimentation, a USB connector for the ST-LINK, and a MIPI® debug connector, expanding the possibilities for hardware interfacing and experimentation. Developers will find extensive support through comprehensive free software libraries and examples, courtesy of the STM32Cube MCU Package. This, combined with compatibility with a wide array of Integrated Development Environments (IDEs), including IAR Embedded Workbench®, MDK-ARM, and STM32CubeIDE, ensures a smooth and efficient development experience, allowing users to fully leverage the capabilities of the Nucleo-64 board in their projects.
Microcontroller Overview
MCU Card / MCU

Architecture
ARM Cortex-M3
MCU Memory (KB)
128
Silicon Vendor
STMicroelectronics
Pin count
64
RAM (Bytes)
20480
You complete me!
Accessories
Click Shield for Nucleo-64 comes equipped with two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the STM32 Nucleo-64 board with no effort. This way, Mikroe allows its users to add any functionality from our ever-growing range of Click boards™, such as WiFi, GSM, GPS, Bluetooth, ZigBee, environmental sensors, LEDs, speech recognition, motor control, movement sensors, and many more. More than 1537 Click boards™, which can be stacked and integrated, are at your disposal. The STM32 Nucleo-64 boards are based on the microcontrollers in 64-pin packages, a 32-bit MCU with an ARM Cortex M4 processor operating at 84MHz, 512Kb Flash, and 96KB SRAM, divided into two regions where the top section represents the ST-Link/V2 debugger and programmer while the bottom section of the board is an actual development board. These boards are controlled and powered conveniently through a USB connection to program and efficiently debug the Nucleo-64 board out of the box, with an additional USB cable connected to the USB mini port on the board. Most of the STM32 microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the STM32 Nucleo-64 board with our Click Shield for Nucleo-64, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.
6-pin Needle Cable is a compact programming cable made from high-quality materials for longevity and easy portability with a tiny square footprint, similar to a 0805 resistor. Designed for quick programming and debugging, it features a 6-pin 0.1″ pitch ribbon connector and is hand-held or temporarily fixable.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Software Support
Library Description
Vela IF820 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Example Description
This example demonstrates the use of Vela IF820 Click by processing data from a connected BT Classic device.
Key functions:
velaif820_cfg_setup- Config Object Initialization function.velaif820_init- Initialization function.velaif820_cmd_set- This function sends a specified set command to the Click module.velaif820_cmd_get- This function sends a specified get command to the Click module.velaif820_read_packet- This function reads a response or event packet from the Click module and stores it in ctx->evt_pkt structure.
Application Init
Initializes the driver and logger.
Application Task
Application task is split in few stages:
VELAIF820_POWER_UP:Powers up the device and checks the communication.VELAIF820_CONFIG_EXAMPLE:Restores factory settings, sets BT Classic flags and reads the BT address and name.VELAIF820_EXAMPLE:Performs a BT terminal example by processing all data from a connected BT Classic device and sending back an adequate response messages.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief Vela IF820 Click Example.
*
* # Description
* This example demonstrates the use of Vela IF820 Click board by processing data
* from a connected BT Classic device.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and logger.
*
* ## Application Task
* Application task is split in few stages:
* - VELAIF820_POWER_UP:
* Powers up the device and checks the communication.
* - VELAIF820_CONFIG_EXAMPLE:
* Restores factory settings, sets BT Classic flags and reads the BT address and name.
* - VELAIF820_EXAMPLE:
* Performs a BT terminal example by processing all data from a connected BT Classic device
* and sending back an adequate response messages.
*
* ## Additional Function
* - static void velaif820_clear_app_buf ( void )
* - static void velaif820_log_app_buf ( void )
* - static err_t velaif820_process ( velaif820_t *ctx )
* - static err_t velaif820_wait_packet ( velaif820_t *ctx, uint8_t timeout_s, uint8_t rsp_flag, uint8_t *cmd_code )
* - static err_t velaif820_power_up ( velaif820_t *ctx )
* - static err_t velaif820_config_example ( velaif820_t *ctx )
* - static err_t velaif820_example ( velaif820_t *ctx )
*
* @note
* We have used the Serial Bluetooth Terminal smartphone application for the test.
* A smartphone and the Click board must be paired in order to exchange messages with each other.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "velaif820.h"
// Message content
#define MESSAGE_CONTENT "Vela IF820 Click board - demo example."
static velaif820_t velaif820;
static log_t logger;
// Application buffer size
#define APP_BUFFER_SIZE 500
#define PROCESS_BUFFER_SIZE 200
static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
/**
* @brief Example states.
* @details Predefined enum values for application example state.
*/
typedef enum
{
VELAIF820_POWER_UP = 1,
VELAIF820_CONFIG_EXAMPLE,
VELAIF820_EXAMPLE
} velaif820_app_state_t;
static velaif820_app_state_t app_state = VELAIF820_POWER_UP;
/**
* @brief Vela IF820 clearing application buffer.
* @details This function clears memory of application buffer and reset its length.
* @note None.
*/
static void velaif820_clear_app_buf ( void );
/**
* @brief Vela IF820 log application buffer.
* @details This function logs data from application buffer to USB UART.
* @note None.
*/
static void velaif820_log_app_buf ( void );
/**
* @brief Vela IF820 data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @param[in] ctx : Click context object.
* See #velaif820_t object definition for detailed explanation.
* @return @li @c 0 - Read some data.
* @li @c -1 - Nothing is read.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t velaif820_process ( velaif820_t *ctx );
/**
* @brief Vela IF820 wait packet function.
* @details This function waits for a packet message, reads and displays it on the USB UART.
* @param[in] ctx : Click context object.
* See #velaif820_t object definition for detailed explanation.
* @param[in] timeout_s : Timeout in seconds.
* @param[in] rsp_flag : 1 - response packet, 0 - event packet.
* @param[in] cmd_code : Expected command code string.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t velaif820_wait_packet ( velaif820_t *ctx, uint8_t timeout_s, uint8_t rsp_flag, uint8_t *cmd_code );
/**
* @brief Vela IF820 power up function.
* @details This function powers up the device and checks communication.
* @param[in] ctx : Click context object.
* See #velaif820_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t velaif820_power_up ( velaif820_t *ctx );
/**
* @brief Vela IF820 config example function.
* @details This function restores factory settings, sets BT Classic flags and reads the BT address and name.
* @param[in] ctx : Click context object.
* See #velaif820_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t velaif820_config_example ( velaif820_t *ctx );
/**
* @brief Vela IF820 example function.
* @details This function performs a BT terminal example by processing all data from
* a connected BT Classic device and sending back an adequate response messages.
* @param[in] ctx : Click context object.
* See #velaif820_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t velaif820_example ( velaif820_t *ctx );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
velaif820_cfg_t velaif820_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.
velaif820_cfg_setup( &velaif820_cfg );
VELAIF820_MAP_MIKROBUS( velaif820_cfg, MIKROBUS_1 );
if ( UART_ERROR == velaif820_init( &velaif820, &velaif820_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
app_state = VELAIF820_POWER_UP;
log_printf( &logger, ">>> APP STATE - POWER UP <<<\r\n\n" );
}
void application_task ( void )
{
switch ( app_state )
{
case VELAIF820_POWER_UP:
{
if ( VELAIF820_OK == velaif820_power_up( &velaif820 ) )
{
app_state = VELAIF820_CONFIG_EXAMPLE;
log_printf( &logger, ">>> APP STATE - CONFIG EXAMPLE <<<\r\n\n" );
}
break;
}
case VELAIF820_CONFIG_EXAMPLE:
{
if ( VELAIF820_OK == velaif820_config_example( &velaif820 ) )
{
app_state = VELAIF820_EXAMPLE;
log_printf( &logger, ">>> APP STATE - EXAMPLE <<<\r\n\n" );
}
break;
}
case VELAIF820_EXAMPLE:
{
velaif820_example( &velaif820 );
break;
}
default:
{
log_error( &logger, " APP STATE." );
break;
}
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
static void velaif820_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static void velaif820_log_app_buf ( void )
{
for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
{
log_printf( &logger, "%c", app_buf[ buf_cnt ] );
}
}
static err_t velaif820_process ( velaif820_t *ctx )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t overflow_bytes = 0;
int32_t rx_cnt = 0;
int32_t rx_size = velaif820_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
if ( ( rx_size > 0 ) && ( rx_size <= APP_BUFFER_SIZE ) )
{
if ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE )
{
overflow_bytes = ( app_buf_len + rx_size ) - APP_BUFFER_SIZE;
app_buf_len = APP_BUFFER_SIZE - rx_size;
memmove ( app_buf, &app_buf[ overflow_bytes ], app_buf_len );
memset ( &app_buf[ app_buf_len ], 0, overflow_bytes );
}
for ( rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ )
{
if ( rx_buf[ rx_cnt ] )
{
app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
}
}
return VELAIF820_OK;
}
return VELAIF820_ERROR;
}
static err_t velaif820_wait_packet ( velaif820_t *ctx, uint8_t timeout_s, uint8_t rsp_flag, uint8_t *cmd_code )
{
err_t error_flag = VELAIF820_OK;
uint32_t timeout_cnt = 0;
while ( ( timeout_cnt < timeout_s ) || ( VELAIF820_WAIT_TIMEOUT_INFINITE == timeout_s ) )
{
error_flag = velaif820_read_packet( ctx );
if ( VELAIF820_OK == error_flag )
{
if ( VELAIF820_PACKET_TYPE_EVENT == ctx->evt_pkt.rsp_flag )
{
log_printf ( &logger, " < EVENT >\r\n" );
}
else
{
log_printf ( &logger, " < RESPONSE >\r\n" );
}
if ( ( VELAIF820_PACKET_TYPE_EVENT == ctx->evt_pkt.rsp_flag ) &&
( strstr( ctx->evt_pkt.command, VELAIF820_EVT_SYS_ERROR ) ) )
{
log_printf( &logger, " Wrong CMD!\r\n" );
error_flag = VELAIF820_ERROR_CMD;
break;
}
else if ( ( ctx->evt_pkt.rsp_flag == rsp_flag ) &&
( strstr( ctx->evt_pkt.command, cmd_code ) ) )
{
log_printf ( &logger, " Command: %s\r\n", ctx->evt_pkt.command );
if ( VELAIF820_PACKET_TYPE_RESPONSE == ctx->evt_pkt.rsp_flag )
{
if ( ctx->evt_pkt.rsp_result )
{
log_printf( &logger, " Result: %.4X\r\n", ctx->evt_pkt.rsp_result );
error_flag = VELAIF820_ERROR;
break;
}
else
{
log_printf( &logger, " Result: OK\r\n" );
}
}
if ( strlen ( ctx->evt_pkt.payload ) )
{
log_printf ( &logger, " Payload: %s\r\n", ctx->evt_pkt.payload );
}
error_flag = VELAIF820_OK;
break;
}
else
{
log_printf ( &logger, " Command: %s\r\n", ctx->evt_pkt.command );
if ( VELAIF820_PACKET_TYPE_RESPONSE == ctx->evt_pkt.rsp_flag )
{
if ( ctx->evt_pkt.rsp_result )
{
log_printf( &logger, " Result: %.4X\r\n", ctx->evt_pkt.rsp_result );
}
else
{
log_printf( &logger, " Result: OK\r\n" );
}
}
if ( strlen ( ctx->evt_pkt.payload ) )
{
log_printf ( &logger, " Payload: %s\r\n", ctx->evt_pkt.payload );
}
}
}
else
{
timeout_cnt++;
}
}
if ( ( timeout_cnt >= timeout_s ) && ( 0 != timeout_s ) )
{
log_printf( &logger, " < TIMEOUT >\r\n" );
error_flag = VELAIF820_ERROR_TIMEOUT;
}
log_printf( &logger, "--------------------------------\r\n" );
return error_flag;
}
static err_t velaif820_power_up ( velaif820_t *ctx )
{
err_t error_flag = VELAIF820_OK;
log_printf( &logger, ">> Reset device.\r\n" );
velaif820_set_cmd_mode( ctx );
velaif820_reset_device( ctx );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_EVENT,
VELAIF820_EVT_GAP_ADV_STATE_CHANGED );
log_printf( &logger, ">> Check communication.\r\n" );
velaif820_cmd_action( ctx, VELAIF820_CMD_SYS_PING, NULL );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_RESPONSE,
VELAIF820_CMD_SYS_PING );
return error_flag;
}
static err_t velaif820_config_example ( velaif820_t *ctx )
{
err_t error_flag = VELAIF820_OK;
log_printf( &logger, ">> Factory reset.\r\n" );
velaif820_cmd_action( ctx, VELAIF820_CMD_SYS_FACTORY_RESET, NULL );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_EVENT,
VELAIF820_EVT_GAP_ADV_STATE_CHANGED );
#define SET_BT_CLASSIC_FLAG "T=92"
log_printf( &logger, ">> Set BT Classic flags.\r\n" );
velaif820_cmd_set( ctx, VELAIF820_CMD_SYS_TRANSPORT, SET_BT_CLASSIC_FLAG );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_RESPONSE,
VELAIF820_CMD_SYS_TRANSPORT );
log_printf( &logger, ">> Save settings.\r\n" );
velaif820_cmd_action( ctx, VELAIF820_CMD_SYS_STORE_CONFIG, NULL );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_RESPONSE,
VELAIF820_CMD_SYS_STORE_CONFIG );
log_printf( &logger, ">> Reboot.\r\n" );
velaif820_cmd_action( ctx, VELAIF820_CMD_SYS_REBOOT, NULL );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_EVENT,
VELAIF820_EVT_GAP_ADV_STATE_CHANGED );
log_printf( &logger, ">> Get BT address.\r\n" );
velaif820_cmd_get( ctx, VELAIF820_CMD_SYS_BT_ADDRESS, NULL );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_RESPONSE,
VELAIF820_CMD_SYS_BT_ADDRESS );
#define GET_BT_CLASSIC_NAME "T=1"
log_printf( &logger, ">> Get device name.\r\n" );
velaif820_cmd_get( ctx, VELAIF820_CMD_GAP_DEVICE_NAME, GET_BT_CLASSIC_NAME );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_RESPONSE,
VELAIF820_CMD_GAP_DEVICE_NAME );
return error_flag;
}
static err_t velaif820_example ( velaif820_t *ctx )
{
err_t error_flag = VELAIF820_OK;
uint32_t timeout_cnt = 0;
#define BT_TERMINAL_TIMEOUT_MS 60000
#define BT_TERMINAL_MESSAGE_FREQ_MS 5000
#define TERMINATION_CMD "END"
#define TERMINATION_RESPONSE "END command received, the connection will be terminated in a few seconds."
#define TERMINATION_TIMEOUT "Timeout, closing the connection in a few seconds."
Delay_ms ( 100 );
log_printf( &logger, ">> Waiting for a BT peer to establish connection with the Click board...\r\n" );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_INFINITE,
VELAIF820_PACKET_TYPE_EVENT,
VELAIF820_EVT_BT_CONNECTED );
log_printf( &logger, ">> BT peer has connected.\r\n" );
velaif820_set_data_mode( ctx );
log_printf( &logger, ">> Waiting for data (up to 60 seconds)...\r\n" );
log_printf( &logger, ">> Connection will be terminated if the Click receives an \"END\" string.\r\n" );
for ( ; ; )
{
velaif820_clear_app_buf( );
if ( VELAIF820_OK == velaif820_process( ctx ) )
{
Delay_ms ( 100 );
timeout_cnt = 0;
velaif820_process( ctx );
velaif820_log_app_buf( );
if ( strstr( app_buf, TERMINATION_CMD ) )
{
log_printf( &logger, ">> Terminating connection on demand.\r\n" );
error_flag |= velaif820_generic_write ( ctx, TERMINATION_RESPONSE, strlen ( TERMINATION_RESPONSE ) );
error_flag |= velaif820_generic_write ( ctx, VELAIF820_PACKET_END, strlen ( VELAIF820_PACKET_END ) );
Delay_ms ( 1000 );
log_printf( &logger, ">> Disconnecting BT peer.\r\n" );
velaif820_set_cmd_mode( ctx );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_EVENT,
VELAIF820_EVT_BT_DISCONNECTED );
break;
}
else if ( strstr( app_buf, VELAIF820_EVT_BT_DISCONNECTED ) )
{
log_printf( &logger, ">> BT peer has disconnected.\r\n" );
break;
}
}
timeout_cnt++;
if ( 0 == ( timeout_cnt % BT_TERMINAL_MESSAGE_FREQ_MS ) )
{
log_printf( &logger, ">> Sending \"%s\" message to connected device.\r\n", ( char * ) MESSAGE_CONTENT );
error_flag |= velaif820_generic_write ( ctx, MESSAGE_CONTENT, strlen ( MESSAGE_CONTENT ) );
error_flag |= velaif820_generic_write ( ctx, VELAIF820_PACKET_END, strlen ( VELAIF820_PACKET_END ) );
Delay_ms ( 100 );
}
if ( BT_TERMINAL_TIMEOUT_MS < timeout_cnt )
{
log_printf( &logger, ">> Terminating connection due to 60s timeout expiration.\r\n" );
error_flag |= velaif820_generic_write ( ctx, TERMINATION_TIMEOUT, strlen ( TERMINATION_TIMEOUT ) );
error_flag |= velaif820_generic_write ( ctx, VELAIF820_PACKET_END, strlen ( VELAIF820_PACKET_END ) );
Delay_ms ( 1000 );
log_printf( &logger, ">> Disconnecting BT peer.\r\n" );
velaif820_set_cmd_mode( ctx );
error_flag |= velaif820_wait_packet( ctx, VELAIF820_WAIT_TIMEOUT_5S,
VELAIF820_PACKET_TYPE_EVENT,
VELAIF820_EVT_BT_DISCONNECTED );
break;
}
Delay_ms ( 1 );
}
return error_flag;
}
// ------------------------------------------------------------------------ END
Additional Support
Resources
Category:BT/BLE



































