52
APPLICATION NOTE R01AN3017EJ0200 Rev.2.00 Page 1 of 48 Feb 3, 2017 Bluetooth ® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE Introduction This document describes about installation, program structure, and usage information on Bluetooth ® Low Energy (hereafter call BLE) RL78/G1D applications. This BLE application communicates with RenesasBLE software developed in either iOS device or Android device. Two profiles are used in this RL78/G1D application and they are Running Speed and Cadence profile, and Cycling Speed and Cadence profile. Related Documents The documents referred in this document may be preliminary version but might not be marked as such version. Document Document No. Japanese English Bluetooth Low Energy Protocol Stack User’s Manual R01UW0095J R01UW0095E API Reference Manual Basic R01UW0088J R01UW0088E API Reference Manual of CSCP R01UW0098J R01UW0098E API Reference Manual of RSCP R01UW0107J R01UW0107E rBLE Command Specification R01AN1376J R01AN1376E Quick Start R01AN2767J R01AN2767E RenesasBLE(For Android) Application R01AN3015J R01AN3015E RenesasBLE(For iOS) Application R01AN3016J R01AN3016E RL78/G1D applications to communicate with RenesasBLE R01AN3017J This Document RL78 Family EEPROM Emulation Library Pack02 User's Manual R01US0068J R01US0068E R01AN3017EJ0200 Rev.2.00 Feb 3, 2017

Bluetooth Low Energy Protocol Stack RL78/G1D applications

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

APPLICATION NOTE

R01AN3017EJ0200 Rev.2.00 Page 1 of 48 Feb 3, 2017

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE Introduction This document describes about installation, program structure, and usage information on Bluetooth® Low Energy (hereafter call BLE) RL78/G1D applications. This BLE application communicates with RenesasBLE software developed in either iOS device or Android device. Two profiles are used in this RL78/G1D application and they are Running Speed and Cadence profile, and Cycling Speed and Cadence profile.

Related Documents The documents referred in this document may be preliminary version but might not be marked as such version.

Document Document No. Japanese English

Bluetooth Low Energy Protocol Stack User’s Manual R01UW0095J R01UW0095E

API Reference Manual Basic R01UW0088J R01UW0088E API Reference Manual of CSCP R01UW0098J R01UW0098E API Reference Manual of RSCP R01UW0107J R01UW0107E rBLE Command Specification R01AN1376J R01AN1376E Quick Start R01AN2767J R01AN2767E RenesasBLE(For Android) Application R01AN3015J R01AN3015E RenesasBLE(For iOS) Application R01AN3016J R01AN3016E RL78/G1D applications to communicate with RenesasBLE

R01AN3017J This Document

RL78 Family EEPROM Emulation Library Pack02 User's Manual R01US0068J R01US0068E

R01AN3017EJ0200 Rev.2.00

Feb 3, 2017

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 2 of 48 Feb 3, 2017

Explanation of Acronyms / Abbreviations and Terms Acronyms /

Abbreviation Expansion

Note

ANP Alert Notification Profile ANS Alert Notification Service API Application Programming Interface ATT Attribute Protocol BAS Battery Service BB Base Band BD_ADDR Bluetooth Device Address BLE Bluetooth low energy BLP Blood Pressure Profile BLS Blood Pressure Service CPP Cycling Power Profile CPS Cycling Power Service CSCP Cycling Speed and Cadence Profile CSCS Cycling Speed and Cadence Service CSRK Connection Signature Resolving Key CTS Current Time Service DIS Device Information Service EDIV Encrypted Diversifier FMP Find Me Profile GAP Generic Access Profile GATT Generic Attribute Profile GLP Glucose Profile GLS Glucose Service HCI Host Controller Interface HID Human Interface Device HIDS HID Service HOGP HID over GATT Profile HRP Heart Rate Profile HRS Heart Rate Service HTP Health Thermometer Profile HTS Health Thermometer Service IAS Immediate Alert Service IRK Identity Resolving Key

L2CAP Logical Link Control and Adaptation Protocol

LE Low Energy LL Link Layer LLS Link Loss Service LNP Location and Navigation Profile LNS Location and Navigation Service LTK Long Term Key MCU Micro Controller Unit MITM Man-in-the-middle MTU Maximum Transmission Unit OOB Out of Band OS Operating System PASP Phone Alert Status Profile PASS Phone Alert Status Service PXP Proximity Profile

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 3 of 48 Feb 3, 2017

RF Radio Frequency RSCP Running Speed and Cadence Profile RSCS Running Speed and Cadence Service RSSI Received Signal Strength Indication ScPP Scan Parameters Profile ScPS Scan Parameters Service SM Security Manager SMP Security Manager Protocol STK Short Term Key TK Temporary Key TPS Tx Power Service

UART Universal Asynchronous Receiver Transmitter

UUID Universal Unique Identifier APP Application CSI Clocked Serial Interface IIC Inter-Integrated Circuit

RSCIP Renesas Serial Communication Interface Protocol

VS Vendor Specific

Term Description Note RenesasBLE Smart Phone Demo Application

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 4 of 48 Feb 3, 2017

Contents

1. Overview .......................................................................................................................... 6

2. Apply ................................................................................................................................ 6

3. Installation ........................................................................................................................ 6 3.1 Contents ........................................................................................................................................ 6 3.2 Installation Instructions .................................................................................................................. 6

3.2.1 Decompress the Zip file .......................................................................................................... 6 3.2.2 How to get a library ................................................................................................................. 7 3.2.3 Copy of the library and related files ........................................................................................ 7

3.3 Build the project ............................................................................................................................ 9

4. Operation Overview ........................................................................................................ 10

5. Program Configuration ................................................................................................... 11 5.1 Operating and Developing Environment ..................................................................................... 11 5.2 Module Configuration .................................................................................................................. 12 5.3 State Transition Diagram ............................................................................................................ 12 5.4 Process ....................................................................................................................................... 13

5.4.1 Initialize ................................................................................................................................. 13 5.4.2 Advertising ............................................................................................................................ 15 5.4.3 Bonding ................................................................................................................................. 17 5.4.4 Ready .................................................................................................................................... 19 5.4.5 Notifying ................................................................................................................................ 21

5.5 I/O Interface................................................................................................................................. 22 5.5.1 LED ....................................................................................................................................... 22 5.5.2 Push Switch .......................................................................................................................... 22 5.5.3 DIP Switch ............................................................................................................................. 23 5.5.4 Save the Pairing information to data Flash ........................................................................... 23

6. API Overview ................................................................................................................. 24 6.1 Files ............................................................................................................................................. 24 6.2 Module List .................................................................................................................................. 26 6.3 Macro List .................................................................................................................................... 26 6.4 DemoApp .................................................................................................................................... 27

6.4.1 Overview ............................................................................................................................... 27 6.4.2 API List .................................................................................................................................. 27 6.4.3 API ........................................................................................................................................ 28

6.5 Cycling Custom Profile ................................................................................................................ 37 6.5.1 Overview ............................................................................................................................... 37 6.5.2 API List .................................................................................................................................. 37 6.5.3 API ........................................................................................................................................ 38

6.6 Running Custom Profile .............................................................................................................. 40 6.6.1 Overview ............................................................................................................................... 40 6.6.2 API List .................................................................................................................................. 40 6.6.3 API ........................................................................................................................................ 41

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 5 of 48 Feb 3, 2017

7. Adding Custom Profile .................................................................................................... 43 7.1 Defining Service .......................................................................................................................... 43 7.2 Implementing Profile ................................................................................................................... 46 7.3 Enabling Profile ........................................................................................................................... 46

8. Bibliography ................................................................................................................... 47

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 6 of 48 Feb 3, 2017

1. Overview This manual describes about installation and configuration of the Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE and explains on how to use this application. To demonstrate the application, use Evaluation Kit hardware and smartphone like iPhone or Android device.

2. Apply To demonstrate this application, program BLE Protocol stack in RL78/G1D (RTK0EN0001D01001BZ) evaluation board and install Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE application in any iPhone or Android device. This manual can be applied to the evaluation on RL78/G1D evaluation board and smartphone device for Bluetooth Low Energy communication.

3. Installation This application is delivered as ZIP file, which includes this application note and sample code.

3.1 Contents The delivered ZIP file includes following:

Document • Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

APPLICATION NOTE (This document) File set for Executable –file creation

• Program source files • Project file for CS+ for CA,CX • Project file for CS+ for CC • Project file for e2 studio • Project file for IAR Embedded Workbench V2

3.2 Installation Instructions

3.2.1 Decompress the Zip file Copy delivered ZIP file to intended empty folder and then decompress the zip file. Refer to "6.1Files" about decompressed file organization.

When using e2 studio as a development environment, don't include the multi byte character (double-byte character) and a blank space to the folder, which develops and a folder pass. For example, if the folder name includes the multi byte character and blank space like this “/../Test∆Lab/workspace/My∆Project”, e2 studio IDE could not find correct project folder for building.

Note: ∆ symbol is used as space in abovementioned example.

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 7 of 48 Feb 3, 2017

3.2.2 How to get a library Before making the build this sample program, it is necessary to download the following library from Renesas Web site.

Bluetooth Low Energy Protocol Stack V1.20. Download the Renesas BLE software package from below link.

https://www.renesas.com/software-tool/bluetooth-low-energy-protocol-stack-rl78-family

RL78 Family EEPROM Emulation Library Pack02

https://www.renesas.com/software-tool/data-flash-libraries

Download the following package.

EEPROM Emulation Library Pack02 Package Ver.2.00(for CA78K0R/CC-RL Compiler) for RL78 Family

For the library for IAR, select "America/Europe/Middle East/Africa" when you run the installer. The Library version select "IAR compiler version 2.10".

3.2.3 Copy of the library and related files Copy libraries and related files to be used into the Development environment folder.

Use CS+ for CC /e2 studio(CC-RL) version

Bluetooth Low Energy Protocol Stack V1.20

(Destination folder)/workspace/renesas/lib

