Skip to content

Active Scanner Demonstration Example #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
334 changes: 334 additions & 0 deletions connectivity/active_scanner_sample_code/.cproject

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions connectivity/active_scanner_sample_code/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>active_scanner_sample_code</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>sdk</name>
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
</link>
<link>
<name>startup</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/startup</locationURI>
</link>
<link>
<name>sdk/FreeRTOS</name>
<type>2</type>
<locationURI>SDKROOT/sdk/free_rtos</locationURI>
</link>
<link>
<name>sdk/adapters</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/adapters</locationURI>
</link>
<link>
<name>sdk/ble</name>
<type>2</type>
<locationURI>SDKROOT/sdk/interfaces/ble</locationURI>
</link>
<link>
<name>sdk/bsp_include</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/include</locationURI>
</link>
<link>
<name>sdk/cli</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/cli</locationURI>
</link>
<link>
<name>sdk/config</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/config</locationURI>
</link>
<link>
<name>sdk/console</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/console</locationURI>
</link>
<link>
<name>sdk/intrinsic</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/intrinsic</locationURI>
</link>
<link>
<name>sdk/ldscripts</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/ldscripts/ble_projects</locationURI>
</link>
<link>
<name>sdk/memory</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/memory</locationURI>
</link>
<link>
<name>sdk/middleware_config</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/config</locationURI>
</link>
<link>
<name>sdk/osal</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/osal</locationURI>
</link>
<link>
<name>sdk/peripherals</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/peripherals</locationURI>
</link>
<link>
<name>sdk/sys_man</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/system/sys_man</locationURI>
</link>
<link>
<name>sdk/util</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/util</locationURI>
</link>
</linkedResources>
<variableList>
<variable>
<name>SDKROOT</name>
<value>$%7BWORKSPACE_LOC%7D</value>
</variable>
</variableList>
</projectDescription>
32 changes: 32 additions & 0 deletions connectivity/active_scanner_sample_code/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Active Scanner Demonstration Example

This example demonstrating setting up the Bluetooth controller in central role. Active scanning can be initiated through the serial console. Once the active scanning session times out, scanning is allowed to be re-initiated. If logging is enabled (enabled by default) each device scanned along with its advertising data are displayed on the serial console.

## HW and SW Configuration

