Intermediate
30 min

Unlock the magic of Bluetooth with BGM220P and MK64FN1M0VDC12

Our Bluetooth marvel!

BLE 9 Click with Clicker 2 for Kinetis

Published Jul 29, 2023

Click board™

BLE 9 Click

Dev Board

Clicker 2 for Kinetis

Compiler

NECTO Studio

MCU

MK64FN1M0VDC12

Discover the true essence of wireless convenience with our advanced Bluetooth solution, connecting your devices effortlessly and eliminating the hassle of cables

A

A

Hardware Overview

How does it work?

BLE 9 Click is based on the BGM220P, an RF performance Bluetooth Low Energy solution that provides BT/BLE connectivity for any embedded application from Silicon Labs. It supports Bluetooth 5.2, direction-finding, and Bluetooth Mesh Low Power Node protocols to deliver industry-leading accuracy. It has worldwide regulatory certifications and a fully-upgradeable software stack as advanced development and debugging tool. The BGM220P module combines the EFR32BG22 wireless System on a Chip (SoC), required decoupling capacitors and inductors, 38.4 MHz and 32.768 kHz crystals, an RF matching circuit, and an integrated ceramic onboard chip antenna. The EFR32BG22 SoC, inside the BGM220P module, includes an Arm Cortex-M33 processing core, up to 32Kb of RAM, up to 512kB of flash memory, and a 2.4GHz radio transceiver, offering up to 8dB output power. This Click board™ offers enhanced performance,

security, and reliability to support IoT products running on Bluetooth networks. BLE 9 Click communicates with MCU using the UART interface as its default communication protocol with the option for the users to use other interfaces, such as SPI and I2C, if they want to configure the module and write the library by themselves using these protocols. It also can be used in a stand-alone SoC configuration without an external host processor. In addition to these protocol pins, this Click board™ also has serial UART connections labeled as CTS and RTS, routed on the CS and INT pins of the mikroBUS™ socket, as well as the Reset pin provided and routed at the RST pin of the mikroBUS™ socket. An additional GPIO pin, labeled as IO routed on the PWM pin of the mikroBUS™ socket, is left for configuration purposes as the user desires. An onboard jumper selects the function of the CS mikroBUS™ pin between the SPI or UART communication pin.

Selection is performed by positioning the SMD jumper, labeled as CTS or CS, to an appropriate position. At the bottom of the BLE 9 Click is an additional header, the Mini Simplicity Debug Connector, which fully supports debugging and programming capabilities. With this header, the user can use a serial wire debug interface for programming and debugging, using SWCLK and SWDIO pins, with a Virtual UART COM port and Virtual UART-SWD-based interface also available through the SWD interface (SWDIO, SWCLK, and SWO). 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. Also, it comes equipped with a library containing functions and an example code that can be used, as a reference, for further development.

BLE 9 Click hardware overview image

Features overview

Development board

Clicker 2 for Kinetis is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit ARM Cortex-M4F microcontroller, the MK64FN1M0VDC12 from NXP Semiconductors, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a JTAG programmer connector, and two 26-pin headers for interfacing with external electronics. Its compact design with clear and easily recognizable silkscreen markings allows you to build gadgets with unique functionalities and

features quickly. Each part of the Clicker 2 for Kinetis development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the Clicker 2 for Kinetis programming method, using a USB HID mikroBootloader or an external mikroProg connector for Kinetis programmer, the Clicker 2 board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Micro-B cable, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or

using a Li-Polymer battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several user-configurable buttons and LED indicators. Clicker 2 for Kinetis is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Clicker 2 for Kinetis dimensions image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

NXP

Pin count

121

RAM (Bytes)

262144

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
PB11
RST
UART CTS / SPI Chip Select
PC4
CS
SPI Clock
PC5
SCK
SPI Data OUT
PC7
MISO
SPI Data IN
PC6
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
User-Configurable I/0
PA10
PWM
UART RTS
PB13
INT
UART TX
PD3
TX
UART RX
PD2
RX
I2C Clock
PD8
SCL
I2C Data
PD9
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

BLE 9 Click Schematic schematic

Step by step

Project assembly

Clicker 2 for PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Clicker 2 for Kinetis as your development board.

Clicker 2 for PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
Micro B Connector Clicker 2 Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Flip&Click PIC32MZ MCU step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.

Software Support

Library Description

This library contains API for BLE 9 Click driver.

