This example demonstrates the implementation of a dynamic BLE Beacon that keeps changing its advertisement data based on either a Timer interrupt or a GPIO Button Press.
The project instantiates a BLE Broadcaster that advertises in Non-Connectable High Duty Cycle ADV mode. The device name is continuously updated in firmware to demonstrate dynamic advertisement payload update feature, every 10 seconds by means of a timer. In addition to this, the device name may be updated instantaneously by a GPIO Button press. The advertisement timeout is set to be infinite and the advertisement interval is set to 100 mS.
Programming Language: C
Associated Parts: CYW20706
Related Hardware: BCM920706V2_EVAL Board
Figure 1: Block Diagram
Figure 2: Firmware Flow
- APPLICATION_START is the program entry point. Here the peripheral UART is set for displaying Debug Messages. The BT Stack and the corresponding management callback are started using the wiced_bt_stack_init () API.
- (): This function handles the events generated for the BLE Stack.
The BTM_ENABLED_EVT indicated that the stack is turned ON. Upon the reception of this event, we start the Non Connectable High Duty Cycle advertisement. The Timer and GPIO Interrupts are registered. The Timer and GPIO Button Press Interrupt callbacks increment the suffix in the Device Name by 1 and then continues the advertisement with the incremented name.
Programming and Testing:
- Install the WICED Studio 4.0 (or above) in your PC. Plug in your BCM920706_EVAL Board and let the drivers bind to the device. Make sure the jumpers are in place. Open WICED Studio and set the platform as 20706-A2_Bluetooth. For more details, please refer WICED-20706-BT-Quick-Start-Guide present in Doc folder in the project explorer.
- Copy the Dynamic_Broadcaster folder from the BCM920706_EVAL Board package. In the WICED Studio, right-click the Apps folder in the Project Explorer pane and click Paste. You can see the Dynamic_Broadcaster folder under the Apps folder.
- Create a Make Target for the project by selecting Project -> Make Target -> Create. Paste the following as the entry in the Target Name field: "Dynamic_Broadcaster-BCM920706_P49 download". Make sure that the Same as the Target Name checkbox is checked. Click OK.
- Open a Serial Terminal (Example: Teraterm or Coolterm), and bind it to the COM Port of the device, that has the bigger port number. The COM Port with the bigger number corresponds to the PUART that displays Debug Messages. The one with the smaller number corresponds to the HCI UART. The BaudRate is set to 115200 in the firmware. Make sure the BaudRate in serial terminal is also set to 115200.
- Double click the Target you just created, shown in the Make Target Pane on the right. You can see the program being built and downloaded into the board. (For more details or troubleshooting, please refer the WICED-20706-BT-Quick-Start-Guide)
- Once the downloading is finished, you will be able to see the logs in the Serial Terminal as shown below:
7) The device has started advertising with the initial device name “DB App 0”. This can be noticed by means of any BLE Scanner.
Note: Cypress provides separate BLE Scanner Applications for Windows Environment, Android Phone and iOS Devices. They are present in Project Explorer ->20706-A2_Bluetooth -> Apps -> hello_sensor -> Peerapps. The below screenshot is obtained from the LeHelloClient App for Android.
8. You can notice that for every 10 seconds the name of the device gets incremented as ”DB App 1”, “DB App 2”, “DB App 3” and so on, by means of the timer interrupt in the firmware. This change in the device name can be noticed in the Scanner application by restarting the scanning.
9.The device name can also be incremented instantaneously by pressing the SW6 (BTN1) in the device.
Table1 lists all relevant application notes, code examples, knowledge base articles, device datasheets, and Component / user module datasheets.
Table 1: Related Documents
AN218191 - WICED™ Quick Start Guide for BT CYW20706
The Quick Start Guide can be accessed from Project Explorer -> 20706-A2_Bluetooth -> Doc
AN216535 - CYW92070xV3_EVAL Evaluation Board Hardware User Manual
The Hardware User Manual can be accessed from Project Explorer -> 20706-A2_Bluetooth -> Doc