- **Hardware Configuration**
- This example runs on the DA1459x family of devices.
- A [Pro Development Kit](https://www.renesas.com/us/en/products/wireless-connectivity/bluetooth-low-energy/da14592-016fdevkt-p-smartbond-da14592-bluetooth-low-energy-52-soc-development-kit-pro) (DevKit) is needed for this example.
- **Software Configuration**
- Download the latest [SDK](https://www.renesas.com/us/en/products/wireless-connectivity/bluetooth-low-energy/da14592-smartbond-multi-core-bluetooth-le-52-soc-embedded-flash?gad_source=1) version for the target family of devices.

- SEGGER J-Link tools are normally downloaded and installed as part of the [e2 Studio](https://www.renesas.com/us/en/software-tool/smartbond-development-tools) installation.

## How to run the example

### Initial Setup

- Download the source code from [GitHub](https://github.com/dialog-semiconductor/BLE_SDK10_DA1459x_examples).
- Import the project into your workspace (there should be no path dependencies). If you are not familiar with these processes it's advised that you first familiarize yourself with the [Getting Started](https://lpccs-docs.renesas.com/um-b-166-da1459x_getting_started/index.html) guide.
- Connect the target device to your host PC via USB1. The mentioned port is used to power the device and to support serial and JTAG interfaces. These two interfaces can be used both for flashing and debugging purposes.
- Compile the source code (either in Release or Debug mode) and flash it into the chip. Please note that the debug flavor should be used merely for debugging purposes since it should increase the generated binary file, significantly. In addition, the source code is built to work with the embedded flash Working with external flash memory devices is out of the scope of this demonstration example.
- Open a serial terminal (115200/8-N-1).
- Once the application image is flashed, press the RESET button on the daughter board to start executing the application.

- The terminal should display the random address generated for device.

- Scanning can be initiated by typing `active_scanner_start`. If the command is typed correctly, all scanned devices along with their data should be displayed.

## Known Limitations

There should be no known limitations for this example.
102 changes: 102 additions & 0 deletions connectivity/active_scanner_sample_code/config/custom_config_eflash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
****************************************************************************************
*
* @file custom_config_eflash.h
*
* @brief Board Support Package. User Configuration file for cached eFLASH mode.
*
* Copyright (C) 2020-2024 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/
#ifndef CUSTOM_CONFIG_EFLASH_H_
#define CUSTOM_CONFIG_EFLASH_H_

#include "bsp_definitions.h"

#define CONFIG_USE_BLE

#define CONFIG_RETARGET
#define DBG_LOG_ENABLE ( 1 )
#define GENERATE_RANDOM_DEVICE_ADDRESS ( 1 )

#define dg_configUSE_CLI ( 1 )
#define dg_configUSE_CONSOLE ( 1 )
#define dg_configUART_ADAPTER ( 1 )

/*************************************************************************************************\
* System configuration
*/
#define dg_configEXEC_MODE ( MODE_IS_CACHED )
#define dg_configCODE_LOCATION ( NON_VOLATILE_IS_EMBEDDED_FLASH )

#define dg_configUSE_WDOG ( 1 )
#define dg_configUSE_SW_CURSOR ( 1 )

/*************************************************************************************************\
* FreeRTOS configuration
*/
#define OS_FREERTOS /* Define this to use FreeRTOS */
#define configTOTAL_HEAP_SIZE ( 24000 ) /* FreeRTOS Total Heap Size */

/*************************************************************************************************\
* Peripherals configuration
*/
#define dg_configFLASH_ADAPTER ( 1 )
#define dg_configNVMS_ADAPTER ( 1 )
#define dg_configNVMS_VES ( 0 )
#define dg_configNVPARAM_ADAPTER ( 1 )

/*************************************************************************************************\
* BLE configuration
*/
#define CONFIG_USE_BLE_SERVICES

/* Default connection parameter */
#define defaultBLE_PPCP_INTERVAL_MIN (BLE_CONN_INTERVAL_FROM_MS(15))
#define defaultBLE_PPCP_INTERVAL_MAX (BLE_CONN_INTERVAL_FROM_MS(15))
#define defaultBLE_PPCP_SLAVE_LATENCY (0) // 0 events
#define defaultBLE_PPCP_SUP_TIMEOUT (BLE_SUPERVISION_TMO_FROM_MS(1000))

/*
* Min. connection event length decides number of packets per connection.
* Increasing this value will increase throughput if device is master.
*/
#define defaultBLE_CONN_EVENT_LENGTH_MIN BLE_CONN_EVENT_LENGTH_FROM_MS(10)

/*************************************************************************************************\
* BLE configuration
*/
#define dg_configBLE_PERIPHERAL ( 0 )
#define dg_configBLE_GATT_SERVER ( 0 )
#define dg_configBLE_OBSERVER ( 0 )
#define dg_configBLE_BROADCASTER ( 0 )
#define dg_configBLE_L2CAP_COC ( 0 )

/* Include bsp default values */
#include "bsp_defaults.h"
/* Include middleware default values */
#include "middleware_defaults.h"

#endif /* CUSTOM_CONFIG_EFLASH_H_ */
11 changes: 11 additions & 0 deletions connectivity/active_scanner_sample_code/makefile.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LDSCRIPT_PATH=../ldscripts

.PHONY: main-build pre-build generate_ldscripts FORCE
main-build : | pre-build

FORCE:

generate_ldscripts : mem.ld sections.ld

%.ld : $(LDSCRIPT_PATH)/%.ld.h FORCE
"$(CC)" -I "$(BSP_CONFIG_DIR)" -I "$(MIDDLEWARE_CONFIG_DIR)" $(PRE_BUILD_EXTRA_DEFS) -include "$(APP_CONFIG_H)" $(LD_DEFS) -Ddg_configDEVICE=$(DEVICE) -Ddg_configBLACK_ORCA_IC_REV=BLACK_ORCA_IC_REV_$(IC_REV) -Ddg_configBLACK_ORCA_IC_STEP=BLACK_ORCA_IC_STEP_$(IC_STEP) -E -P -c "$<" -o "$@"
80 changes: 80 additions & 0 deletions connectivity/active_scanner_sample_code/misc/misc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
****************************************************************************************
*
* @file misc.h
*
* @brief Miscellaneous functionality
*
* Copyright (C) 2015-2024 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/

#ifndef MISC_H_
#define MISC_H_

#include <stdio.h>
#include "hw_gpio.h"

/*********************************************************************
*
* Defines
*
*********************************************************************
*/
#define KiB 1024

#if DBG_LOG_ENABLE
#define DBG_LOG(_f, args...) printf((_f), ## args)
#else
#define DBG_LOG(_f, args...)
#endif /* DBG_LOG_ENABLE */

#if DBG_IO_ENABLE
#define DBG_IO_ON(_port, _pin) \
{ \
hw_sys_pd_com_enable(); \
hw_gpio_set_pin_function((_port), (_pin), HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO); \
hw_gpio_set_active((_port), (_pin)); \
hw_gpio_pad_latch_enable((_port), (_pin)); \
hw_gpio_pad_latch_disable((_port), (_pin)); \
hw_sys_pd_com_disable(); \
}

#define DBG_IO_OFF(_port, _pin) \
{ \
hw_sys_pd_com_enable(); \
hw_gpio_set_pin_function((_port), (_pin), HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO); \
hw_gpio_set_inactive((_port), (_pin)); \
hw_gpio_pad_latch_enable((_port), (_pin)); \
hw_gpio_pad_latch_disable((_port), (_pin)); \
hw_sys_pd_com_disable(); \
}

#else
#define DBG_IO_ON(_port, _pin)
#define DBG_IO_OFF(_port, _pin)
#endif /* DBG_IO_ENABLE */

#endif /* MISC_H_ */
Loading
Loading