- BLE_CONTROLLER_LIB_CCRL.lib - BLE_HOST_lib_CCRL.lib - BLE_PROFILE_CSP_LIB_CCRL.lib - BLE_PROFILE_RSP_LIB_CCRL.lib - BLE_PROFILES_COMMON_LIB_CCRL.lib - BLE_rBLE_lib_CCRL.lib

EEPROM Emulation Library Pack02 for CC0RL Compiler for RL78 Family, Japan Release

(Destination folder)/workspace/renesas/src/driver/dataflash/cc_rl

- eel.h - eel.lib - eel_types.h - fdl.h - fdl.lib - fdl_types.h

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 8 of 48 Feb 3, 2017

Use CS+ for CA,CX version

Bluetooth Low Energy Protocol Stack V1.20

(Destination folder)/workspace/renesas/lib

- BLE_CONTROLLER_LIB.lib - BLE_HOST_lib.lib - BLE_PROFILE_CSP_LIB.lib - BLE_PROFILE_RSP_LIB.lib - BLE_PROFILES_COMMON_LIB.lib - BLE_rBLE_lib.lib

EEPROM Emulation Library Pack02 for the CA78K0R Compiler for RL78 Family, Japan Release

(Destination folder)/workspace/renesas/src/driver/dataflash/cs

- eel.h - eel.lib - eel_types.h - fdl.h - fdl.lib - fdl_types.h

Use IAR Embedded Workbench V2 version

Bluetooth Low Energy Protocol Stack V1.20

(Destination folder)/workspace/renesas/lib

- BLE_CONTROLLER_lib.a - BLE_HOST_lib.a - BLE_PROFILE_CSP_lib.a - BLE_PROFILE_RSP_lib.a - BLE_PROFILES_COMMON_lib.a - BLE_rBLE_lib.a

EEPROM Emulation Library Pack02 for IAR Compiler

(Destination forler)/workspace/renesas/src/driver/dataflash/iar_v2

- eel.h - eel.a - eel_types.h - fdl.h - fdl.a - fdl_types.h

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 9 of 48 Feb 3, 2017

3.3 Build the project To build the project, follow the below instructions and get execution file.

1. Open the project file, starts the development environment by double-clicking the project file as a CS+ development environment using one of the CC, CX, and CA compiler, or IAR Embedded Workbench V2 for IAR compiler When using e2 studio, launch the environment and import an existing project file into the workspace. (Destination folder)/workspace/renesas/tools/project

Table 3-1 show the list of compilers to select the respective development environment.

Table 3-1 Development environment / Project file

Note: (*1) e2 studio is necessary to import the project file into workspace.

2. To build the project,

a. CS+ environment : build project from the "build" menu b. e2 studio environment : build project from the Project menu. c. IAR Embedded Workbench : "Make" from the "Project" menu.

3. After completing the project build successfully, executable file will be generated into folder shown in Table 3-1.

Development environment Project file / Workspace file Execution file

generation folder CS+ for CC (CC-RL)

workspace/renesas/tools/project/CS_CCRL/BLE_Demo/ BLE_Demo.mtpj

BLE_Demo/rBLE_Emb/DefaultBuild

CS+ for CA, CX (CA78K0R)

workspace/renesas/tools/project/CubeSuite/BLE_Demo/ BLE_Demo.mtpj

BLE_Demo/BLE_Emb/DefaultBuild

e2 studio(CC-RL)

workspace/renesas/tools/project/e2studio/BLE_Demo(*1)

BLE_Demo/rBLE_Emb/DefaultBuild

IAR Embedded Workbench V2

workspace/renesas/tools/project/iar_v2/BLE_Demo/ BLE_Demo.eww

For Debug : BLE_Demo/BLE_Demo/Debug For Release : BLE_Demo/BLE_Demo/Release

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 10 of 48 Feb 3, 2017

4. Operation Overview In this demonstration, for peripheral device, use the Evaluation Kit programmed with two profiles act as a sensor, and for central device, use smartphone, which preinstalled with RenesasBLE application. The smartphone will display sensor’s values. Since there are two profiles in this demo, Evaluation Kit is needed to configure either Running Speed and Cadence profile, or Cycling Speed and Cadence profile through DIP Switch SW6 position 1. To select Running Speed and Cadence profile, turn ON DIP Switch SW6 position 1. If turns OFF to DIP Switch SW6 position 1, set as Cycling Speed and Cadence profile. In addition, setting DIP Switch SW6 position 4 to ON will configure as encryption mode. Before power ON, set DIP Switch SW6 for desire configuration. Four LEDs are used to indicate the status of this application. LED1 will blink while not connecting to smartphone. After successfully connected, turn ON the LED1 and the Evaluation Kit start acting as a sensor. After the devices are successful paring, LED2 turns ON. The LED3 is ON when the encryption option is set. When LED4 turns ON, Running Speed and Cadence profile is selected. Alternatively, it turns OFF while selecting Cycling Speed and Cadence profile. Turn on the power to the evaluation kit will automatically start advertise and the Central device can search to this Peripheral device. Then try to establish connection and pairing. When pairing is succeeded, the Evaluation Kit will send the measured value every second to smartphone (central device). Then, smartphone displays measured values. By pressing the switch SW2, increase the measured value as number of steps for Running Speed and Cadence profile setting, and wheel rotational speed for Cycling Speed and Cadence profile setting. The various measurements are shown in the smartphone Graph so that the graph adjusts its display scaled to 10 minutes, 1 hour, or day appropriately. In addition, you can set stride-wheel radius in the smartphone by using the custom profile.

Figure 4-1 Operational procedure

1)Configuration

2)Pairing

Pairing procedure implementation

Profile (SW6_1), Set the encryption presence or absence (SW6_4)

3)Operation

By pressing the SW2 The number of steps / rotation speed is simulated

The graph displays the measured value Set the stride / radius

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 11 of 48 Feb 3, 2017

5. Program Configuration This section will explain overview of application, building the projects, and operation in detail.

[NOTE] The programs listed in this application note are for demonstration purpose only and not intended to use for mass production. If use any part of this application in production, be responsible to validation with respect to end-user application.

5.1 Operating and Developing Environment In this demo, the Bluetooth® Low Energy Protocol Stack RL78/G1D applications is developed and tested in below listed environment.

Hardware • RL78/G1D evaluation board (RTK0EN0001D01001BZ)

Smart Phone • iOS iPhone 5s (iOS 8.4) iPad Air(iOS 8.4) iPhone 6 (iOS 10.2) iPad 3rd generation(iOS 9.3.5)

• Android HUAWEI G620S (Android OS 4.4.4) Google Nexus 5 (Android OS 4.4.4) Google Nexus 6 (Android OS 6.0.1) Google Nexus 7 2013 (Android OS 5.1.1) ASUS MeMO Pad7(Android OS 4.4.2) SAMSUNG GALAXY S5(Android OS 4.4.2)

Software • CS+ for CA,CX(V3.01.00) / RL78 Compiler CA78K0R(V1.72) • CS+ for CC(V3.03.00) / RL78 Compiler CC-RL(V1.03.00) • e2 studio (V4.3.0.007) /RL78 Compiler CC-RL(V1.03.00) • IAR Embedded Workbench for Renesas RL78(V2.20.1) • Bluetooth Low Energy Protocol Stack(V1.20)

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 12 of 48 Feb 3, 2017

5.2 Module Configuration The internal structure of Bluetooth® Low Energy Protocol Stack program is shown in Figure 5-1. This demo application has mainly customized to Renesas BLE software (Stack) with two profiles and “DemoApp” section.

rBLE_Core

Profile Layer

Host StackGAP,GATT,SM,L2CAP

RF/BB

Controller StackHCI,LL

RF Driver

RWKE(OS

functions)

RWKE API

rBLE API

DemoApp

Figure 5-1 Internal Structure

5.3 State Transition Diagram Figure 5-2 shows State Transition Diagram of Demo Application (hereafter call DemoApp), and in next section 5.4 Process, detail will be explained using this transition diagram.

Connected

Initialize Advertising

Bonding

Notifying

Ready

Secure

Non-Secure

Finish Bonding

Finish Initial Communication

Disconnect

Connect

Figure 5-2 DemoApp State Transition Diagram

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 13 of 48 Feb 3, 2017

5.4 Process The DemoApp has three states: Initialize State, Advertising State, and Connected State. The following will explain each state in detail.

5.4.1 Initialize To communicate with RenesasBLE, this Bluetooth® Low Energy Protocol Stack RL78/G1D application program starts with main function. Then the program jumps to "arch_main_ent" that initializes heap memory and global variables, RWKE (OS functions), RL78/G1D device peripherals, and then initializes DemoApp application. DemoApp also initializes rBLE API. In case of using secure mode, set security configuration. To transit to Advertising State, call RBLE_GAP_Broadcast_Enable and then perform as BLE Peripheral device (RL78/G1D evaluation board).

In this initialization state, pass argument, RBLE_GAP_SEC1_NOAUTH_PAIR_ENC to RBLE_GAP_Set_Security_Request function as unauthenticated pairing with encryption for security configuration. To enable Bonding, pass argument, RBLE_GAP_BONDABLE to RBLE_GAP_Set_Bonding_Mode function.

Figure 5-3 shows Initialize State sequence for this DemoApp.

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 14 of 48 Feb 3, 2017

Initialize ApplicationDemoApp_Init Initialize Timer, Switch and LED

Select Sensor type

Initialize rBLE APIRBLE_Init

rwble_schedule Notify finish rBLE initializationDemoApp_CallBack

RBLE_GAP_Resetrwble_schedule

DemoApp_GAP_ResetResultCB

RBLE_VS_Flash_Management

rwble_scheduleDemoApp_VS_FlashManagementCompCB

RBLE_VS_Flash_Accessrwble_schedule

DemoApp_VS_FlashAccessCompCB

RBLE_VS_Flash_Managementrwble_schedule

DemoApp_VS_FlashManagementCompCB

RBLE_GAP_Set_Security_Requestrwble_schedule

