Bluetooth® Low Energy Protocol Stack API Reference Manual: Basics Renesas MCU Target Device RL78/G1D All information contained in these materials, including products and product specifications, represents information on the product at the time of publication and is subject to change by Renesas Electronics Corp. without notice. Please review the latest information published by Renesas Electronics Corp. through various means, including the Renesas Electronics Corp. website (http://www.renesas.com). Rev.1.19 Mar. 2018 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. (Rev.4.0-1 November 2017) 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. (cid:190) 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. (cid:190) 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. (cid:190) 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. (cid:190) 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. (cid:190) 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. How to Use This Manual 1. Purpose and Target Readers This manual describes the API (Application Program Interface) of the basic features of the Bluetooth Low Energy protocol stack (BLE software), which is used to develop Bluetooth applications that incorporate the Renesas Bluetooth low energy microcontroller RL78/G1D. It is intended for users designing application systems incorporating this software. A basic knowledge of microcontrollers and Bluetooth low energy is necessary in order to use this manual. Related documents The related documents indicated in this publication may include preliminary versions. However, preliminary versions are not marked as such. Document Name Document No. Bluetooth Low Energy Protocol Stack User's Manual R01UW0095E API Reference Manual: Basics This manual API Reference Manual: FMP R01UW0089E API Reference Manual: PXP R01UW0090E API Reference Manual: HTP R01UW0091E API Reference Manual: BLP R01UW0092E API Reference Manual: HOGP R01UW0093E API Reference Manual: ScPP R01UW0094E API Reference Manual: HRP R01UW0097E API Reference Manual: CSCP R01UW0098E API Reference Manual: CPP R01UW0099E API Reference Manual: GLP R01UW0103E API Reference Manual: TIP R01UW0106E API Reference Manual: RSCP R01UW0107E API Reference Manual: ANP R01UW0108E API Reference Manual: PASP R01UW0109E API Reference Manual: LNP R01UW0113E Sample Program Application Note R01AN1375E rBLE command specifications R01AN1376E List of Abbreviations and Acronyms Abbreviation Full Form Remark 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 Abbreviation Full Form Remark 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 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 Abbreviation Full Form Remark APP Application CSI Clocked Serial Interface IIC Inter-Integrated Circuit RSCIP Renesas Serial Communication Interface Protocol VS Vendor Specific All trademarks and registered trademarks are the property of their respective owners. Bluetooth is a registered trademark of Bluetooth SIG, Inc. U.S.A. EEPROM is a trademark of Renesas Electronics Corporation. Windows, Windows NT and Windows XP are registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. PC/AT is a trademark of International Business Machines Corporation. Contents 1. Overview ........................................................................................................................................................ 1 2. General .......................................................................................................................................................... 2 2.1 BLE Software and its APIs ................................................................................................................................. 2 2.2 rBLE API ............................................................................................................................................................ 3 2.2.1 Language ................................................................................................................................................... 3 2.2.2 rBLE API procedure .................................................................................................................................. 3 2.2.3 Classification of rBLE API profiles ........................................................................................................... 4 2.2.4 Handling of parameters of rBLE API functions ........................................................................................ 5 2.2.5 Registration of callback functions for event notification ........................................................................... 5 2.2.6 Basic operation of callback functions for event notification ...................................................................... 7 2.3 BLE Software State Transitions.......................................................................................................................... 9 2.3.1 rBLE_Core state transitions ....................................................................................................................... 9 2.3.2 rBLE_HOST state transitions .................................................................................................................. 10 2.4 BLE Software Initialization Procedure ............................................................................................................. 11 3. Common Definitions .................................................................................................................................... 11 3.1 Standard Typedef .............................................................................................................................................. 11 3.2 Generic Definitions ........................................................................................................................................... 11 3.3 GATT Definitions ............................................................................................................................................. 16 4. Initialization .................................................................................................................................................. 19 4.1 Definitions ........................................................................................................................................................ 19 4.2 Functions .......................................................................................................................................................... 20 4.2.1 RBLE_Init ............................................................................................................................................... 20 4.3 Events ............................................................................................................................................................... 21 4.3.1 RBLE_INIT_EVENT_MODE_CHANGE .............................................................................................. 21 5. Generic Access Profile ................................................................................................................................ 22 5.1 Definitions ........................................................................................................................................................ 22 5.2 Functions .......................................................................................................................................................... 38 5.2.1 RBLE_GAP_Reset .................................................................................................................................. 39 5.2.2 RBLE_GAP_Set_Name ........................................................................................................................... 39 5.2.3 RBLE_GAP_Observation_Enable ........................................................................................................... 40 5.2.4 RBLE_GAP_Observation_Disable .......................................................................................................... 41 Index-1 5.2.5 RBLE_GAP_Broadcast_Enable .............................................................................................................. 42 5.2.6 RBLE_GAP_Broadcast_Disable ............................................................................................................. 44 5.2.7 RBLE_GAP_Set_Bonding_Mode ........................................................................................................... 45 5.2.8 RBLE_GAP_Set_Security_Request ........................................................................................................ 45 5.2.9 RBLE_GAP_Get_Device_Info ................................................................................................................ 46 5.2.10 RBLE_GAP_Get_White_List_Size ......................................................................................................... 46 5.2.11 RBLE_GAP_Add_To_White_List .......................................................................................................... 46 5.2.12 RBLE_GAP_Del_From_White_List ....................................................................................................... 47 5.2.13 RBLE_GAP_Get_Remote_Device_Name .............................................................................................. 48 5.2.14 RBLE_GAP_Get_Remote_Device_Info ................................................................................................. 49 5.2.15 RBLE_GAP_Device_Search ................................................................................................................... 49 5.2.16 RBLE_GAP_Set_Random_Address ........................................................................................................ 50 5.2.17 RBLE_GAP_Set_Privacy_Feature .......................................................................................................... 51 5.2.18 RBLE_GAP_Create_Connection ............................................................................................................ 52 5.2.19 RBLE_GAP_Connection_Cancel ............................................................................................................ 53 5.2.20 RBLE_GAP_Disconnect ......................................................................................................................... 53 5.2.21 RBLE_GAP_Start_Bonding .................................................................................................................... 54 5.2.22 RBLE_GAP_Bonding_Info_Ind .............................................................................................................. 55 5.2.23 RBLE_GAP_Bonding_Response ............................................................................................................ 56 5.2.24 RBLE_GAP_Change_Connection_Param ............................................................................................... 57 5.2.25 RBLE_GAP_Channel_Map_Req ............................................................................................................ 58 5.2.26 RBLE_GAP_Read_RSSI ......................................................................................................................... 58 5.2.27 RBLE_GAP_Authorized_Ind .................................................................................................................. 58 5.3 Events ............................................................................................................................................................... 59 5.3.1 RBLE_GAP_EVENT_RESET_RESULT ............................................................................................... 60 5.3.2 RBLE_GAP_EVENT_SET_NAME_COMP .......................................................................................... 60 5.3.3 RBLE_GAP_EVENT_OBSERVATION_ENABLE_COMP ................................................................. 60 5.3.4 RBLE_GAP_EVENT_OBSERVATION_DISABLE_COMP ................................................................ 60 5.3.5 RBLE_GAP_EVENT_BROADCAST_ENABLE_COMP ..................................................................... 60 5.3.6 RBLE_GAP_EVENT_BROADCAST_DISABLE_COMP .................................................................... 61 5.3.7 RBLE_GAP_EVENT_SET_BONDING_MODE_COMP ...................................................................... 61 5.3.8 RBLE_GAP_EVENT_SET_SECURITY_REQUEST_COMP ............................................................... 61 5.3.9 RBLE_GAP_EVENT_GET_DEVICE_INFO_COMP ........................................................................... 61 5.3.10 RBLE_GAP_EVENT_GET_WHITE_LIST_SIZE_COMP .................................................................... 62 5.3.11 RBLE_GAP_EVENT_ADD_TO_WHITE_LIST_COMP ...................................................................... 62 5.3.12 RBLE_GAP_EVENT_DEL_FROM_WHITE_LIST_COMP ................................................................. 62 5.3.13 RBLE_GAP_EVENT_GET_REMOTE_DEVICE_NAME_COMP ....................................................... 62 5.3.14 RBLE_GAP_EVENT_GET_REMOTE_DEVICE_INFO_COMP ......................................................... 63 Index-2 5.3.15 RBLE_GAP_EVENT_DEVICE_SEARCH_COMP ............................................................................... 63 5.3.16 RBLE_GAP_EVENT_DEVICE_SEARCH_RESULT_IND .................................................................. 64 5.3.17 RBLE_GAP_EVENT_RPA_RESOLVED .............................................................................................. 64 5.3.18 RBLE_GAP_EVENT_SET_RANDOM_ADDRESS_COMP ................................................................ 64 5.3.19 RBLE_GAP_EVENT_SET_PRIVACY_FEATURE_COMP ................................................................. 65 5.3.20 RBLE_GAP_EVENT_CONNECTION_COMP ..................................................................................... 65 5.3.21 RBLE_GAP_EVENT_CONNECTION_CANCEL_COMP ................................................................... 65 5.3.22 RBLE_GAP_EVENT_DISCONNECT_COMP ...................................................................................... 66 5.3.23 RBLE_GAP_EVENT_ADVERTISING_REPORT_IND ....................................................................... 66 5.3.24 RBLE_GAP_EVENT_BONDING_COMP ............................................................................................. 67 5.3.25 RBLE_GAP_EVENT_BONDING_REQ_IND ....................................................................................... 68 5.3.26 RBLE_GAP_EVENT_CHANGE_CONNECTION_PARAM_REQ_IND ............................................. 69 5.3.27 RBLE_GAP_EVENT_CHANGE_CONNECTION_PARAM_COMP .................................................. 69 5.3.28 RBLE_GAP_EVENT_CHANGE_CONNECTION_PARAM_RESPONSE .......................................... 69 5.3.29 RBLE_GAP_EVENT_CHANNEL_MAP_REQ_COMP ....................................................................... 70 5.3.30 RBLE_GAP_EVENT_READ_RSSI_COMP .......................................................................................... 70 5.3.31 RBLE_GAP_EVENT_WR_CHAR_IND ................................................................................................ 70 5.3.32 RBLE_GAP_EVENT_COMMAND_DISALLOWED_IND .................................................................. 70 6. Security Manager ........................................................................................................................................ 71 6.1 Definitions ........................................................................................................................................................ 71 6.2 Functions .......................................................................................................................................................... 75 6.2.1 RBLE_SM_Set_Key ................................................................................................................................ 76 6.2.2 RBLE_SM_Start_Enc .............................................................................................................................. 76 6.2.3 RBLE_SM_Tk_Req_Resp ....................................................................................................................... 77 6.2.4 RBLE_SM_Ltk_Req_Resp ..................................................................................................................... 78 6.2.5 RBLE_SM_Irk_Req_Resp ...................................................................................................................... 79 6.2.6 RBLE_SM_Csrk_Req_Resp.................................................................................................................... 80 6.2.7 RBLE_SM_Chk_Bd_Addr_Req_Resp .................................................................................................... 81 6.3 Events ............................................................................................................................................................... 82 6.3.1 RBLE_SM_EVENT_SET_CNF .............................................................................................................. 83 6.3.2 RBLE_SM_ENC_START_IND .............................................................................................................. 83 6.3.3 RBLE_SM_TK_REQ_IND ..................................................................................................................... 83 6.3.4 RBLE_SM_LTK_REQ_IND ................................................................................................................... 84 6.3.5 RBLE_SM_LTK_REQ_FOR_ENC_IND ............................................................................................... 85 6.3.6 RBLE_SM_IRK_REQ_IND ................................................................................................................... 85 6.3.7 RBLE_SM_CSRK_REQ_IND ................................................................................................................ 86 6.3.8 RBLE_SM_KEY_IND ............................................................................................................................ 86 Index-3 6.3.9 RBLE_SM_CHK_BD_ADDR_REQ ...................................................................................................... 86 6.3.10 RBLE_SM_TIMEOUT_EVT .................................................................................................................. 87 6.3.11 RBLE_SM_EVENT_COMMAND_ERROR_IND ................................................................................. 87 7. Generic Attribute Profile .............................................................................................................................. 88 7.1 Definitions ........................................................................................................................................................ 88 7.2 Functions ........................................................................................................................................................ 102 7.2.1 RBLE_GATT_Enable ........................................................................................................................... 103 7.2.2 RBLE_GATT_Discovery_Service_Request ......................................................................................... 104 7.2.3 RBLE_GATT_Discovery_Char_Request .............................................................................................. 105 7.2.4 RBLE_GATT_Discovery_Char_Descriptor_Request ........................................................................... 106 7.2.5 RBLE_GATT_Read_Char_Request ...................................................................................................... 107 7.2.6 RBLE_GATT_Write_Char_Request ..................................................................................................... 109 7.2.7 RBLE_GATT_Write_Reliable_Request ............................................................................................... 110 7.2.8 RBLE_GATT_Execute_Write_Char_Request ...................................................................................... 110 7.2.9 RBLE_GATT_Notify_Request ............................................................................................................. 111 7.2.10 RBLE_GATT_Indicate_Request ........................................................................................................... 111 7.2.11 RBLE_GATT_Write_Response ............................................................................................................ 111 7.2.12 RBLE_GATT_Set_Permission .............................................................................................................. 112 7.2.13 RBLE_GATT_Set_Data ........................................................................................................................ 112 7.3 Events ............................................................................................................................................................. 113 7.3.1 RBLE_GATT_EVENT_DISC_SVC_ALL_CMP ................................................................................. 114 7.3.2 RBLE_GATT_EVENT_DISC_SVC_ALL_128_CMP ......................................................................... 114 7.3.3 RBLE_GATT_EVENT_DISC_SVC_BY_UUID_CMP ....................................................................... 115 7.3.4 RBLE_GATT_EVENT_DISC_SVC_INCL_CMP ............................................................................... 115 7.3.5 RBLE_GATT_EVENT_DISC_CHAR_ALL_CMP ............................................................................. 116 7.3.6 RBLE_GATT_EVENT_DISC_CHAR_ALL_128_CMP ..................................................................... 116 7.3.7 RBLE_GATT_EVENT_DISC_CHAR_BY_UUID_CMP .................................................................... 117 7.3.8 RBLE_GATT_EVENT_DISC_CHAR_BY_UUID_128_CMP ............................................................ 117 7.3.9 RBLE_GATT_EVENT_DISC_CHAR_DESC_CMP ........................................................................... 118 7.3.10 RBLE_GATT_EVENT_DISC_CHAR_DESC_128_CMP ................................................................... 118 7.3.11 RBLE_GATT_EVENT_READ_CHAR_RESP .................................................................................... 118 7.3.12 RBLE_GATT_EVENT_READ_CHAR_LONG_RESP ....................................................................... 119 7.3.13 RBLE_GATT_EVENT_READ_CHAR_MULT_RESP ....................................................................... 119 7.3.14 RBLE_GATT_EVENT_READ_CHAR_LONG_DESC_RESP ........................................................... 120 7.3.15 RBLE_GATT_EVENT_WRITE_CHAR_RESP .................................................................................. 120 7.3.16 RBLE_GATT_EVENT_WRITE_CHAR_RELIABLE_RESP ............................................................. 120 7.3.17 RBLE_GATT_EVENT_CANCEL_WRITE_CHAR_RESP ................................................................. 120 Index-4
Description: