BLE 10 click
BLE 10 Click is a compact add-on board that provides BT/BLE connectivity for any embedded application. This board features the PAN1780-AT, a Bluetooth® 5 Low Energy Module based on Nordic's nRF52840 single-chip controller from Panasonic.
click Product page
Click library
- Author : Stefan Filipovic
- Date : Sep 2021.
- Type : UART type
Software Support
We provide a library for the BLE10 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 BLE10 Click driver.
Standard key functions :
ble10_cfg_setup
Config Object Initialization function.
void ble10_cfg_setup(ble10_cfg_t *cfg)
BLE 10 configuration object setup function.
BLE 10 Click configuration object.
Definition ble10.h:147
ble10_init
Initialization function.
err_t ble10_init(ble10_t *ctx, ble10_cfg_t *cfg)
BLE 10 initialization function.
BLE 10 Click context object.
Definition ble10.h:123
ble10_default_cfg
Click Default Configuration function.
void ble10_default_cfg(ble10_t *ctx)
BLE 10 default configuration function.
Example key functions :
ble10_set_device_name
This function sets the local device name.
err_t ble10_set_device_name(ble10_t *ctx, char *dev_name)
BLE 10 set local device name function.
ble10_factory_reset
This function factory resets the device.
err_t ble10_factory_reset(ble10_t *ctx)
BLE 10 factory reset function.
ble10_get_temperature
This function executes get temperature command which returns the current temperature of the module's internal temperature sensor.
err_t ble10_get_temperature(ble10_t *ctx)
BLE 10 get temperature function.
Example Description
This example reads and processes data from BLE 10 clicks.
The demo application is composed of two sections :
Application Init
Initializes the driver, then performs a factory reset and sets the local device name.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
err_t init_flag =
ble10_init( &ble10, &ble10_cfg );
if ( UART_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
ble10_process( );
ble10_clear_app_buf( );
app_buf_len = 0;
app_buf_cnt = 0;
log_printf( &logger, " - Factory Reset -\r\n" );
log_printf( &logger, " - Set Device Name -\r\n" );
log_info( &logger, " Application Task " );
}
#define BLE10_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition ble10.h:106
#define EVT_RESET
Definition main.c:47
void application_init(void)
Definition main.c:100
#define DEVICE_NAME
Definition main.c:51
#define RSP_OK
Definition main.c:44
Application Task
Logs all the received events/responses on the USB UART. Then checks if there's a specific command string (defined by the GET_TEMP_COMMAND macro) received from the GATT Server, and if so, it executes temperature reading command and logs the results.
{
ble10_process( );
if ( app_buf_len > 0 )
{
Delay_ms ( 100 );
ble10_process( );
for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
{
log_printf( &logger, "%c", app_buf[ buf_cnt ] );
}
{
const char * __generic msg_ptr = strrchr ( app_buf, ',' ) + 1;
uint8_t msg_len = *( msg_ptr - 2 ) - 48;
if ( msg_len == strlen ( get_temp_cmd ) )
{
char get_temp_hex[ 64 ] = { 0 };
uint8_t get_temp_hex_chr[ 3 ] = { 0 };
uint8_t cnt = 0;
for ( cnt = 0; cnt < strlen ( get_temp_cmd ); cnt++ )
{
uint8_to_hex ( get_temp_cmd[ cnt ], get_temp_hex_chr );
strcat ( get_temp_hex, get_temp_hex_chr );
}
if ( 0 == memcmp ( get_temp_hex, msg_ptr, strlen ( get_temp_hex ) ) )
{
ble10_clear_app_buf( );
log_printf( &logger, " - Get Temperature -\r\n" );
}
}
}
ble10_clear_app_buf( );
}
Delay_ms ( 1 );
}
void application_task(void)
Definition main.c:148
#define EVT_GATT_VAL
Definition main.c:48
#define GET_TEMP_COMMAND
Definition main.c:55
Note
We have used the nRF Connect smartphone application for the test. Make sure to configure the GATT Server properly in the nRF Connect application, then you will be able to send a desired command from it, once you connect to the click board. You can use the Sample configuration for GATT Server which comes with the application installation and then send a command via Test Service from the Server.
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.BLE10
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.