DemoApp_GAP_SetSecReqCompCBRBLE_GAP_Set_Bonding_Mode

rwble_scheduleDemoApp_GAP_SetBondModeCompCB

RBLE_GAP_Broadcast_Enable

arch_main_ent rBLE APIDemoApp

SW6-4ON

[Secure]

SW6-4ON/OFFCommon

[Pairing information read]

Figure 5-3 Initialize Sequence

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 15 of 48 Feb 3, 2017

5.4.2 Advertising After executing Initialize State, transit to Advertising State, and the Peripheral device (RL78/G1D evaluation board) starts sending the Advertise package periodically. Then, wait for connection from Central device (smartphone). When receive the Connect request from Central device, process connection sequence using rBLE API. When the connection is succeeded with Central device, notify Connect Completion by DemoApp_GAP_ConnectCompCB callback function.

After connecting, enable the profile according to the evaluation board configuration: Switch SW6 position 1. Then complete the activation process and transition to the Ready state.

Advertising State sequence is shown in Figure 5-4.

Send Advertise

Connect RequestNotifiy Connected

DemoApp_GAP_ConnectCompCBSensor Enable

RBLE_RSCP_Sensor_Enable

DemoApp_RSCP_SensorEnableCompCB

DemoApp_RunCustom_Enable

RBLE_GATT_Enable

DemoCustom_RunProfile_EndEnableComplete

RBLE_CSCP_Sensor_Enable

DemoApp_CSCP_SensorEnableCompCB

DemoCustom_CyclProfile_Enable

RBLE_GATT_Enable

DemoCustom_CyclProfile_EndEnableComplete

Peripheral

rBLE APIDemoApp Central

SW6-1ON [RSCP]

[CSCP]SW6-1OFF

Figure 5-4 Advertising Sequence

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 16 of 48 Feb 3, 2017

Before connecting to smartphone, Two different advertising states are used with different advertising interval to save power. The states listed with different advertising periods and its state transitions diagram are shown in Table 5-1 and Figure 5-5 respectively.

Table 5-1 Advertise Status List

No. Status Parameter Period 1 Normal Advertise AdvIntervalMin:30msec

AdvIntervalMax:60msec AdvFiltPolicy:All Allowed

Up to 30 seconds

2 Power Saving Advertise AdvIntervalMin:1000msec AdvIntervalMax:1200msec AdvFiltPolicy: All Allowed

After No.1 unlimited

[1]Normal

Adv

Connected

[2]Power saving

Adv

30 seconds expired

Connect Connect

Disconnect

Power ON

Figure 5-5 Advertise State Transition Diagram

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 17 of 48 Feb 3, 2017

5.4.3 Bonding After connection with the Central, data communication starts immediately from Central. Then Peripheral returns the "Insufficient Authentication Error" to Central (Smartphone) to start bonding sequence.

When Bluetooth stack in rBLE layer receives Bonding Request, This notification request pass DemoApp through using DemoApp_GAP_BondingReqIndCB. Beginning of the Bonding, DemoApp responses the notification to Central via rBLE layer with using RBLE_GAP_Bonding_Response. After that, receive LTK Request from DemoApp_SM_LtkReqIndCB then initialize LTK Key, and response from RBLE_SM_Ltk_Req_Resp to Central.

Bonding is completed, the DemoApp_GAP_BondingCompCB function is called, to begin to save the pairing information. And then transitions to the Ready state.

Bonding State sequence is shown in Figure 5-6.

Data CommunicationInfufficient Authentication Error

Bonding Request

Bonding Request NotificationDemoApp_GAP_BondingReqIndCB

Bonding ResponseRBLE_GAP_Bonding_Response Bonding Response

LTK Request NotificationDemoApp_SM_LtkReqIndCB

LTK ResponseRBLE_SM_Ltk_Req_Resp LTK Response

Key NotificationDemoApp_SM_KeyIndCB

Bonding Complate NotificationDemoApp_GAP_DelFromWhiteListCompCB

[Pairing information write]

RBLE_VS_Flash_ManagementDemoApp_VS_FlashManagementCompCB

RBLE_VS_Flash_AccessDemoApp_VS_FlashAccessCompCB

RBLE_VS_Flash_ManagementDemoApp_VS_FlashManagementCompCB

Peripheral

rBLE APIDemoApp Central

SW6-4ON

IRK rocessing Enable

Figure 5-6 Bonding Sequence

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 18 of 48 Feb 3, 2017

[Note] During the pairing, information is needed to read / write access to Data Flash. If arise the "DF_ERR_POOL_FULL" error at that time of access, use the RBLE_VS_Flash_Operation function and run the cleanup of Data Flash. Then run RBLE_VS_Flash_Access function again to store (read / write) the Pairing information.

RBLE_VS_Flash_ManagementDemoApp_VS_FlashManagementCompCB

RBLE_VS_Flash_AccessDemoApp_VS_FlashAccessCompCB

RBLE_VS_Flash_OperationDemoApp_VS_FlashOperationCompCB

RBLE_VS_Flash_AccessDemoApp_VS_FlashAccessCompCB

RBLE_VS_Flash_ManagementDemoApp_VS_FlashManagementCompCB

Peripheral

rBLE APIDemoApp

[Pairing information read/write]

[DF_ERR_POOL_FULL recovery]

Figure 5-7 Data Flash access recovery process

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 19 of 48 Feb 3, 2017

5.4.4 Ready At Ready State, Peripheral is waiting initial sequence for Central ready. Normally, Central retrieves required Service and Characteristic information (if needed, include Read/Write Characteristic) from Peripheral.

In this application program, the Notify Setting of specific Characteristic of CSCP or RSCP profile is set to enable when transit to Notifying State. If Notify Setting of Measurement is enabled, start enabling the Measurement process. Then send initial Measurement to Central and set periodic timer.

Ready State sequence is shown in Figure 5-8 and Figure 5-9.

Discover Service RequestDiscover Service Response

Discover Characteristic RequestDiscover Characteristic Response

Read Characteristic RequestRead Characteristic Response

Set Characteristic Notify RequestSet Characteristic Notify Response

Set Notify NotificationDemoApp_RSCP_SensorCfgNotifyIndCB

Set Notify NotificationDemoApp_CSCP_SensorCfgNotifyIndCB

Peripheral

rBLE APIDemoApp Central

SW6-1ON [RSCP]

[CSCP]SW6-1OFF

Figure 5-8 Ready Sequence

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 20 of 48 Feb 3, 2017

Enabling MeasurementDemoApp_SendTimer

Send Initial MeasurementRBLE_RSCP_Sensor_Send_Measurements

Send Measurement

Send Initial MeasurementRBLE_CSCP_Sensor_Send_Measurements

Send Measurement

Start Periodic Timerke_timer_set

Peripheral

rBLE APIDemoApp Central

SW6-1ON

[RSCP]

[CSCP]SW6-1OFF

Figure 5-9 Ready Sequence (continued)

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 21 of 48 Feb 3, 2017

5.4.5 Notifying At Notifying State, DemoApp from peripheral device sends measurement periodically to central device. When periodic timer has expired, the DemoApp_SendTimer is called for refreshing timer.

Notifying State sequence is shown in Figure 5-10.

Enabling MeasurementDemoApp_SendTimer

Send Initial MeasurementRBLE_RSCP_Sensor_Send_Measurements

Send Measurement

Send Initial MeasurementRBLE_CSCP_Sensor_Send_Measurements

Send Measurement

Start Periodic Timerke_timer_set

Peripheral

rBLE APIDemoApp Central

SW6-1ON

[RSCP]

[CSCP]SW6-1OFF

Figure 5-10 Notifying Sequence

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 22 of 48 Feb 3, 2017

5.5 I/O Interface 5.5.1 LED There are four LEDs on evaluation board led and the application drives the LEDs with respect to the Table 5-2 description as below to indicate the evaluation board setting as well as the connection status of smartphone.

Table 5-2 Status of the LED lights

LED No. Description

LED1(P120) LED indicating the connection status and smart phones. This LED is not always goes out application running.

Turn ON Status of connection with the smart phone

Blinking During the execution of the advertising. Wait for Smart phone connections.

LED2(P147) Whether the encryption state is the connection of the smart phone.

Turn ON Encryption mode

Turn OFF Non-encryption mode

LED3(P03) Indicates the presence or absence of the encryption settings. With the SW6-4 of the DIPSW.

Turn ON Encryption mode

Turn OFF Non-encryption mode

LED4(P60) Shows the settings of the profile to use. With the SW6-1 of the DIPSW.

Turn ON Use the RSCP

Turn OFF Use the CSCP

5.5.2 Push Switch On the evaluation board, use only SW2 (INTP5) can be detected for HW interrupts. Pressing the SW2 will simulate model behavior after connecting with smart-phone connection for detecting sensor.

Table 5-3 indicates simulated sensor data type with respect to selected profile and explains the type of sending data.

Table 5-3 Behavior of SW2

Profile Simulated sensor data type

RSCP Step data. Press down once to detect as one step.

CSCP Wheel count data. Once pushed to detect as a revolution one.

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 23 of 48 Feb 3, 2017

5.5.3 DIP Switch Dip switch, SW6 on the evaluation board is used to configure on which profile to be work with and whether encryption will be used or not to the evaluation.

Table 5-4 shows SW6 State and evaluation configuration.

Table 5-4 Behavior of SW6

SW6 No. Description

SW6-1(P10) Select of Profile

ON(Right side) RSCP mode

OFF(Left side) CSCP mode

SW6-2(―) Unused

SW6-3(―) Unused

SW6-4(P02) Select of Encryption

ON(Right side) Secure mode

OFF(Left side) Non-secure mode

5.5.4 Save the Pairing information to data Flash Using the EEPROM emulation library Pack02, built with the BLE stack pairing information and store in Data Flash. Data Flash contains LTK information, and run Just Works pairing.

Table 5-5 shows the details of the data stored in the data Flash memory.

Table 5-5 Store data to the data Flash memory

Data ID Data Size Read timing Write timing 0x02(*1) Paring information Copying RAM variables

when the application starts.

If the Pairing information was updated after disconnecting communication device and write the new Pairing information.

Address of the device 6 byte Address type of the device 1 byte Security status 1 byte Local encryption information

30byte(*2)

(*1) Data ID 0x01 is used as ID to save the BD address data on Flash at BLE. (*2) If enable using the USE_DEMO_IRK_EXEC macro, include IRK key 28 bytes; total 58 bytes.

Refer "RL78 family EEPROM emulation library Pack02 user's manual" about How to write the data on Flash using Data Flash driver in the BLE stack for more information.

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 24 of 48 Feb 3, 2017

6. API Overview This chapter will explain mainly on project files structure and usage of APIs for configuring this demo application program. For detail about the BLE software API, refer to Bluetooth Low Energy Protocol Stack API Reference Manual Basic as well as CSCP and RSCP profile documents.

6.1 Files Program source files.

(*) Those added in this application.

bleip Bluetooth directory └─src Source directory ├─common Bluetooth Common directory │ co_bt.h Bluetooth Common definition │ └─rwble BLE directory rwble.h BLE entry point rwble_config.h BLE protocol stack configuration rBLE rBLE directory └─src rBLE source directory ├─demo_app DemoApp(This program) directory(*) │ demo_api_custom.h Custom Profile API(*) │ demo_app.c DemoApp(*) │ demo_app.h DemoApp definition(*) │ demo_console.c DemoApp Console(*) │ demo_console.h DemoApp Console definition(*) │ demo_custom_cycl_profile.c Cycling custom profile implementation(*) │ demo_custom_run_profile.c Running custom profile implementation(*) │ demo_led.c DemoApp LED Control(*) │ demo_led.h DemoApp LED Control definition(*) │ demo_parameter.c DemoApp Parameters(*) │ demo_sw.c DemoApp Switch Control(*) │ demo_sw.h DemoApp Switch Control definition(*) │ ├─include rBLE header directory │ └─sample_app Sample program directory

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 25 of 48 Feb 3, 2017

(*2)This sample application does not include the BLE protocol stack library. Refer to 3.2.2 How to get a library section

for the lib folder. (*3) Those are fixed in this application

renesas ├─config Link configuration directory │ ├─lib Profile Library directory(*2) │ ├─src Source file directory │ │ types.h Type definition │ │ │ ├─arch Architecture implementation │ │ └─rl78 r178 directory │ │ │ arch.h Architecture depending definition │ │ │ arch_main.c BLE main(*3) │ │ │ config.h BLE stack configuration │ │ │ db_handle.h DB Handle definition for profiles(*3) │ │ │ hw_config.h H/W configuration │ │ │ ke_conf.c Kernel task management │ │ │ main.c main(entry point) │ │ │ prf_config.c Profile parameters configuration(*3) │ │ │ prf_config.h Profile parameters configuration │ │ │ definition(*3) │ │ │ prf_config_host.c Profile parameters configuration setting │ │ │ prf_sel.h Profile Select setting(*3) │ │ │ rble_core_config.c rBLE_Core configuration │ │ │ rble_core_config.h rBLE_Core configuration header │ │ │ rwble_mem.c BLE stack and memory management │ │ │ rwble_mem.h BLE stack and memory management header │ │ │ rwke_api.h RWKE API and system function definition │ │ │ │ │ └─ll Built-in function directory │ │ ll.h Built-in function declaration │ │ │ ├─compiler Compiler directory │ │ │ └─driver Driver directory │ └─dataflash Data Flash Driver directory │ eel_descriptor_t02.c EEL Descriptor Source file(*3) | eel_descriptor_t02.h EEL Descriptor Header file(*3) └─tools Tool directory └─project Project directory └─XXXXXXX Developing environment directory └─BLE_Demo Project directory of this program

| BLE_Demo.mtpj Project file └─rBLE_Emb Sub-project directory of program └─DefaultBuild Hex file directory BLE_Emb.hex Hex file

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 26 of 48 Feb 3, 2017

6.2 Module List Table 6-1 shows main list of modules used in this program.

Table 6-1 Module List

Module Souce Overview

DemoApp rBLE/src/demo_app/demo_app.c

DemoApp implementation and main process in Application layer. Mainly process callbacks from GAP and SM.

Cycling Custom Profile rBLE/src/demo_app/demo_custom_cycl_profile.c Implementation of Cycling Custom Profile

Running Custom Profile rBLE/src/demo_app/demo_custom_run_profile.c Implementation of Running

Custom Profile 6.3 Macro List Table 6-2 shows optional macros define in this application. .

Table 6-2 Macro List

Macro Source Overview

DEMO_APP _DEBUG_PRINT

rBLE/src/demo_app/demo_console.h

USB serial in the debug output of strings. Defined: Enable Debug Output and disable Sleep. Not-Defined: Disable Debug Output and enabled Sleep.(Default)

CFG_DEMO_APP

CA78K0R(Build tool) / CC-RL(Build tool) / IAR C/C++ Compiler(Build tool) :

recent options(Compiler) -Define Macros

Is the source of the demo application are separated by this macro. When you view the source code to measure. Defined: Enable DemoApp.(Default) Not-Defined: Disable DemoApp.

USE_DEMO _CUSTOM_PROFILE

CA78K0R(Build tool) / CC-RL(Build tool) / IAR C/C++ Compiler(Build tool) :

recent options(Compiler) -Define Macros

Custom sources are separated by this macro. When you view the source code to measure. Defined: DemoApp Custom Profile Enabled.(Default) Not-Defined: DemoApp Custom Profile Disabled.

USE_DEMO_IRK_EXEC

CA78K0R(Build tool) / CC-RL(Build tool) / IAR C/C++ Compiler(Build tool) :

recent options(Compiler) -Define Macros

Source for the address resolution process using IRK are separated by this macro. Defined: Address resolution process Enabled. Not-Defined: Address resolution process Disabled.(Default)

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 27 of 48 Feb 3, 2017

6.4 DemoApp 6.4.1 Overview In application layer, the DemoApp does several initializations and handle callbacks from system and rBLE API.

6.4.2 API List Table 6-3 shows the list of main API functions in the DemoApp (demo_app.c).

Table 6-3 DemoApp API List

Function Overview DemoApp_Init Initialize DemoApp DemoApp_GAP_Reset DemoApp_GAP_ResetResultCB

GAP Initialization

DemoApp_GAP_CallBack GAP Callback DemoApp_SM_CallBack SM Callback DemoApp_GAP_SetSecurityRequest DemoApp_GAP_SetSecReqCompCB

Security Request

DemoApp_GAP_SetBondingMode DemoApp_GAP_SetBondModeCompCB

Bonding Configuration

DemoApp_GAP_Broadcast_Enable Start Advertise DemoApp_GAP_ConnectCompCB Connect Notification DemoApp_GAP_StartSensor Start Sensor DemoApp_GAP_BondingReqIndCB Bonding Request Notification DemoApp_GAP_BondingResp Bonding Response DemoApp_SM_LtkReqIndCB LTK Request Notification DemoApp_SM_LtkReqResp LTK Response DemoApp_SM_LtkReqForEncIndCB Paired LTK Request Notification DemoApp_SM_LtkReqForEncResp Paired LTK Response DemoApp_SM_KeyIndCB Key Notification DemoApp_GAP_BondingCompCB Bonding Completion Notification DemoApp_GAP_DisconnectCompCB Disconnect Notification DemoApp_CSCP_SensorEnable DemoApp_CSCP_SensorEnableCompCB

Enable CSCP Sensor

DemoApp_CyclCustom_CallBack Cycling Custom Callback DemoApp_CyclCustom_Enable Enable Cycling Custom DemoApp_CyclCustom_ChgCharIndCB Cycling Custom Changed

Notification DemoApp_RSCP_SensorEnable DemoApp_RSCP_SensorEnableCompCB

Enable RSCP Sensor

DemoApp_RunCustom_CallBack Running Custom Callback DemoApp_RunCustom_Enable Enable Running Custom DemoApp_RunCustom_ChgCharIndCB Running Custom Changed

Notification DemoApp_SendTimer Measurement Periodic Process DemoApp_RSCP_SendMeasurements Send RSCP Measurements DemoApp_CSCP_SendMeasurements Send CSCP Measurements DemoApp_VS_CallBack VS Callback DemoApp_VS_FlashManagementCompCB Data Flash Access

Management Complete Callback

DemoApp_VS_FlashAccessCompCB Data Flash Access Complete Callback

DemoApp_VS_FlashOperationCompCB Data Flash Block Operation Complete Callback

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 28 of 48 Feb 3, 2017

6.4.3 API The DemoApp (demo_app.c) of APIs overview is explained as below.

Function void DemoApp_Init( void )

Overview DemoApp Initialization

Description

・Initialize Application Layer.

・Initialize Switch, LED and Peripherals

・After completing abovementioned initialization, initialize rBLE API specifying DemoApp_CallBack. When the initialization finished, DemoApp_CallBack is invoked and then call DemoApp_GAP_Reset inside the callback.

Argument None

Return None

Function static void DemoApp_GAP_Reset( void )

Overview GAP Initialization

Description

・Call RBLE_GAP_Reset function registered with DemoApp_GAP_CallBack and DemoApp_SM_CallBack callbacks. When GAP initialization finished, DemoApp_GAP_ResetResultCB is invoked inside the DemoApp_GAP_CallBack.

・Initialize state variables of DemoApp.

Argument None

Return None

Function static void DemoApp_GAP_ResetResultCB( RBLE_GAP_EVENT *event )

Overview Notify the GAP Initialization finished

Description ・It is called when RBLE_GAP_Reset finished.

・Call RBLE_VS_FlashManagement to read pairing information from Data flash.

Argument RBLE_GAP_EVENT *event Event Information

Return None

Function static void DemoApp_GAP_CallBack( RBLE_GAP_EVENT *event )

Overview GAP Callback

Description ・This event receives notifications from GAP.

・DemoApp checks type of events and calls appropriate callback functions implemented in the DemoApp.

Argument RBLE_GAP_EVENT *event Event Information

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 29 of 48 Feb 3, 2017

Function static void DemoApp_SM_CallBack( RBLE_SM_EVENT *event )

Overview SM Callback

Description ・This event receives notifications from SM(Security Manager).

・ DemoApp checks type of events and calls appropriate callback functions implemented in the DemoApp.

Argument RBLE_SM_EVENT *event Event Information

Return None

Function static void DemoApp_GAP_SetSecurityRequest( void )

Overview Security Request

Description

・This API function sets Security Setting to SM.

・This API function calls RBLE_GAP_Set_Security_Request with RBLE_GAP_SEC1_NOAUTH_PAIR_ENC. When it finished, DemoApp_GAP_SetSecReqCompCB is invoked in the DemoApp_SM_CallBack.

Argument None

Return None

Function static void DemoApp_GAP_SetSecReqCompCB( RBLE_GAP_EVENT *event )

Overview Security Request finished Notification

Description ・This event receives Notification that RBLE_GAP_Set_Security_Request fisnished.

・This event configures Bonding by calling DemoApp_GAP_SetBondingMode.

Argument RBLE_GAP_EVENT *event Event Information

Return None

Function static void DemoApp_GAP_SetBondingMode( void )

Overview Bonding Configuration

Description

・This API enables Bonding by calling RBLE_GAP_Set_Bonding_Mode with using configuration RBLE_GAP_BONDABLE. When it finished, DemoApp_GAP_SetBondModeCompCB is invoked inside DemoApp_GAP_CallBack.

Argument None

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 30 of 48 Feb 3, 2017

Function static void DemoApp_GAP_SetBondModeCompCB( RBLE_GAP_EVENT *event )

Overview Bonding Configuration finished Notification

Description ・This event receives Notification that RBLE_GAP_Set_Bonding_Mode finished.

・It transits to Advertising State by calling DemoApp_GAP_Broadcast_Enable.

Argument RBLE_GAP_EVENT *event Event Information

Return None

Function static void DemoApp_GAP_Broadcast_Enable( uint8_t advState )

Overview Start Advertise

Description ・This function starts Advertise by calling RBLE_GAP_Broadcast_Enable.

・It starts timer so that it changes interval of sending Advertising package after 30 seconds.

Argument uint8_t advState Advertising mode parameter

Return None

Function static void DemoApp_GAP_ConnectCompCB( RBLE_GAP_EVENT *event )

Overview ConnectNotification

Description ・This event receives notification that it is connected with Central.

・It transits to Ready State by calling DemoApp_GAP_StartSensor.

Argument RBLE_GAP_EVENT *event Event Information

Return None

Function static void DemoApp_GAP_StartSensor( void )

Overview Start Sensor

Description ・This function starts Sensor by calling DemoApp_RSCP_SensorEnable if demo sets as RSCP or by calling DemoApp_CSCP_SensorEnable if CSCP is configured.

Argument None

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 31 of 48 Feb 3, 2017

Function static void DemoApp_GAP_BondingReqIndCB( RBLE_GAP_EVENT *event )

Overview Bonding Request Notification

Description ・This event receives notification include Bonding Request from Central.

・It does Bonding Response by calling DemoApp_GAP_BondingResp.

Argument RBLE_GAP_EVENT *event Event Information

Return None

Function static void DemoApp_GAP_BondingResp( void )

Overview Bonding Response

Description ・It starts Bonding Sequence by calling RBLE_GAP_Bonding_Response

Argument None

Return None

Function static void DemoApp_SM_LtkReqIndCB( RBLE_SM_EVENT *event )

Overview LTK Request Notification

Description ・This event receives notification of LTK Request .

・It does LTK response by calling DemoApp_SM_LtkReqResp.

Argument RBLE_SM_EVENT *event Event Information

Return None

Function static void DemoApp_SM_LtkReqResp( void )

Overview LTK Response

Description ・This function generates LTK and does LTK Response by calling RBLE_SM_Ltk_Req_Resp.

Argument None

Return None

Function static void DemoApp_SM_LtkReqForEncIndCB( RBLE_SM_EVENT *event )

Overview Paired LTK Request Notification

Description ・This event receives notification of LTK Request .

・It does LTK response by calling DemoApp_SM_LtkReqForEncResp.

Argument RBLE_SM_EVENT *event Event Information

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 32 of 48 Feb 3, 2017

Function static void DemoApp_SM_LtkReqForEncResp( RBLE_SM_EVENT *event )

Overview Paired LTK Response

Description

・LTK information read variables in the DemoApp_VS_FlashAccessCompCB callback function, which calls the RBLE_SM_Ltk_Req_Resp function to set the LTK response.

Check compare ediv LTK information during LTK response variables and event information in the RBLE_SM_EVENT of RBLE_EVT_SM_Key_t structures, and values that match the request partner exchange of key opponents.

Returns the error response if pairing device is different.

Argument RBLE_SM_EVENT *event Event Information

Return None

Function static void DemoApp_SM_KeyIndCB( RBLE_SM_EVENT *event )

Overview Key Notification

Description

・This event receives notification of Key.

・It updates Key information which is managed by DemoApp.

・This function uses a macro, USE_DEMO_IRK_EXEC, normally in preprocessing become invalid.

Argument RBLE_SM_EVENT *event Event Information

Return None

Function static void DemoApp_GAP_BondingCompCB( RBLE_GAP_EVENT *event )

Overview Bonding finished Notification

Description ・This event receives notification that Bonding Sequence finished.

・Initiate Data Flash saves the Pairing information, call RBLE_VS_Flash_Management.

Argument RBLE_GAP_EVENT *event Event Information

Return None

Function static void DemoApp_GAP_DisconnectCompCB ( RBLE_GAP_EVENT *event )

Overview Disconnected Notification

Description

・Stop the timer of periodic notification.

・If perform pairing, LTK, data Flash saves the Pairing information.

・To call the DemoApp_GAP_Broadcast_Enable function then transition to Advertising, start Advertise in this callback.

Argument RBLE_GAP_EVENT *event Event Information

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 33 of 48 Feb 3, 2017

Function static void DemoApp_CSCP_SensorEnable( void )

Overview Enable CSCP

Description

・This function enables CSCP Sensor by calling RBLE_CSCP_Sensor_Enable. After enabling, DemoApp_CSCP_SensorEnableCompCB is invoked inside DemoApp_CSCP_CallBack.

・It enables Cycling custom profile by calling DemoApp_CyclCustom_Enable.

Argument None

Return None

Function static

void DemoApp_CSCP_SensorEnableCompCB( RBLE_CSCPS_EVENT *event )

Overview CSCP Sensor enabled Notification

Description ・This event receives notification that DemoApp_CSCP_SensorEnable finished. After enabling, it is invoked via DemoApp_CSCP_CallBack.

Argument RBLE_CSCPS_EVENT *event Event Information

Return None

Function static void DemoApp_CyclCustom_CallBack(

DEMO_CUSTOM_CYCL_PROFILE_EVENT *event )

Overview Cycling Custom Callback

Description ・This event receives notifications from Cycling Custom Profile.

・It checks type of event and calls proper callback function implemented by DemoApp.

Argument DEMO_CUSTOM_CYCL_PROFILE_EVENT *event Event Information

Return None

Function static void DemoApp_CyclCustom_Enable( void )

Overview Enable CSCP Custom Profile

Description ・It enables CSCP Custom Profile by calling DemoCustom_CyclProfile_Enable. After

enabling, DemoApp_CyclCustom_EnableCompCB is invoked via DemoApp_CyclCustom_CallBack.

Argument None

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 34 of 48 Feb 3, 2017

Function static void DemoApp_CyclCustom_ChgCharIndCB(

DEMO_CUSTOM_CYCL_PROFILE_EVENT *event )

Overview Cycling Custom changed Notification

Description ・This event is invoked when value of Cycling Custom is changed.

Argument DEMO_CUSTOM_CYCL_PROFILE_EVENT *event Event Information

Return None

Function static void DemoApp_RSCP_SensorEnable( void )

Overview Enable RSCP

Description

・It enables RSCP Sensor by calling RBLE_RSCP_Sensor_Enable. After enabling, DemoApp_RSCP_SensorEnableCompCB is invoked via DemoApp_RSCP_CallBack.

・It enables Running Custom Profile by calling DemoApp_RunCustom_Enable.

Argument None

Return None

Function static void DemoApp_RSCP_SensorEnableCompCB(

RBLE_RSCPS_EVENT *event )

Overview RSCP Sensor enabled Notification.

Description ・The event receives notification that RBLE_RSCP_Sensor_Enable fisnished. After enabling, It is called via DemoApp_RSCP_CallBack.

Argument RBLE_RSCPS_EVENT *event Event Information

Return None

Function static void DemoApp_RunCustom_CallBack(

DEMO_CUSTOM_RUN_PROFILE_EVENT *event )

Overview Running Custom Callback

Description ・The event receives notifications from Running Custom Profile.

・It checks type of event and calls proper callback function implemented by DemoApp.

Argument DEMO_CUSTOM_RUN_PROFILE_EVENT *event Event Information

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 35 of 48 Feb 3, 2017

Function static void DemoApp_RunCustom_Enable( void )

Overview Enable RSCP Custom Profile

Description ・It enables RSCP Custom Profile by calling DemoCustom_RunProfile_Enable. After

enabling, DemoApp_RunCustom_EnableCompCB is invoked via DemoApp_RunCustom_CallBack

Argument None

Return None

Function static void DemoApp_RunCustom_ChgCharIndCB(

DEMO_CUSTOM_RUN_PROFILE_EVENT *event )

Overview Running Custom changed Notification

Description ・It is invoked when value of Running Custom is changed.

Argument DEMO_CUSTOM_RUN_PROFILE_EVENT *event Event Information

Return None

Function static void DemoApp_SendTimer( void )

Overview Send Timer expired Notification

Description ・It is called when sending timer is expired.

Argument None

Return None

