TOP Contributors

  1. MIKROE (2659 codes)
  2. Alcides Ramos (356 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136951 times)
  2. FAT32 Library (70063 times)
  3. Network Ethernet Library (56015 times)
  4. USB Device Library (46333 times)
  5. Network WiFi Library (41954 times)
  6. FT800 Library (41265 times)
  7. GSM click (29050 times)
  8. mikroSDK (26474 times)
  9. PID Library (26446 times)
  10. microSD click (25408 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

BT click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.9

mikroSDK Library: 2.0.0.0

Category: BT/BLE

Downloaded: 80 times

Not followed.

License: MIT license  

BT Click is a compact add-on board targeted for applications that require both Bluetooth Smart and Classic connectivity. This board features the BT121, a dual-mode Bluetooth Smart Ready module solution that gives unparalleled flexibility to integrate both Bluetooth Smart and Bluetooth Basic Rate/Enhanced Data Rate (BR/EDR) wireless technologies from Silicon Labs.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "BT click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "BT click" changes.

Do you want to report abuse regarding "BT click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


BT click

BT Click is a compact add-on board targeted for applications that require both Bluetooth Smart and Classic connectivity. This board features the BT121, a dual-mode Bluetooth Smart Ready module solution that gives unparalleled flexibility to integrate both Bluetooth Smart and Bluetooth Basic Rate/Enhanced Data Rate (BR/EDR) wireless technologies from Silicon Labs.

bt_click.png

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jun 2021.
  • Type : UART type

Software Support

We provide a library for the BT 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 BT Click driver.

Standard key functions :

  • bt_cfg_setup Config Object Initialization function.

    void bt_cfg_setup ( bt_cfg_t *cfg );
  • bt_init Initialization function.

    err_t bt_init ( bt_t *ctx, bt_cfg_t *cfg );
  • bt_default_cfg Click Default Configuration function.

    err_t bt_default_cfg ( bt_t *ctx );

Example key functions :

  • bt_set_local_name This function sets the local name of the device.

    err_t bt_set_local_name ( bt_t *ctx, char *name );
  • bt_send_package This function sends a data package to the click board.

    err_t bt_send_package ( bt_t *ctx, bt_package_t pkg );
  • bt_read_package This function waits for the command or event type of message to arrive and then reads the complete message and stores it to pkg structure.

    err_t bt_read_package ( bt_t *ctx, bt_package_t *pkg );

Example Description

This example demonstrates the use of BT click board.

The demo application is composed of two sections :

Application Init

Initializes the driver and configures the click board.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    bt_cfg_t bt_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 );
    Delay_ms ( 100 );
    log_info( &logger, " Application Init " );

    // Click initialization.

    bt_cfg_setup( &bt_cfg );
    BT_MAP_MIKROBUS( bt_cfg, MIKROBUS_1 );
    err_t init_flag  = bt_init( &bt, &bt_cfg );
    if ( UART_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    log_printf( &logger, " Default Config : %s\r\n\n", ( char * )
                         ( BT_OK == bt_default_cfg ( &bt ) ? "OK" : "FAIL" ) );

    log_printf( &logger, " Set Local Name : %s\r\n\n", ( char * )
                        ( BT_OK == bt_set_local_name ( &bt, "MikroE - BT click" ) ? "OK" : "FAIL" ) );

    log_printf( &logger, " Delete Bondings : %s\r\n\n", ( char * )
                        ( BT_OK == bt_delete_bondings ( &bt ) ? "OK" : "FAIL" ) );

    log_printf( &logger, " Set Bondable Mode : %s\r\n\n", ( char * )
                        ( BT_OK == bt_set_bondable_mode ( &bt, BT_SM_SET_BONDABLE_ALLOWED ) ? "OK" : "FAIL" ) );

    log_printf( &logger, " Set GAP Mode : %s\r\n\n", ( char * )
                        ( BT_OK == bt_set_gap_mode ( &bt, BT_GAP_MODE_CONNECTABLE, 
                                                          BT_GAP_MODE_DISCOVERABLE, 
                                                          BT_GAP_MODE_NOT_LIMITED ) ? "OK" : "FAIL" ) );

    log_printf( &logger, " RFCOMM Start Server : %s\r\n\n", ( char * )
                        ( BT_OK == bt_rfcomm_start_server ( &bt, BT_RFCOMM_SERVER_DEF_SDP_ID, 
                                                                 BT_RFCOMM_SERVER_DEF_STREAM_DEST ) ? "OK" : "FAIL" ) );

    log_info( &logger, " Application Task " );
}

Application Task

Handles most of the events required for this example, the packages of events not supported in this example will be just displayed on the USB UART. The event handler will display all messages sent from the remote device on the USB UART and send back the predefined response message "DONE". There are two specific commands which can be sent from the remote device: "led blink" - calls bt_led_blink function for a 5 seconds time period. "check buttons" - calls bt_check_buttons function.


void application_task ( void )
{
    bt_event_handler( &bt );
}

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.

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.BT

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.


ALSO FROM THIS AUTHOR

Remote Temp click

0

Remote Temp Click is a temperature sensing Click board™, which features the EMC1833 from Microchip, a specifically designed IC, capable of measuring remote temperature. This option makes Remote Temp click well-suited for monitoring the temperature of a CPU, GPU or FPGA, where the BJT model junction can be a substrate PNP or NPN.

[Learn More]

Thermo K 3 click

0

Thermo K 3 Click is a compact add-on board that provides accurate temperature measurements with a thermocouple probe. This board features the MAX6675, a cold-junction-compensated K-thermocouple-to-digital converter from Analog Devices. With the versatile type-K probe, this board enables precise temperature measurements of up to +700°C in 12-bit (0.25°C) resolution. This board can measure temperatures as high as +1024°C but with less precision. It features cold-junction compensation sensing and correction and open thermocouple detection.

[Learn More]

Secure 3 click

1

Secure 3 click carries the ATSHA204A, a cryptographic coprocessor with secure hardware-based key storage from Microchip. The click is designed to run on either 3.3V or 5V power supply. Secure 3 click communicates with the target microcontroller over an I2C interface.

[Learn More]