Key functions:

  • ble9_adv_create_id - This function creates adequate ID

  • ble9_adv_start - This function starts advertising

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 BLE 9 Click example
 *
 * # Description
 * This example demonstrates the use of BLE 9 click board by processing
 * the incoming data and displaying them on the USB UART.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Reads and processes all incoming data and displays them on the USB UART.
 *
 * ## Additional Function
 * - static void ble9_clear_app_buf ( void )
 * - static err_t ble9_process ( ble9_t *ctx )
 * 
 * <pre>
 * For more information on the chip itself and the firmware on it,
 * please visit the following page:
 *     [1] https://docs.silabs.com/bluetooth/3.1
 *         - Take into condideration that the library itself
 *           is designed to work with GSDK version 3.1.0
 *           If you wish to use a different version of firmware,
 *           take into consideration that some functions might not work.
 * </pre>
 *
 * @author MikroE Team
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "ble9.h"
#include "log.h"

#define PROCESS_BUFFER_SIZE 200

static ble9_t ble9;
static log_t logger;

static uint8_t app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;

/**
 * @brief BLE 9 clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void ble9_clear_app_buf ( void );

/**
 * @brief BLE 9 data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #ble9_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 ble9_process ( ble9_t *ctx );

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    ble9_cfg_t cfg;

    /** 
     * 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 ----" );
    Delay_ms ( 100 );

    // Click initialization.
    ble9_cfg_setup( &cfg );
    BLE9_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    ble9_init( &ble9, &cfg );
    Delay_ms ( 1000 );
    
    // Clear app buffer
    ble9_process ( &ble9 );
    ble9_clear_app_buf( );
    Delay_ms ( 100 );
    
    if ( BLE9_OK == ble9_sys_get_version ( &ble9 ) )
    {
        log_printf( &logger, "--- System Version ---\r\n" );
        log_printf( &logger, " Major: 0x%.4X\r\n", ble9.ble9_version.version_major );
        log_printf( &logger, " Minor: 0x%.4X\r\n", ble9.ble9_version.version_minor );
        log_printf( &logger, " Patch: 0x%.4X\r\n", ble9.ble9_version.version_patch );
        log_printf( &logger, " Build: 0x%.4X\r\n", ble9.ble9_version.version_build );
        log_printf( &logger, " Bootloader: 0x%.8LX\r\n", ble9.ble9_version.version_bootloader );
        log_printf( &logger, " Hash: 0x%.8LX\r\n", ble9.ble9_version.version_hash );
        log_printf( &logger, "------------------------\r\n" );
    }
    
    log_printf( &logger, "Creating advertising point...\r\n" );
    Delay_ms ( 100 );
    ble9_adv_create_id ( &ble9 );

    log_printf( &logger, "Starting module advertising...\r\n" );
    Delay_ms ( 100 );
    ble9_adv_start ( &ble9, BLE9_ADVERTISER_MODE_DISCOVERABLE_GENERAL, 
                     BLE9_ADVERTISER_MODE_CONNECTABLE_SCANNABLE );

    log_printf( &logger, "The module has been configured.\r\n" );
    Delay_ms ( 100 );
}

void application_task ( void )
{
    ble9_process ( &ble9 );
    if ( app_buf_len > 0 ) 
    {
        for ( uint16_t cnt = 0; cnt < app_buf_len; cnt++ )
        {
            log_printf( &logger, "%.2X ", ( uint16_t ) app_buf[ cnt ] );
        }
        ble9_clear_app_buf( );
    }
}

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 ble9_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static err_t ble9_process ( ble9_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t rx_size = 0;
    rx_size = ble9_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
    if ( rx_size > 0 ) 
    {
        int32_t buf_cnt = app_buf_len;
        if ( ( ( app_buf_len + rx_size ) > PROCESS_BUFFER_SIZE ) && ( app_buf_len > 0 ) ) 
        {
            buf_cnt = PROCESS_BUFFER_SIZE - ( ( app_buf_len + rx_size ) - PROCESS_BUFFER_SIZE );
            memmove ( app_buf, &app_buf[ PROCESS_BUFFER_SIZE - buf_cnt ], buf_cnt );
        }
        for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] ) 
            {
                app_buf[ buf_cnt++ ] = rx_buf[ rx_cnt ];
                if ( app_buf_len < PROCESS_BUFFER_SIZE )
                {
                    app_buf_len++;
                }
            }
        }
        return BLE9_OK;
    }
    return BLE9_ERROR;
}

// ------------------------------------------------------------------------ END
/*!
 * @file main.c
 * @brief BLE 9 Click example
 *
 * # Description
 * This example demonstrates the use of BLE 9 click board by processing
 * the incoming data and displaying them on the USB UART.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Reads and processes all incoming data and displays them on the USB UART.
 *
 * ## Additional Function
 * - static void ble9_clear_app_buf ( void )
 * - static err_t ble9_process ( ble9_t *ctx )
 * 
 * <pre>
 * For more information on the chip itself and the firmware on it,
 * please visit the following page:
 *     [1] https://docs.silabs.com/bluetooth/3.1
 *         - Take into condideration that the library itself
 *           is designed to work with GSDK version 3.1.0
 *           If you wish to use a different version of firmware,
 *           take into consideration that some functions might not work.
 * </pre>
 *
 * @author MikroE Team
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "ble9.h"
#include "log.h"

#define PROCESS_BUFFER_SIZE 200

static ble9_t ble9;
static log_t logger;

static uint8_t app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;

/**
 * @brief BLE 9 clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void ble9_clear_app_buf ( void );

/**
 * @brief BLE 9 data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #ble9_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 ble9_process ( ble9_t *ctx );

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    ble9_cfg_t cfg;

    /** 
     * 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 ----" );
    Delay_ms ( 100 );

    // Click initialization.
    ble9_cfg_setup( &cfg );
    BLE9_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    ble9_init( &ble9, &cfg );
    Delay_ms ( 1000 );
    
    // Clear app buffer
    ble9_process ( &ble9 );
    ble9_clear_app_buf( );
    Delay_ms ( 100 );
    
    if ( BLE9_OK == ble9_sys_get_version ( &ble9 ) )
    {
        log_printf( &logger, "--- System Version ---\r\n" );
        log_printf( &logger, " Major: 0x%.4X\r\n", ble9.ble9_version.version_major );
        log_printf( &logger, " Minor: 0x%.4X\r\n", ble9.ble9_version.version_minor );
        log_printf( &logger, " Patch: 0x%.4X\r\n", ble9.ble9_version.version_patch );
        log_printf( &logger, " Build: 0x%.4X\r\n", ble9.ble9_version.version_build );
        log_printf( &logger, " Bootloader: 0x%.8LX\r\n", ble9.ble9_version.version_bootloader );
        log_printf( &logger, " Hash: 0x%.8LX\r\n", ble9.ble9_version.version_hash );
        log_printf( &logger, "------------------------\r\n" );
    }
    
    log_printf( &logger, "Creating advertising point...\r\n" );
    Delay_ms ( 100 );
    ble9_adv_create_id ( &ble9 );

    log_printf( &logger, "Starting module advertising...\r\n" );
    Delay_ms ( 100 );
    ble9_adv_start ( &ble9, BLE9_ADVERTISER_MODE_DISCOVERABLE_GENERAL, 
                     BLE9_ADVERTISER_MODE_CONNECTABLE_SCANNABLE );

    log_printf( &logger, "The module has been configured.\r\n" );
    Delay_ms ( 100 );
}

void application_task ( void )
{
    ble9_process ( &ble9 );
    if ( app_buf_len > 0 ) 
    {
        for ( uint16_t cnt = 0; cnt < app_buf_len; cnt++ )
        {
            log_printf( &logger, "%.2X ", ( uint16_t ) app_buf[ cnt ] );
        }
        ble9_clear_app_buf( );
    }
}

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 ble9_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static err_t ble9_process ( ble9_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t rx_size = 0;
    rx_size = ble9_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
    if ( rx_size > 0 ) 
    {
        int32_t buf_cnt = app_buf_len;
        if ( ( ( app_buf_len + rx_size ) > PROCESS_BUFFER_SIZE ) && ( app_buf_len > 0 ) ) 
        {
            buf_cnt = PROCESS_BUFFER_SIZE - ( ( app_buf_len + rx_size ) - PROCESS_BUFFER_SIZE );
            memmove ( app_buf, &app_buf[ PROCESS_BUFFER_SIZE - buf_cnt ], buf_cnt );
        }
        for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] ) 
            {
                app_buf[ buf_cnt++ ] = rx_buf[ rx_cnt ];
                if ( app_buf_len < PROCESS_BUFFER_SIZE )
                {
                    app_buf_len++;
                }
            }
        }
        return BLE9_OK;
    }
    return BLE9_ERROR;
}

// ------------------------------------------------------------------------ END
/*!
 * @file main.c
 * @brief BLE 9 Click example
 *
 * # Description
 * This example demonstrates the use of BLE 9 click board by processing
 * the incoming data and displaying them on the USB UART.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Reads and processes all incoming data and displays them on the USB UART.
 *
 * ## Additional Function
 * - static void ble9_clear_app_buf ( void )
 * - static err_t ble9_process ( ble9_t *ctx )
 * 
 * <pre>
 * For more information on the chip itself and the firmware on it,
 * please visit the following page:
 *     [1] https://docs.silabs.com/bluetooth/3.1
 *         - Take into condideration that the library itself
 *           is designed to work with GSDK version 3.1.0
 *           If you wish to use a different version of firmware,
 *           take into consideration that some functions might not work.
 * </pre>
 *
 * @author MikroE Team
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "ble9.h"
#include "log.h"

#define PROCESS_BUFFER_SIZE 200

static ble9_t ble9;
static log_t logger;

static uint8_t app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;

/**
 * @brief BLE 9 clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void ble9_clear_app_buf ( void );

/**
 * @brief BLE 9 data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #ble9_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 ble9_process ( ble9_t *ctx );

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    ble9_cfg_t cfg;

    /** 
     * 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 ----" );
    Delay_ms ( 100 );

    // Click initialization.
    ble9_cfg_setup( &cfg );
    BLE9_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    ble9_init( &ble9, &cfg );
    Delay_ms ( 1000 );
    
    // Clear app buffer
    ble9_process ( &ble9 );
    ble9_clear_app_buf( );
    Delay_ms ( 100 );
    
    if ( BLE9_OK == ble9_sys_get_version ( &ble9 ) )
    {
        log_printf( &logger, "--- System Version ---\r\n" );
        log_printf( &logger, " Major: 0x%.4X\r\n", ble9.ble9_version.version_major );
        log_printf( &logger, " Minor: 0x%.4X\r\n", ble9.ble9_version.version_minor );
        log_printf( &logger, " Patch: 0x%.4X\r\n", ble9.ble9_version.version_patch );
        log_printf( &logger, " Build: 0x%.4X\r\n", ble9.ble9_version.version_build );
        log_printf( &logger, " Bootloader: 0x%.8LX\r\n", ble9.ble9_version.version_bootloader );
        log_printf( &logger, " Hash: 0x%.8LX\r\n", ble9.ble9_version.version_hash );
        log_printf( &logger, "------------------------\r\n" );
    }
    
    log_printf( &logger, "Creating advertising point...\r\n" );
    Delay_ms ( 100 );
    ble9_adv_create_id ( &ble9 );

    log_printf( &logger, "Starting module advertising...\r\n" );
    Delay_ms ( 100 );
    ble9_adv_start ( &ble9, BLE9_ADVERTISER_MODE_DISCOVERABLE_GENERAL, 
                     BLE9_ADVERTISER_MODE_CONNECTABLE_SCANNABLE );

    log_printf( &logger, "The module has been configured.\r\n" );
    Delay_ms ( 100 );
}

void application_task ( void )
{
    ble9_process ( &ble9 );
    if ( app_buf_len > 0 ) 
    {
        for ( uint16_t cnt = 0; cnt < app_buf_len; cnt++ )
        {
            log_printf( &logger, "%.2X ", ( uint16_t ) app_buf[ cnt ] );
        }
        ble9_clear_app_buf( );
    }
}

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 ble9_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static err_t ble9_process ( ble9_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t rx_size = 0;
    rx_size = ble9_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
    if ( rx_size > 0 ) 
    {
        int32_t buf_cnt = app_buf_len;
        if ( ( ( app_buf_len + rx_size ) > PROCESS_BUFFER_SIZE ) && ( app_buf_len > 0 ) ) 
        {
            buf_cnt = PROCESS_BUFFER_SIZE - ( ( app_buf_len + rx_size ) - PROCESS_BUFFER_SIZE );
            memmove ( app_buf, &app_buf[ PROCESS_BUFFER_SIZE - buf_cnt ], buf_cnt );
        }
        for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] ) 
            {
                app_buf[ buf_cnt++ ] = rx_buf[ rx_cnt ];
                if ( app_buf_len < PROCESS_BUFFER_SIZE )
                {
                    app_buf_len++;
                }
            }
        }
        return BLE9_OK;
    }
    return BLE9_ERROR;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.