Function static void DemoApp_CSCP_SendMeasurements( void )

Overview Send CSC Measurement

Description ・It calculates and sends CSC Measurement.

Argument None

Return None

Function static void DemoApp_RSCP_SendMeasurements( void )

Overview Send RSC Measurement

Description ・It calculates and sends RSC Measurement.

Argument None

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 36 of 48 Feb 3, 2017

static void DemoApp_VS_CallBack(RBLE_VS_EVENT *event )

Overview VS Callback

Description ・The event receives notifications from VS(Vendor Specific).

・DemoApp checks type of event and calls proper callback function implemented by DemoApp.

Argument RBLE_VS_EVENT *event Event Information

Return None

static void DemoApp_VS_FlashManagementCompCB(RBLE_VS_EVENT *event )

Overview Data Flash Access Management Complete Callback

Description

・It receives Notification that RBLE_VS_Flash_Access finished.

・Read/Write Data Flash to the RBLE_VS_Flash_Access function to call if the command is RBLE_VS_FLASH_CMD_START.

・DemoApp_GAP_SetSecurityRequest function to call if the command is RBLE_VS_FLASH_CMD_STOP, if encryption is enabled, the security settings. DemoApp_GAP_Broadcast_Enable function to call if the encryption is disabled, and the transition to Advertising.

Argument RBLE_VS_EVENT *event Event Information

Rerurn None

static void DemoApp_VS_FlashAccessCompCB(RBLE_VS_EVENT *event )

Overview Data Flash Access Complete Callback

Description

・The event receives Notification that RBLE_VS_Flash_Access finished.

・If the command was Read to the Pairing information containing the internal variable Advertising begins.

・If the Write command, transition to the Ready state.

・To run the "RBLE_VS_Flash_Operation" function if the error was the result and do the cleanup of Data Flash.

Argument RBLE_VS_EVENT *event Event Information

Return None

static void DemoApp_VS_FlashOperationCompCB (RBLE_VS_EVENT *event )

Overview Data Flash Access Operation Complete Callback

Description

・It receives Notification that RBLE_VS_Flash_Operation finished.

・The Pairing information could not be done by the RBLE_VS_Flash_Access function for data placement is completed if the command is RBLE_VS_FLASH_CMD_CLEANUP, the read/write again.

Argument RBLE_VS_EVENT *event Event Information

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 37 of 48 Feb 3, 2017

6.5 Cycling Custom Profile 6.5.1 Overview The processing of Cycling will be implemented with the custom profile. In Cycling Custom Profile, you need to configure the wheel radius to be used in the CSCP. Here is this custom profile that required functions are not highlighted.

[Note] Wheel radius setting value RL78/G1D can receive through Cycling Custom Profiles. But in the demo, to work on RL78/G1D not using the setting value.

Cycling Custom Profiles specification is shown in Table 6-4.

Table 6-4 Cycling Custom Profiles specification

Attribute handle Attribute handle & value

DEMO_CUSTOM_CYCL_PROFILE_HDL_SVC 0x0037 (*)

Type: Primary Service Declaration

UUID: 0xF2B2C260-5780-11E5-A518-0002A5D5C51B

DEMO_CUSTOM_CYCL_PROFILE_HDL_RADIUS_CHAR 0x0038 (*)

Type: Characteristic Declaration

UUID: 0x15DB6B80-5780-11E5-B8EC-0002A5D5C51B

Property: Read/Write

DEMO_CUSTOM_CYCL_PROFILE_HDL_RADIUS_VAL 0x0039 (*)

Type: Characteristic Value

You can configure the wheel radius by transmitting a Write to this Characteristic. The default value is 60(cm).

DEMO_CUSTOM_CYCL_PROFILE_HDL_RADIUS_DESC 0x003A (*)

Type: Characteristic User Description

(*)Hexadecimal number of the attributes handle depends on the profiles included in the firmware.

6.5.2 API List Cycling Custom Profile (demo_custom_cycl_Profile.c) APIs are listed in Table 6-5.

Table 6-5 Cycling Custom Profile API List

Function Overview DemoCustom_CyclProfile_Enable DemoCustom_CyclProfile_EndEnableComplete

Enable Cycling Custom Profile

DemoCustom_CyclProfile_GattCallback Cycling Custom GATT Callback DemoCustom_CyclProfile_Response Cycling Custom Response DemoCustom_CyclProfile_SendChgChar Cycling Custom Update Notification DemoCustom_CyclProfile_SetData Cycling Custom Update

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 38 of 48 Feb 3, 2017

6.5.3 API Main Cycling Custom Profile (demo_custom_cycl_profile.c) API overview is as shown below.

Function RBLE_STATUS DemoCustom_CyclProfile_Enable( uint16_t conhdl,

DEMO_CUSTOM_CYCL_PROFILE_EVENT_HANDLER call_back )

Overview Enables Cycling Custom Profile

Description ・This function enables custom profile by calling RBLE_GATT_Enable.

・After enabling, it calls DemoCustom_CyclProfile_EndEnableComplete

Argument uint16_t conhdl Connection handle

DMEO_CUSTOM_CYCL_PROFILE_EVENT_HANDLER call_back Custom profile callback

Return RBLE_STATUS Result

Function static void DemoCustom_CyclProfile_EndEnableComplete(RBLE_STATUS status)

Overview Cycling Custom Profile enabled Notification

Description ・It calls specified callback function

Argument RBLE_STATUS status Result

Return None

Function static void DemoCustom_CyclProfile_GattCallback( RBLE_GATT_EVENT *event )

Overview Cycling Custo mGATT Callback

Description ・the event receives GATT Event to custom profile and calls appropriate callback functions.

Argument RBLE_GATT_EVENT *event Event Information

Return None

Function static

void DemoCustom_CyclProfile_Response(uint16_t att_hdl, RBLE_STATUS result)

Overview Cycling Custom Response

Description ・It sends Write Response.

Argument uint16_t att_hdl Attribute handle

RBLE_STATUS result result of writing

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 39 of 48 Feb 3, 2017

Function

static

void DemoCustom_CyclProfile_SendChgChar(

uint8_t char_code, uint8_t *value, uint16_t val_len)

Overview Cycling Custom Update Notification

Description ・It notifies DemoApp that value is chagned.

Argument

uint8_t char_code Characteristic Code

uint8_t *value Value of Characteristic

uint16_t val_len Length of value

Return None

Function

static

RBLE_STATUS DemoCustom_CyclProfile_SetData(

uint16_t val_hdl, uint8_t *data, uint16_t data_len)

Overview Cycling Custom Update

Description ・It updates the value of Cycling Custom by calling RBLE_GATT_Set_Data.

Argument

uint16_t val_hdl Handle of value

uint8_t *data Value of Characteristic

uint16_t data_len Length of data

Return RBLE_STATUS Result

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 40 of 48 Feb 3, 2017

6.6 Running Custom Profile 6.6.1 Overview Running process will be implemented with the custom profile configure the setting of stride to be used in the RSCP. Here is this custom profile that required functions are not highlighted.

Running Custom Profiles specification is shown in Table 6-6.

Table 6-6 Running Custom Profiles specification

Attribute handle Attribute handle & value

DEMO_CUSTOM_RUN_PROFILE_HDL_SVC 0x0033 (*)

Type: Primary Service Declaration

UUID: 0x0A8BCD00-5781-11E5-9E51-0002A5D5C51B

DEMO_CUSTOM_RUN_PROFILE_HDL_STRIDE_CHAR 0x0034 (*)

Type: Characteristic Declaration

UUID: 0x045EFD80-5781-11E5-AC83-0002A5D5C51B

Property: Read/Write

DEMO_CUSTOM_RUN_PROFILE_HDL_STRIDE_VAL 0x0035 (*)

Type: Characteristic Value

You can set stride by transmitting a Write to this Characteristic. The default value is 80(cm).

DEMO_CUSTOM_RUN_PROFILE_HDL_STRIDE_DESC 0x0036 (*)

Type: Characteristic User Description

(*)Hexadecimal number of the attributes handle depends on the profiles included in the firmware.

6.6.2 API List Running Custom Profile (demo_custom_run_Profile.c) APIs are listed in bellow Table 6-7.

Table 6-7 Running Custom Profile API List

Function Overview DemoCustom_RunProfile_Enable DemoCustom_RunProfile_EndEnableComplete

Enables Running Custom Profile

DemoCustom_RunProfile_GattCallback Running Custom GATT Callback DemoCustom_RunProfile_Response Running Custom Response DemoCustom_RunProfile_SendChgChar Running Custom Update Notification DemoCustom_RunProfile_SetData Running Custom Update

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 41 of 48 Feb 3, 2017

6.6.3 API Running Custom Profile (demo_custom_run_profile.c) API overview is described as below.

Function RBLE_STATUS DemoCustom_RunProfile_Enable( uint16_t conhdl,

DEMO_CUSTOM_RUN_PROFILE_EVENT_HANDLER call_back )

Overview Enables Running Custom Profile

Description ・This function enables custom profile by calling RBLE_GATT_Enable

・After enabling, it calls DemoCustom_RunProfile_EndEnableComplete.

Argument uint16_t conhdl Connection handle

DMEO_CUSTOM_RUN_PROFILE_EVENT_HANDLER call_back Custom profile callback

Return RBLE_STATUS Result

Function static void DemoCustom_RunProfile_EndEnableComplete(RBLE_STATUS status)

Overview Running Custom Profile enabled Notification

Description ・It calls specified callback function.

Argument RBLE_STATUS status Result

Return None

Function static void DemoCustom_RunProfile_GattCallback( RBLE_GATT_EVENT *event )

Overview Running Custom GATT Callback

Description ・It receives GATT Event to custom profile and calls appropriate callback functions.

Argument RBLE_GATT_EVENT *event Event Information

Return None

Function static

void DemoCustom_RunProfile_Response(uint16_t att_hdl, RBLE_STATUS result)

Overview Running Custom Response

Description ・It sends Write Response.

Argument uint16_t att_hdl Attribute handle

RBLE_STATUS result Result of writing

Return None

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 42 of 48 Feb 3, 2017

Function

static

void DemoCustom_RunProfile_SendChgChar(

uint8_t char_code, uint8_t *value, uint16_t val_len)

Overview Running Custom Update Notification

Description ・It notifies DemoApp when value is changed.

Argument

uint8_t char_code Characteristic Code

uint8_t *value Value of Characteristic

uint16_t val_len Length of value

Return None

Function

static

RBLE_STATUS DemoCustom_RunProfile_SetData(

uint16_t val_hdl, uint8_t *data, uint16_t data_len)

Overview Running Custom Update

Description ・It updates value of Running Custom by calling RBLE_GATT_Set_Data.

Argument

uint16_t val_hdl Handle of value

uint8_t *data Value of Characteristic

uint16_t data_len Length of data

Return RBLE_STATUS Result

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 43 of 48 Feb 3, 2017

7. Adding Custom Profile There are three steps to add new Custom Profile in the program as listed below. In this chapter, explain how to add TestProfile Profile, TestProfile Service and TestCharacteristic Characteristic as example.

1. Defining Service 2. Implementing Profile 3. Enabling Profile

For more information, see “7.4.2 Creating a User Profile” of Bluetooth® Low Energy Protocol Stack User’s Manual and “2.2.5 Registration of callback functions for event notification” of API Reference Manual: Basics.

7.1 Defining Service Add definition of Service and Characteristic to GATT database.

1. Add Database Handle corresponding to Service and Characteristic. Add definition of Service, Characteristic and corresponding the characteristic value with names before end of (DB_HDL_MAX) enumeration, which is defined as “Attribute database handles” in db_handle.h header file under renesas/src/arch/rl78/ folder.

[NOTE]Here, add definitions TEST_PROFILE_HDL_SVC as Service,

TEST_PROFILE_HDL_CHARA1_CHARA as Characteristic, and TEST_PROFILE_HDL_CHARA1_VAL as value of the characteristic.

2. Add Database Index corresponding to Service, Characteristic. Add definition of Service, Characteristic and value of the characteristic with names to end of enumeration, which is defined as “Attribute database index” in prf_config.h header file under renesas/src/arch/rl78/ folder.

[NOTE]Here, add definitions TEST_PROFILE_IDX_SVC as Service,

TEST_PROFILE_IDX_CHARA1_CHARA as Characteristic and TEST_PROFILE_IDX_CHARA1_VAL as value of the characteristic.

/** Attribute database handles */ enum { /* Generic Access Profile Service*/ GAP_HDL_PRIM_SVC = 0x0001, GAP_HDL_CHAR_DEVNAME, // --- omit --- TEST_PROFILE_HDL_SVC, //Service TEST_PROFILE_HDL_CHARA1_CHARA, //Characteristic: Chara1 TEST_PROFILE_HDL_CHARA1_VAL, //for Value of Characteristic: Chara1 DB_HDL_MAX };

/** Attribute database index */ enum { /* Invalid index*/ ATT_INVALID_IDX = 0x0000, // --- omit --- TEST_PROFILE_IDX_SVC, //Service TEST_PROFILE_IDX_CHARA1_CHARA, //Characteristic: Chara1 TEST_PROFILE_IDX_CHARA1_VAL, //for Value of Characteristic: Chara1 };

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 44 of 48 Feb 3, 2017

3. Define variable for UUID of Service and Characteristic.

[NOTE]Define that can be referenced from prf_config.c header file under renesas/src/arch/rl78/ folder.

4. Define structure variable (struct) atts_char128_desc, which describes as Characteristic of Profile and actual variable for value of the characteristic.

①Prop member defines attributes of Read/Write, Authentication requirement, Notification and

Indication. ②Set attr_hdl member using Database Handle as above. [NOTE]Define that can be referenced from prf_config.c header file under renesas/src/arch/rl78/ folder.

/* Service */ const uint8_t test_profile_svc[RBLE_GATT_128BIT_UUID_OCTET] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };

/* Characteristic */ const struct atts_char128_desc test_profile_chara1 = { RBLE_GATT_CHAR_PROP_WR | RBLE_GATT_CHAR_PROP_RD, { (uint8_t)(TEST_PROFILE_HDL_CHARA1_VAL & 0xff), (uint8_t)((TEST_PROFILE_HDL_CHARA1_VAL >> 8) & 0xff) }, { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xff } }; uint16_t test_profile_chara1_value = 100;

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 45 of 48 Feb 3, 2017

5. Define structural variables (struct) atts_char128_desc, which describes Characteristic of Profile and actual value of the characteristic.

③Set taskid member using Database Index as above.

④Set perm member to specify access permission to each descriptor.

/** Attribute Database */ const struct atts_desc atts_desc_list_prf[] = { // --- omit --- //* Service */ { RBLE_DECL_PRIMARY_SERVICE, sizeof(test_profile_svc), sizeof(test_profile_svc), TASK_ATTID(TASK_RBLE, TEST_PROFILE_IDX_SVC), ③ RBLE_GATT_PERM_RD, ④ (void *)&test_profile_svc }, /* Characteristic: Chara1 */ { RBLE_DECL_CHARACTERISTIC, sizeof(test_profile_chara1), sizeof(test_profile_chara1), TASK_ATTID(TASK_RBLE, TEST_PROFILE_IDX_CHARA1_CHARA), ③ RBLE_GATT_PERM_RD, ④ (void *)&test_profile_chara1 }, /* Demo Cycling Custom Radius Value */ { DB_TYPE_128BIT_UUID, sizeof(test_profile_chara1_value), sizeof(test_profile_chara1_value), TASK_ATTID(TASK_RBLE, TEST_PROFILE_IDX_CHARA1_VAL), ③ (RBLE_GATT_PERM_RD|RBLE_GATT_PERM_WR), ④ (void *)&test_profile_chara1_value }, };

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 46 of 48 Feb 3, 2017

7.2 Implementing Profile To implement Profile process, GATT Callback function is used. This Profile always processes Event Notification from GATT.

[NOTE]In the example, define TestProfile_GattCallback as Callback function from GATT. [NOTE]Check type of event and implement required process for required event. In the example,

it implements TestProfile_WriteCmdInd function to process Write command for event RBLE_GATT_EVENT_WRITE_CMD_IND.

7.3 Enabling Profile After implementing the Profile, register GATT Callback function by calling RBLE_GATT_Enable.

static void TestProfile_WriteCmdInd(struct RBLE_GATT_Write_Cmd_Ind_t *cmd); void TestProfile_GattCallback( RBLE_GATT_EVENT *event ) { switch ( event-> type ) { case RBLE_GATT_EVENT_WRITE_CMD_IND: TestProfile_WriteCmdInd(&event->param.write_cmd_ind); break; default: break; } } static void TestProfile_WriteCmdInd(struct RBLE_GATT_Write_Cmd_Ind_t *cmd) { RBLE_GATT_SET_DATA set_data; if ( cmd->elmt == TEST_PROFILE_HDL_CHARA1_VAL ) { set_data.val_hdl = cmd->elmt; set_data.val_len = cmd->size; memcpy(set_data.value, cmd->value, set_data.val_len); RBLE_GATT_Set_Data(cmd->elmt, cmd->value[0], cmd->size) } }

void SomewhereInitializeOrSomewhereTrigger( void ) { RBLE_GATT_Enable( TestProfile_GattCallback ); }

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 47 of 48 Feb 3, 2017

8. Bibliography • iOS Developer Library https://developer.apple.com/library/content/navigation/ • Android Developers https://developer.android.com/index.html • Specifications / Bluetooth Technology Website https://www.bluetooth.com/specifications

Bluetooth® Low Energy Protocol Stack RL78/G1D applications to communicate with RenesasBLE

R01AN3017EJ0200 Rev.2.00 Page 48 of 48 Feb 3, 2017

Website and Support Renesas Electronics Website

http://www.renesas.com/ Inquiries

http://www.renesas.com/contact/

All trademarks and registered trademarks are the property of their respective owners.

Bluetooth is a registered trademark of Bluetooth SIG, Inc., U.S.A.

A-1

Revision History

Rev. Date Description

Page Summary 1.00 Feb 18, 2016 - First edition 1.01 Mar 4, 2016 - Change the title

RL78 Compiler CC-RL is supported. Update the Related the Documents

P.6 3.1 Contents Added to two project file names for CC-RL.

P.11 5.1 Operating and Developing Environment Added to following to two developed and tested below listed environment.

- Smart Phone : Android - Software

P.24 6.1 Files Modify the developing environment directory name.

P.26 6.3 Macro List Modify the macro name.

CFG_DEMO_CUSTOM_PROFILE -> USE_DEMO_CUSTOM_PROFILE Add to CC-RL of column to Source of Table 6-2.

P.43 Reconfigure the Chapter 7. 2.00 Feb 3, 2017 - Change the Timer driver using the RWKE API.

Delete the specification on the WhiteList. Typographical errors corrected.

P.6 3.1Contents Added to one project file names for IAR Embedded Workbench.

P.6-P.9 Add to chapters 3.2.1Decompress the Zip file~3.2.3Copy of the library and related files. Add to 3.3Build the project.

P.11 5.1Operating and Developing Environment Smartphone OS version number update. IAR Embedded Workbench for append Software.

P.13 5.4.1Initialize Correct "arch_main" "arch_main_ent". Figure 5-3 Add to Pairing information read timing.

P.14-P.21 Correct "OPT"/"Alt" DIPSW setting.

P.15 5.4.2Advertising Encryption is removed with no explanation. Figure 5-5 is removed. Integrated in Figure 5-4. Connection response of Central is removed in Figure 5-4.

P.16 Table 5-1 Advertise Status List Delete the WhiteList state transition descriptions in the No.2 and No.3.

P.17 5.4.3Bonding Description write about when you store pairing information.

Append the Pairing information write timing shown in Figure 5-6.

P.20,P.21 Figure 5-9,Figure 5-10 Change from "DemoTimer_SetTimerID""ke_timer_set".

P.22 Add to chapter 5.5I/O Interface.

A-2

P.24 6.1Files Delete the description of "demo_timer.c"/"demo_timer.h".

P.26 Table 6-2 Macro List Add to the description, Default status and add to

"USE_DEMO_IRK_EXEC" macro. P.27 Table 6-3 DemoApp API List add to Data Flash for four

functions. ・DemoApp_VS_CallBack ・DemoApp_VS_FlashManagementCompCB ・DemoApp_VS_FlashAccessCompCB

・DemoApp_VS_FlashOperationCompCB P.28 6.4.3API

Add to Data Flash functions. P.30 6.4.3API

DemoApp_GAP_Broadcast_Enable function argument spec changed from void to uint8_t.

P.37 6.5.1Overview Add to Table 6-4.

P.40 6.6.1Overview Add to Table 6-6.

P.44 Remove the static const array declarations that can be illustrated in description 3.

P.44,P.45 Description 4 & 5 annotated references written numbers.

P.47 8Bibliography Update the URL was listed.

General Precautions in the Handling of Microprocessing Unit and Microcontroller Unit Products The following usage notes are applicable to all Microprocessing unit and Microcontroller unit products from Renesas. For detailed usage notes on the products covered by this document, refer to the relevant sections of the document as well as any technical updates that have been issued for the products.

1. Handling of Unused Pins Handle unused pins in accordance with the directions given under Handling of Unused Pins in the manual. ¾ The input pins of CMOS products are generally in the high-impedance state. In operation with an

unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of LSI, an associated shoot-through current flows internally, and malfunctions occur due to the false recognition of the pin state as an input signal become possible. Unused pins should be handled as described under Handling of Unused Pins in the manual.

2. Processing at Power-on The state of the product is undefined at the moment when power is supplied. ¾ The states of internal circuits in the LSI are indeterminate and the states of register settings and

pins are undefined at the moment when power is supplied. In a finished product where the reset signal is applied to the external reset pin, the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed. In a similar way, the states of pins in a product that is reset by an on-chip power-on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified.

3. Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited. ¾ The reserved addresses are provided for the possible future expansion of functions. Do not access

these addresses; the correct operation of LSI is not guaranteed if they are accessed. 4. Clock Signals

After applying a reset, only release the reset line after the operating clock signal has become stable. When switching the clock signal during program execution, wait until the target clock signal has stabilized. ¾ When the clock signal is generated with an external resonator (or from an external oscillator)

during a reset, ensure that the reset line is only released after full stabilization of the clock signal. Moreover, when switching to a clock signal produced with an external resonator (or by an external oscillator) while program execution is in progress, wait until the target clock signal is stable.

5. Differences between Products Before changing from one product to another, i.e. to a product with a different part number, confirm that the change will not lead to problems. ¾ The characteristics of Microprocessing unit or Microcontroller unit products in the same group but

having a different part number may differ in terms of the internal memory capacity, layout pattern, and other factors, which can affect the ranges of electrical characteristics, such as characteristic values, operating margins, immunity to noise, and amount of radiated noise. When changing to a product with a different part number, implement a system-evaluation test for the given product.

http://www.renesas.comRefer to "http://www.renesas.com/" for the latest and detailed information.

Renesas Electronics America Inc.1001 Murphy Ranch Road, Milpitas, CA 95035, U.S.A.Tel: +1-408-432-8888, Fax: +1-408-434-5351Renesas Electronics Canada Limited9251 Yonge Street, Suite 8309 Richmond Hill, Ontario Canada L4C 9T3Tel: +1-905-237-2004Renesas Electronics Europe LimitedDukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.KTel: +44-1628-651-700Renesas Electronics Europe GmbHArcadiastrasse 10, 40472 Düsseldorf, Germany Tel: +49-211-6503-0, Fax: +49-211-6503-1327Renesas Electronics (China) Co., Ltd.Room 1709 Quantum Plaza, No.27 ZhichunLu, Haidian District, Beijing, 100191 P. R. ChinaTel: +86-10-8235-1155, Fax: +86-10-8235-7679Renesas Electronics (Shanghai) Co., Ltd.Unit 301, Tower A, Central Towers, 555 Langao Road, Putuo District, Shanghai, 200333 P. R. China Tel: +86-21-2226-0888, Fax: +86-21-2226-0999Renesas Electronics Hong Kong LimitedUnit 1601-1611, 16/F., Tower 2, Grand Century Place, 193 Prince Edward Road West, Mongkok, Kowloon, Hong KongTel: +852-2265-6688, Fax: +852 2886-9022Renesas Electronics Taiwan Co., Ltd.13F, No. 363, Fu Shing North Road, Taipei 10543, TaiwanTel: +886-2-8175-9600, Fax: +886 2-8175-9670Renesas Electronics Singapore Pte. Ltd.80 Bendemeer Road, Unit #06-02 Hyflux Innovation Centre, Singapore 339949Tel: +65-6213-0200, Fax: +65-6213-0300Renesas Electronics Malaysia Sdn.Bhd.Unit 1207, Block B, Menara Amcorp, Amcorp Trade Centre, No. 18, Jln Persiaran Barat, 46050 Petaling Jaya, Selangor Darul Ehsan, MalaysiaTel: +60-3-7955-9390, Fax: +60-3-7955-9510Renesas Electronics India Pvt. Ltd.No.777C, 100 Feet Road, HAL 2nd Stage, Indiranagar, Bangalore 560 038, IndiaTel: +91-80-67208700, Fax: +91-80-67208777Renesas Electronics Korea Co., Ltd.17F, KAMCO Yangjae Tower, 262, Gangnam-daero, Gangnam-gu, Seoul, 06265 KoreaTel: +82-2-558-3737, Fax: +82-2-558-5338

SALES OFFICES

© 2018 Renesas Electronics Corporation. All rights reserved.Colophon 7.1

(Rev.4.0-1 November 2017)

Notice

1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for

the incorporation or any other use of the circuits, software, and information in the design of your product or system. Renesas Electronics disclaims any and all liability for any losses and damages incurred by

you or third parties arising from the use of these circuits, software, or information.

2. Renesas Electronics hereby expressly disclaims any warranties against and liability for infringement or any other claims involving patents, copyrights, or other intellectual property rights of third parties, by or

arising from the use of Renesas Electronics products or technical information described in this document, including but not limited to, the product data, drawings, charts, programs, algorithms, and application

examples.

3. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or others.

4. You shall not alter, modify, copy, or reverse engineer any Renesas Electronics product, whether in whole or in part. Renesas Electronics disclaims any and all liability for any losses or damages incurred by

you or third parties arising from such alteration, modification, copying or reverse engineering.

5. Renesas Electronics products are classified according to the following two quality grades: “Standard” and “High Quality”. The intended applications for each Renesas Electronics product depends on the

product’s quality grade, as indicated below.

"Standard": Computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home electronic appliances; machine tools; personal electronic

equipment; industrial robots; etc.

"High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control (traffic lights); large-scale communication equipment; key financial terminal systems; safety control equipment; etc.

Unless expressly designated as a high reliability product or a product for harsh environments in a Renesas Electronics data sheet or other Renesas Electronics document, Renesas Electronics products are

not intended or authorized for use in products or systems that may pose a direct threat to human life or bodily injury (artificial life support devices or systems; surgical implantations; etc.), or may cause

serious property damage (space system; undersea repeaters; nuclear power control systems; aircraft control systems; key plant systems; military equipment; etc.). Renesas Electronics disclaims any and all

liability for any damages or losses incurred by you or any third parties arising from the use of any Renesas Electronics product that is inconsistent with any Renesas Electronics data sheet, user’s manual or

other Renesas Electronics document.

6. When using Renesas Electronics products, refer to the latest product information (data sheets, user’s manuals, application notes, “General Notes for Handling and Using Semiconductor Devices” in the

reliability handbook, etc.), and ensure that usage conditions are within the ranges specified by Renesas Electronics with respect to maximum ratings, operating power supply voltage range, heat dissipation

characteristics, installation, etc. Renesas Electronics disclaims any and all liability for any malfunctions, failure or accident arising out of the use of Renesas Electronics products outside of such specified

ranges.

7. Although Renesas Electronics endeavors to improve the quality and reliability of Renesas Electronics products, semiconductor products have specific characteristics, such as the occurrence of failure at a

certain rate and malfunctions under certain use conditions. Unless designated as a high reliability product or a product for harsh environments in a Renesas Electronics data sheet or other Renesas

Electronics document, Renesas Electronics products are not subject to radiation resistance design. You are responsible for implementing safety measures to guard against the possibility of bodily injury, injury

or damage caused by fire, and/or danger to the public in the event of a failure or malfunction of Renesas Electronics products, such as safety design for hardware and software, including but not limited to

redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. Because the evaluation of microcomputer software alone is very difficult

and impractical, you are responsible for evaluating the safety of the final products or systems manufactured by you.

8. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product. You are responsible for carefully and

sufficiently investigating applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive, and using Renesas Electronics

products in compliance with all these applicable laws and regulations. Renesas Electronics disclaims any and all liability for damages or losses occurring as a result of your noncompliance with applicable

laws and regulations.

9. Renesas Electronics products and technologies shall not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws

or regulations. You shall comply with any applicable export control laws and regulations promulgated and administered by the governments of any countries asserting jurisdiction over the parties or

transactions.

10. It is the responsibility of the buyer or distributor of Renesas Electronics products, or any other party who distributes, disposes of, or otherwise sells or transfers the product to a third party, to notify such third

party in advance of the contents and conditions set forth in this document.

11. This document shall not be reprinted, reproduced or duplicated in any form, in whole or in part, without prior written consent of Renesas Electronics.

12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products.

(Note 1) “Renesas Electronics” as used in this document means Renesas Electronics Corporation and also includes its directly or indirectly controlled subsidiaries.

(Note 2) “Renesas Electronics product(s)” means any product developed or manufactured by or for Renesas Electronics.