background image

105

SWRU271H – October 2010 – Revised April 2019

Submit Documentation Feedback

Copyright © 2010–2019, Texas Instruments Incorporated

GAP API

Appendix A

SWRU271H – October 2010 – Revised April 2019

GAP API

A.1

Commands

This section details the GAP commands from gap.h which the application uses. Other GAP commands
are abstracted through the GAPRole or the GAPBondMgr.

uint16 GAP_GetParamValue (gapParamIDs_t paramID)

Get a GAP parameter.

Parameters

paramID – parameter ID (

Section A.2

)

Returns

GAP Parameter Value if successful

0xFFFF if paramID invalid

bStatus_t GAP_SetParamValue (gapParamIDs_t paramID, uint16 paramValue)

Set a GAP parameter.

Parameters

paramID – parameter ID (Section A.2)

paramValue – new param value

Returns

SUCCESS

INVALIDPARAMETER: paramID is invalid

A.2

Configurable Parameters

ParamID

Description

TGAP_GEN_DISC_ADV_MIN

Minimum time (ms) to remain advertising in Discovery mode.
Setting this to 0 turns off this time-out, thus advertising
infinitely. Default is 0.

TGAP_LIM_ADV_TIMEOUT

Maximum time (sec) to remain advertising in Limited Discovery
mode. Default is 180 seconds.

TGAP_GEN_DISC_SCAN

Minimum time (ms) to perform scanning for General Discovery

TGAP_LIM_DISC_SCAN

Minimum time (ms) to perform scanning for Limited Discovery

TGAP_CONN_EST_ADV_TIMEOUT

Advertising time-out (ms) when performing Connection
Establishment

TGAP_CONN_PARAM_TIMEOUT

Time-out (ms) for link layer to wait to receive connection
parameter update response

TGAP_LIM_DISC_ADV_INT_MIN

Minimum advertising interval in limited discovery mode
(n × 0.625 ms)

TGAP_LIM_DISC_ADV_INT_MAX

Maximum advertising interval in limited discovery mode
(n × 0.625 ms)

TGAP_GEN_DISC_ADV_INT_MIN

Minimum advertising interval in general discovery mode
(n × 0.625 ms)

TGAP_GEN_DISC_ADV_INT_MAX

Maximum advertising interval in general discovery mode
(n × 0.625 ms)

TGAP_CONN_ADV_INT_MIN

Minimum advertising interval when in connectable mode
(n × 0.625 ms)

Summary of Contents for CC2540

Page 1: ...CC2540 and CC2541 Bluetooth Low Energy Software Developers Guide Literature Number SWRU271H October 2010 Revised April 2019 ...

Page 2: ...ew 20 4 2 Project Overview 20 4 3 Start up in main 22 4 4 Application Initialization 23 4 5 Event Processing 23 4 5 1 Periodic Event 23 4 5 2 OSAL Messages 24 4 6 Callbacks 24 4 7 Complete Attribute Table 25 4 8 Additional Sample Projects 26 5 The Bluetooth Low Energy Protocol Stack 27 5 1 Overview 27 5 2 Generic Access Profile GAP 27 5 2 1 Overview 27 5 2 2 GAP Abstraction 31 5 2 3 Configuring th...

Page 3: ...sting for 32 MHz Crystal Stabilization Time 69 7 6 3 Setting the Sleep Clock Accuracy 69 7 7 Software Considerations 69 7 7 1 Memory Management for GATT Notifications and Indications 69 7 7 2 Limit Application Processing During Bluetooth Low Energy Activity 70 7 7 3 Global Interrupts 70 8 Development and Debugging 71 8 1 Overview 71 8 2 IAR Overview 71 8 3 Using IAR Embedded Workbench 71 8 3 1 Ope...

Page 4: ...s 121 C 3 Callbacks 121 C 3 1 RSSI Callback rssiCB 121 C 3 2 Central Event Callback eventCB 122 D GATT ATT API 123 D 1 Overview 123 D 2 Server Commands 123 D 3 Client Commands 124 D 4 Return Values 130 D 5 Events 131 D 6 GATT Commands and Corresponding ATT Events 133 D 7 ATT_ERROR_RSP Error Codes 133 E GATTServApp API 135 E 1 Overview 135 E 2 Commands 135 F GAPBondMgr API 137 F 1 Overview 137 F 2 ...

Page 5: ...rver 45 5 9 simpleGATTProfile Characteristic Table from BTool 46 5 10 GATT Client Abstraction 48 5 11 GATT Server Abstraction 51 5 12 Attribute Table Initialization 52 5 13 Get and Set Profile Parameter Usage 61 6 1 HAL Drivers 65 8 1 IAR Embedded Workbench 72 8 2 Project Configurations and Options 73 8 3 Project Configurations 73 8 4 Preprocessor Defined Symbols Settings 74 8 5 The buildConfig h ...

Page 6: ...ised April 2019 Submit Documentation Feedback Copyright 2010 2019 Texas Instruments Incorporated List of Tables List of Tables 5 1 GAP Bond Manager Security Terms 37 5 2 Supported BLE Stack Library Configurations 63 G 1 Host Error Codes 160 ...

Page 7: ... Remote Control Quick Start Guide INSTALL Documents TI_CC2541_ARC_Quick_Start_Guide pdf 4 Advanced Remote Control User s Guide INSTALL Documents TI_CC2541_ARC_User_Guide pdf 5 TI CC2540 Bluetooth Low Energy Sample Applications Guide INSTALL Documents TI_BLE_Sample_Applications_Guide pdf 6 Universal Bootloader UBL Guide INSTALL Documents Universal Boot Loader for SOC 8051 by USB MSD Developer s Gui...

Page 8: ...41 documentation using the v1 5 x release refer to functionality only For an overview of TI devices that implement features defined by newer Bluetooth specifications see www ti com ble 1 2 Introduction The beginning Version 4 0 of the Bluetooth standard allows for two systems of wireless technology Bluetooth Basic Rate Enhanced Data Rate often referred to as BR EDR or Classic Bluetooth Bluetooth L...

Page 9: ...troller and the host This separation of controller and host derives from standard Bluetooth BR EDR devices where the two sections were often implemented separately Profiles and applications are implemented in Figure 1 1 of the generic access protocol GAP and generic attribute protocol GATT layers of the protocol stack The physical layer PHY is a 1 Mbps adaptive frequency hopping Gaussian Frequency...

Page 10: ...rd HCI commands and events The TI BLE Vendor Specific HCI Reference Guide specifies the TI proprietary commands and events The link logical control and adaption protocol L2CAP layer provides data encapsulation services to the upper layers allowing for logical end to end communication of data For more information on TI s implementation of the L2CAP layer see Section 5 6 The security manager SM laye...

Page 11: ...mbines a 2 4 GHz RF transceiver microcontroller up to 256KB of in system programmable memory 8KB of RAM and a full range of peripherals 2 2 Configurations The platform supports two different stack and application configurations Single Device The controller host profiles and application are implemented on the CC2540 41 as a true single chip solution This configuration is the simplest and most commo...

Page 12: ...om 12 SWRU271H October 2010 Revised April 2019 Submit Documentation Feedback Copyright 2010 2019 Texas Instruments Incorporated The TI Bluetooth Low Energy Software Development Platform Figure 2 1 Single Device Configuration ...

Page 13: ...ately on an external host processor The application and profiles communicate with the CC2540 41 through vendor specific HCI commands using an SPI a UART interface or a virtual UART interface over USB This configuration is optimal for applications that execute on another device such as an external microcontroller or a PC When using this type of application you can develop it externally while runnin...

Page 14: ...ergy development kit includes other sample projects These projects implement various profiles and demonstration applications For more information on these other projects see the TI CC2540 Bluetooth low energy Sample Applications Guide 2 4 Software Overview Software developed using the Bluetooth Low Energy software development kit consists of following five major components OSAL HAL The Bluetooth L...

Page 15: ...ets software set up how events should execute Each layer of software functions as a task and requires a task identifier ID a task initialization routine and an event processing routine You can also define a message processing routine These layers must adhere to a priority scheme with the LL as the highest priority because of its timing requirements The following is the hierarchy from the SimpleBLE...

Page 16: ...OSAL must have an initialization routine called from the function osalInitTasks Within this function the initialization routine for every layer of software is called within the osalInitTasks As each task initialization routine is called an 8 bit task ID value is assigned to the task The task ID determines the priority of the tasks The task ID gives lower values higher priority The protocol stack t...

Page 17: ...Peripheral application defines a flag in simpleBLEPeripheral h SBP_START_DEVICE_EVT 0x0001 indicating the initial device start is complete the application processing begins The application cannot define one reserved flag value 0x8000 This value corresponds to the event SYS_EVENT_MSG for messaging between tasks For more information see Section 3 5 When the OSAL detects an event set for a task it ca...

Page 18: ...parameter that you must use to input a time out value in milliseconds This timeout parameter causes the OSAL to set a timer and set the specified event when the timer expires 3 4 Heap Manager Th eOSAL provides basic memory management functions The osal_mem_alloc function can allocate memory similarly to the standard C malloc function The OSAL function takes a single parameter specifying the number...

Page 19: ...uffer 3 Call osal_msg_send specifying the destination task ID and pointer to the message to be sent The following code shows an example from OnBoard c The OSAL sets the SYS_EVENT_MSG flag for the receiving task that a message indicating that an incoming message is available This flag results in the event handler being invoked for the receiving task The receiving task retrieves the data by calling ...

Page 20: ... Overview The Bluetooth Low Energy software development kit contains a sample project SimpleBLEPeripheral that implements a basic Bluetooth Low Energy peripheral device This project is built using the single device stack configuration with the stack profiles and application running on the CC2540 41 4 2 Project Overview On the left side of the IAR window the Workspace section lists the files used b...

Page 21: ...sport layer that allows you to route HCI data to a serial interface CC254X_BLE_HCI_TL_Full lib must be included for this capability see the HostTest project in the SDK If not used the CC254X_BLE_HCI_TL_None lib should be used see SimpleBLEPeripheral in the SDK when developing a single chip application OSAL This group contains the OSAL source code and header files For more information on the OSAL s...

Page 22: ...n and Profiles 4 3 Start up in main The main function in SimpleBLEPeripheral_Main c is the starting point at runtime This function brings up the board and initializes the OSAL and SNV drivers Next this function initializes power management and creates the tasks Finally the function calls the osal_start_system which starts the processing loop OSAL and does not return ...

Page 23: ...ripheral device receives no connection request the device remains discoverable for 30 72 seconds before going into a standby state The project also includes the simpleGATTProfile service A connected central device operating as a GATT client can perform characteristic reads and writes on simpleGATTProfile characteristic values The device can also enable notifications of one of the characteristics 4...

Page 24: ... the keyfob HAL sends an OSAL message to the application As Section 3 5 describes this action causes a SYS_EVENT_MSG event to occur This event is handled in the application by the function simpleBLEperipheral_ProcessOSALMsg In the current SimpleBLEPeripheral application the KEY_CHANGE message is the only recognized OSAL message type You can define additional message types The KEY_CHANGE message ev...

Page 25: ...ocess for adding profiles and services to the application Figure 4 2 shows the complete attributes of the SimpleBLEPeripheral and can be a reference when communicating wirelessly with the device Services are red Characteristic descriptors are yellow General attributes are white For more details see Section 5 5 When working with the SimpleBLEPeripheral application print Figure 4 2 as a reference Fi...

Page 26: ...2019 Texas Instruments Incorporated The Application and Profiles 4 8 Additional Sample Projects The Bluetooth Low Energy development kit includes several sample projects implementing profiles such as the following A heart rate monitor A health thermometer A proximity key fob For more information on these projects see Chapter 5 ...

Page 27: ... files TI does not provide the protocol stack source code TI intends the functionality of these layers to be understood as they interact directly with the application and profiles 5 2 Generic Access Profile GAP 5 2 1 Overview The GAP layer of the Bluetooth Low Energy protocol stack defines the behavior of devices performing the following actions Device discovery Link establishment Link termination...

Page 28: ...ection parameters when the connection is formed Master or Slave If the device was the advertiser it becomes a slave after connecting If the device was the initiator it becomes a master after connecting 5 2 1 1 Connection Parameters This section describes the connection parameters sent by the initiating device with the connection request These parameters can be modified by either device when the co...

Page 29: ...nts If this time period passes without a successful connection event the device considers the connection lost and returns to an unconnected state This parameter value is represented in units of 10 ms The supervision time out value can range from a minimum of 10 100 ms to 3200 32 seconds The time out must be larger than the effective connection interval For more details see Section 5 2 1 2 5 2 1 2 ...

Page 30: ...it to zero will do the following Increase the power consumed by the peripheral device Reduce the amount of time required to send data from the central device to the peripheral device Increasing the slave latency will do the following Reduce the power consumed by the peripheral device when it has no data to send to the central device Increase the amount of time required to send data from the centra...

Page 31: ...5 4 Figure 5 4 GAP Abstraction Configure the GAPRole module and use its APIs to interface with the GAP layer Section 5 2 3 describes the functions and parameters not handled or configured through the GAPRole task These functions and parameters must be modified directly through the GAP layer 5 2 3 Configuring the GAP Layer The GAP layer functionality is defined mostly in library code You can find t...

Page 32: ...nectable Observer scans for advertisements but cannot initiate connections Peripheral an advertiser that is connectable and operates as a slave in a single link layer connection Central scans for advertisements and initiates connections and operates as a master in a single or multiple link layer connections The Bluetooth Low Energy central protocol stack supports up to three simultaneous connectio...

Page 33: ... functions Section B 3 defines these callbacks 3 Send GAPRole commands from the application The following is an example of the application using GAPRole_TerminateConnection NOTE The return value from the Bluetooth Low Energy protocol stack only indicates whether the attempt to terminate the connection was initiated successfully The termination of connection event sent to the application asynchrono...

Page 34: ...orated The Bluetooth Low Energy Protocol Stack 4 The GAPRole task processes most of the GAP related events passed to it from the Bluetooth Low Energy protocol stack The task forwards some events to the application The following is an example tracing the GAP_LINK_TERMINATED_EVENT from the Bluetooth Low Energy protocol stack to the application ...

Page 35: ...ation function that is SimpleBLECentral_init 2 Initialize the GAPRole task Do this initialization when processing START DEVICE EVT This initialization involves passing function pointers to application callback functions Section C 3 defines these callbacks 3 Send GAPRole commands from the application The following is an example of the application using GAPCentralRole_StartDiscovery NOTE The return ...

Page 36: ...orated The Bluetooth Low Energy Protocol Stack 4 The GAPRole task processes some of the GAP related events passed to it from the Bluetooth Low Energy protocol stack The task forwards some events to the application The following is an example tracing the GAP_DEVICE_DISCOVERY_EVENT from the Bluetooth Low Energy protocol stack to the application ...

Page 37: ...te a key 2 Encrypt the link with keys from step 1 3 Bond the keys store keys in secure flash SNV 4 When reconnected use the keys stored in SNV to encrypt the link NOTE You can skip steps For example you can to skip bonding and just re pair after reconnecting The GAPBondMgr uses the SNV flash area to store bond information For more information on SNV see Section 6 10 5 4 1 Overview of Bluetooth Low...

Page 38: ...om the GAPBondMgr 1 Initialize the GAPBondMgr parameters Do this in the application initialization function that is SimpleBLECentral_init Consider the following parameters For the example the pairMode has been changed to initiate pairing 2 Register application callbacks with the GAPBondMgr Do this registration after the GAPRole starts in the START_DEVICE_EVT processing The GAPBondMgr is configured...

Page 39: ...ww ti com Gap Bond Manager GAPBondMgr 39 SWRU271H October 2010 Revised April 2019 Submit Documentation Feedback Copyright 2010 2019 Texas Instruments Incorporated The Bluetooth Low Energy Protocol Stack ...

Page 40: ... are present for the security mode For more information on how input and output capabilities affect pairing see the Specification of the Bluetooth System Covered Core Package version 4 0 30 June 2010 5 4 3 1 Pairing Disabled With pairing set to FALSE the protocol stack rejects any attempt to pair 5 4 3 2 Just Works Pairing Without Bonding Just Works pairing encrypts without MITM authentication and...

Page 41: ...tooth Low Energy Protocol Stack The GAPBondMgr pairing states are passed to the application callback when required during the pairing process GAPBOND_PAIRING_STATE_STARTED is passed when sent or received by the stack GAPBOND_PAIRING_STATE_COMPLETE is sent when the pairing completes A Just Works pairing requires the pair state callback For more information see Section F 4 ...

Page 42: ...right 2010 2019 Texas Instruments Incorporated The Bluetooth Low Energy Protocol Stack 5 4 3 3 Just Works Pairing With Bonding Enabled To enable bonding with a Just Works pairing use the following settings For an overview of this process for peripheral device see Figure 5 6 Figure 5 6 Bonding After Just Works Pairing ...

Page 43: ...enticated pairing requires MITM protection This method is a way of transferring a passcode between the devices The passcode cannot transmit wirelessly and is displayed on one device typically on an LCD screen or a serial number on the device and entered on the other device To pair with MITM authentication use the following settings This method requires an additional step in the security process in...

Page 44: ... following callback to request a passcode from the application Depending on the input and output capabilities of the devices the callback function should either display a passcode or read in an entered passcode This passcode must be sent by the application to the GAPBondMgr using the GAPBondMgr_PasscodeRsp function The following is an example of the SimpleBLECentral In the previous example a rando...

Page 45: ...A device can also act as both a GATT client and a GATT server 5 5 1 GATT Characteristics and Attributes While characteristics are sometimes interchangeable when referring to Bluetooth Low Energy consider them as groups of information called attributes Attributes are the base groups of information transferred between devices Characteristics organize and use attributes as data values properties and ...

Page 46: ...t into the stack library Mandatory GATT Service This service contains information about the GATT server and is a part of the Bluetooth Low Energy protocol stack This service is required for every GATT server device per the Bluetooth Low Energy specification The source code for this service is not provided but is built into the stack library Device Information Service This service exposes informati...

Page 47: ...te 0 the properties of the SIMPLEPROFILE_CHAR1 These properties are defined in the Bluetooth specification 13 The following are a few of the relevant properties 0x02 Permits reads of the characteristic value 0x04 Permits writes of the characteristic value without a response 0x08 Permits writes of the characteristic value with a response 0x10 Permits of notifications of the characteristic value wit...

Page 48: ...3 1 Using the GATT Layer Directly This section describes how to use the GATT layer directly in the application The functionality of the GATT layer is implemented in the library code but you can find the header functions can in gatt h You can find the complete API for the GATT layer in Appendix D You can find more information on the functionality of these commands in the Device Information Service ...

Page 49: ...Submit Documentation Feedback Copyright 2010 2019 Texas Instruments Incorporated The Bluetooth Low Energy Protocol Stack 3 Perform a GATT client procedure The following example uses GATT_WriteCharValue which is triggered by pressing the key on the left in the SimpleBLECentral application ...

Page 50: ...ient procedure in the application In the following example the application receives an ATT_WRITE_RSP event For a list of GATT commands and their corresponding ATT events see Section D 6 NOTE Though the event sent to the application is an ATT event it is sent as a GATT protocol stack message GATT_MSG_EVENT Besides receiving responses to its own commands a GATT client may also receive asynchronous d...

Page 51: ...he GATT layer With a GATT server direct calls to GATT layer functions are unnecessary The application interfaces with the profiles 5 5 4 1 GATTServApp Module The GATTServApp module stores and manages the application wide attribute table Various profiles use the table to add their characteristics to the attribute table The Bluetooth Low Energy stack uses the table to respond to discovery requests f...

Page 52: ...ssions and read write call backs Figure 5 12 shows that this information is passed through the GATTServApp to GATT and stored in the stack Do this in the application initialization function that is simpleBLEPeripheral_init Figure 5 12 Attribute Table Initialization 5 5 4 2 Profile Architecture This section describes the architecture for profiles and provides functional examples of the simpleGATTPr...

Page 53: ...in gatt_uuid c or a custom UUID in the profile Permissions This element enforces how and if a GATT client device can access the value of the attribute Possible permissions are defined in gatt h as the following GATT_PERMIT_READ Attribute is Readable GATT_PERMIT_WRITE Attribute is Writable GATT_PERMIT_AUTHEN_READ Read requires Authentication GATT_PERMIT_AUTHEN_WRITE Write requires Authentication GA...

Page 54: ...pleGATTProfile simpleProfileCharacteristic1 declaration The type is set to the Bluetooth SIG defined characteristic UUID 0x2803 A GATT client must read the UUID so the permission must be set to GATT_PERMIT_READ Section 5 5 1 describes the value of a characteristic declaration The pointer to the properties of the characteristic value is passed to the GATTServApp in pValue The GATTServApp adds the U...

Page 55: ...are not set to readable and writable errors occur The pValue is a pointer to the location of the actual value This value is statically defined in the profile as follows 5 5 4 2 1 4 Client Characteristic Configuration Consider the simpleGATTProfile simpleProfileCharacteristic4 configuration The type is set to the Bluetooth SIG defined client characteristic configuration UUID 0x2902 GATT clients mus...

Page 56: ...f these arrays initialized in the profile In the AddService function several supported connections are declared and memory is allocated for each array One CCC is defined in the simpleGATTProfile but the profile may contain additional CCCs Initialize the CCC arrays CCC values do not change between power downs and bonded device connections because they are stored in NV For each CCC in the profile th...

Page 57: ...is the register application callback function of the simpleGATTProfile Where the typedef callback is defined as follows The application must define a callback of this type and pass it to the simpleGATTProfile with the SimpleProfile_RegisterAppCBs function The application does this in simpleBLEPeripheral c through the following For the mechanism of how this callback is used see Section 5 5 4 2 4 5 ...

Page 58: ...e is readable the protocol stack calls the read call back of the profile The profile must copy the value perform any profile specific processing and notify the application if applicable The following flow diagram shows the processing workflow for a read of SIMPLEPROFILE_CHAR1 in the simpleGATTProfile NOTE Consider the processing in this section in the context of the protocol stack If any intensive...

Page 59: ... given attribute the protocol stack will check the permissions of the attribute If the attribute is write call the write callback of the profile The profile stores the value to be written performs any profile specific processing and notifies the application if applicable The following flow diagram illustrates a write of simpleprofileChar3 in the simpleGATTProfile In the diagram red corresponds to ...

Page 60: ... Copyright 2010 2019 Texas Instruments Incorporated The Bluetooth Low Energy Protocol Stack NOTE Minimize the processing done in the stack task Set an application so processing can complete in the application task if extensive additional processing beyond storing the attribute write value in the profile is required ...

Page 61: ...c has notify and or indicate properties Figure 5 13 and the following code depict how to set the simpleProfileChacteristic4 in the simpleGATTProfile Figure 5 13 Get and Set Profile Parameter Usage The application initializes simpleProfileCharacteristic4 to 0 in SimpleBLEPeripheral c through the following The code for this function is displayed in the following code from simpleGATTProfile c Other t...

Page 62: ...sor application the HCI layer is implemented by a transport protocol such as SPI or UART In embedded SoC projects the HCI layer is implemented through function calls and callbacks The commands and events discussed previously in this guide pass from the given layer through the HCI layer to the controller and through the controller to the HCI layer 5 7 1 HCI Extension Vendor Specific Commands Some H...

Page 63: ...ed BLE Stack Library Configurations Configuration GAP Roles Supported Chipset Library Broadcaster Observer Peripheral Central Network processor X X X X CC2540 CC2540_BLE lib CC254X_BLE_HCI_TL_Full lib Single device X X X X CC2540 CC2540_BLE lib Single device X CC2540 CC2540_BLE_bcast lib Single device X X CC2540 CC2540_BLE_ bcast_observ lib Single device X X CC2540 CC2540_BLE_cent lib Single devic...

Page 64: ...e such as a new PCB without making changes to the protocol stack or application source code The HAL includes software for the SPI and UART communication interfaces AES keys LCD and LEDs The HAL drivers that support the following hardware platforms include the following SmartRF05EB CC2540EM SmartRF05EB CC2541EM CC2540 Keyfob CC2541 Keyfob CC2541 SensorTag CC2540 USB Dongle When developing with a di...

Page 65: ...www ti com Overview 65 SWRU271H October 2010 Revised April 2019 Submit Documentation Feedback Copyright 2010 2019 Texas Instruments Incorporated Drivers Figure 6 1 HAL Drivers ...

Page 66: ...reprocessor definitions TI designed the driver to function with the LEDs on the key fob You must modify parts of the driver such as the LED bit definitions in hal_led c to use it with custom hardware For an example using the LED driver see the CC2540 1 DK miniKeyfob in the SimpleBLEPeripheral project 6 6 KEY The KEY driver handles button inputs To include the KEY driver define HAL_KEY TRUE in the ...

Page 67: ...r has 80 invalidated data A compaction is copying valid data to a temporary area then erasing the sector where the data was stored The SNV driver uses the hal_flash driver SNV can be read from or written to using the following APIs uint8 osal_snv_read osalSnvId_t id osalSnvLen_t len void pBuf Read data from NV Parameters id valid NV item len Length of data to read pBuf pointer to buffer to store d...

Page 68: ...pleBLECentral SimpleBLEPeripheral SimpleBLEBroadcaster SimpleBLEObserver When deciding the role and purpose of the application choose from the appropriate libraries in Section 5 8 7 3 Define Bluetooth Low Energy Behavior Use the Bluetooth Low Energy protocol stack APIs to define the system behavior such as adding profiles defining the GATT database configuring the security model and so forth Use t...

Page 69: ...s buffer time is implemented using the HAL_SLEEP_ADJ_TICKS definition where the value of the definition corresponds to the number of 32 MHz ticks This definition is set in hal_sleep c to 25 for the CC2541 EM and 35 for the CC2540 EM by default If the value of the definition is larger the buffer time is longer and more power is wasted Calculate this value empirically If HAL_SLEEP_ADJ_TICKS is set t...

Page 70: ... event If the controller does not get process advertising restarts or the connection drops Because OSAL is not multithreaded each task must stop processing to let the controller process The stack layers do not have this issue Ensure that the application processes less than the following connection advertising interval 2 ms The 2 ms are added as buffer to account for controller processing time If e...

Page 71: ...struments ti wireless Download IAR Embedded Workbench 30 day Evaluation Edition This version of IAR is free and fully functional for 30 days This version includes the standard features Purchase the full featured version of IAR Embedded Workbench For complete Bluetooth Low Energy application development using the CC2540 41 TI recommends the complete version of IAR without restrictions 8 3 Using IAR...

Page 72: ...10 2019 Texas Instruments Incorporated Development and Debugging This file is the workspace for the SimpleBLEPeripheral project When you select this file the files associated with the workspace should also open with a list of files on the left side For the IAR Embedded Workbench see Figure 8 1 Figure 8 1 IAR Embedded Workbench ...

Page 73: ...g Options a window will pop up displaying the project options You might need to have a few different configurations of options for different setups like when using multiple hardware platforms The IAR lets you create configurations You can select these configurations through the drop down menu in the top of the Workspace pane see Figure 8 2 The default configuration in the SimpleBLEPeripheral proje...

Page 74: ...important settings when building a project see Figure 8 4 You can find and set these values by doing the following 1 Click the C C Compiler category on the left 2 Click the Preprocessor tab on the right Figure 8 4 Preprocessor Defined Symbols Settings When preceded by an x the symbol has no valid definition and can be considered disabled Removing the preceding x to restore the proper name of the s...

Page 75: ...iler settings let you set up the configuration files to be included You must include the config cfg file with every build because it defines some required universal constants The buildConfig h file included with the software development kit defines the appropriate symbols for the project see Figure 8 5 Figure 8 5 The buildConfig h File Select the Use command line option box through the Extra Optio...

Page 76: ...ree of any pending tasks PLUS_BROADCASTER This symbol indicates that the device is using the GAP Peripheral Broadcaster multirole profile rather than the single GAP Peripheral role profile The default option in the simpleBLEPeripheral project is undefined HAL_LCD This symbol indicates whether to include and use the LCD driver when set to TRUE If not defined it is set to TRUE HAL_LED This symbol in...

Page 77: ...ing 1 Right click on the workspace name see Figure 8 7 Figure 8 7 Building a Project 2 Click Make or press F7 NOTE This action compiles the source code links the files and builds the project Any compiler errors or warnings appear in the Build window 3 To download the compiled code onto a CC2540 41 device and debug connect the keyfob using a hardware debugger such as the CC Debugger included with t...

Page 78: ...ide of the IAR window see Figure 8 8 Figure 8 8 Debug Button in IAR NOTE If there are multiple debug devices connected Figure 8 9 appears to select a device Figure 8 9 Target Selection 5 Select a device NOTE After selecting a device the code downloads When the code is downloaded a toolbar with the debug commands appears in the upper left corner of the screen 6 Click the Go button on the toolbar to...

Page 79: ...Debugging button to leave debugging mode Figure 8 10 shows both of these buttons Figure 8 10 IAR Debug Toolbar 8 While the program executes disconnect the hardware debugger from the CC2540 41 The debugger runs while the device remains powered 8 3 4 Linker Map File After building a project IAR generates a linker map file that you can find in the Output group in the file list Figure 8 11 Map File in...

Page 80: ...e Warnings none This text shows the total code space CODE memory and RAM XDATA memory the project uses Ensure the sum of the CODE memory plus CONST memory does not exceed the maximum flash size of the device either 128KB or 256KB depending on the version of the CC2540 41 Ensure the size of the XDATA memory does not exceed 7936 bytes as the CC2540 41 contains 8KB of SRAM 256 bytes are reserved For ...

Page 81: ...he following files folders from a clean unmodified 1 5 0 installation to your existing 1 4 2 installation When prompted overwrite replace the existing files with the newer 1 5 0 files Both 1 4 2 and 1 5 0 utilize the same file path structure and naming All paths are relative to BLE_INSTALL which is the root installation of the SDK for example C Texas Instruments BLE CC254x 1 5 0 a All sub folders ...

Page 82: ...ct to BLE v1 4 1 The following steps apply to projects already running BLE v 1 4 1 2 Copy all library files from the BLE v1 4 2 SDK to the existing BLE v1 4 1 SDK installation The libraries are located at 1 4 2_INSTALL Projects ble Libraries Where the default 1 4 2_INSTALL path is C Texas Instruments BLE CC254x 1 4 2 2 The entire v1 4 2 Libraries folder can be copy pasted to the v1 4 1 installatio...

Page 83: ... pAttr uint8 pValue uint8 len uint16 offset uint8 method Also the GAP_RegisterForHCIMsgs command has been changed to GAP_RegisterForMsgs 9 3 2 3 Typedef Changes The Central Event Callback function in the Central GAPRole has changed from typedef void pfnGapCentralRoleEventCB_t gapCentralRoleEvent_t pEvent Pointer to event structure to typedef uint8 pfnGapCentralRoleEventCB_t gapCentralRoleEvent_t p...

Page 84: ... int sEncKey 1 Set to distribute slave encryption key unsigned int sIdKey 1 Set to distribute slave identity key unsigned int sSign 1 Set to distribute slave signing key unsigned int sLinkKey 1 Set to derive slave link key from slave LTK unsigned int sReserved 4 Reserved for slave don t use unsigned int mEncKey 1 Set to distribute master encryption key unsigned int mIdKey 1 Set to distribute maste...

Page 85: ...Value noti len 0 len GATT_LOCAL_READ if status SUCCESS noti handle pAttr handle if cccValue GATT_CLIENT_CFG_NOTIFY status GATT_Notification connHandle noti authenticated else GATT_CLIENT_CFG_INDICATE status GATT_Indication connHandle attHandleValueInd_t noti authenticated taskId if status SUCCESS GATT_bm_free gattMsg_t noti ATT_HANDLE_VALUE_NOTI else status bleNoResources This will need to be done...

Page 86: ...SING_EVT All UUID s are now stored in centralized locations gatt_uuid h and gatt_profile_uuid h Also the following API s have changed extern bStatus_t GAP_TerminateLinkReq uint8 taskID uint16 connectionHandle uint8 reason the third parameter reason has been added to allow the application to indicate the termination reason to the connected device The GAPBondMgr_ProcessGAPMsg gapEventHdr_t pMsg func...

Page 87: ...ect This chapter describes how to port a CC2540 Project to work on a CC2541 Similar steps can be taken for the reverse direction 1 Create and select a new CC2540 project configuration based on the CC2541 configuration under Project Edit Configurations Figure 9 1 Edit IAR Project Configuration 2 In the project options under general options in the target tab change the Device to CC2540F256 Figure 9 ...

Page 88: ...r 2010 Revised April 2019 Submit Documentation Feedback Copyright 2010 2019 Texas Instruments Incorporated General Information 3 Under C C Compiler in the Preprocessor tab define CC2540 and make sure CC2541 is not defined Figure 9 3 IAR Project Options Predefined Symbols ...

Page 89: ...ated General Information 4 In the Workspace pane under the TOOLS group open buildConfig cfg and comment out the CC2541 define Figure 9 4 Stack Build Configuration 5 In the Workspace pane under the LIB group exclude the 2541 library by right clicking on CC2541_BLE_peri lib and selecting options Then check Exclude from build Figure 9 5 BLE Library Exclude From Custom Build ...

Page 90: ...r later to ensure pairing compatibility with Android 6 0 Marshmallow devices The included Software Developer s Guide SWRU271G is compatible with this release All projects have been migrated to IAR Embedded Workbench for 8051 v9 10 3 Bug Fixes Fixed an issue where Limited Discoverable advertising doesn t end if the ADV payload length is 31 bytes Fixed an issue where the GATT Client is not able to r...

Page 91: ...veral bug fixes and enhancements The Bluetooth Low Energy protocol stack including both the controller and host was completely retested for v1 4 1 Changes and minor enhancements All projects have been migrated from IAR v8 20 2 to IAR 9 10 3 To build all projects upgrade to IAR v9 10 3 Smarter handling of connection parameter updates with multiple connections GAPRole_SetParameter GAPROLE_ADVERT_DAT...

Page 92: ...November 8 2013 Notices This version of the Texas Instruments Bluetooth Low Energy stack and software is a minor update to the v1 3 2 release It contains some minor bug fixes and a few functional changes The Bluetooth Low Energy protocol stack including both the controller and host was completely retested for v1 4 0 Changes and Enhancements All projects have been migrated from IAR v8 10 4 to IAR 8...

Page 93: ...128 bytes or more will be disregarded by the stack and as such no HCI event will be returned For technical support visit the Texas Instruments Bluetooth Low Energy E2E Forum http e2e ti com support low_power_rf f 538 aspx Version 1 3 2 June 13 2013 Notices This version of the Texas Instruments Bluetooth Low Energy stack and software is a minor update to the v1 3 1 release It contains some minor bu...

Page 94: ...anges It also contains two additional projects for the CC2541 Advanced Remote Control Kit Since none of the profile source code was significantly changed since the v1 3 release no additional re testing of the profiles and sample application were done for v1 3 1 The only exception is the HID over GATT profile which was fully re tested for this release The Bluetooth Low Energy protocol stack includi...

Page 95: ...54x could have timing issues due to the crystal not having time to stabilize Minor bug fixes to GlucoseSensor and GlucoseCollector projects Known Issues Use of the NV memory to save application data or Bluetooth Low Energy Host bonding information during a Bluetooth Low Energy connection may cause an unexpected disconnect The likelihood of this happening increases with frequent usage especially wh...

Page 96: ...as been added as an option for the physical HCI interface It also supports power management by means of the MRDY and SRDY lines The CC2541 configuration of the KeyFobDemo project has been modified to support the new CC2541 keyfob hardware contained in the CC2541DK MINI kit The accelerometer has been changed and a TPS62730 DC DC converter has been added The structure of all projects have been chang...

Page 97: ... Energy E2E Forum http e2e ti com support low_power_rf f 538 aspx Version 1 2 1 Apr 13 2012 Notices This version of the Texas Instruments Bluetooth Low Energy stack and software is a minor update to the v1 2 release It contains some minor enhancements and bug fixes with no API changes or major functional changes Changes and Enhancements When advertising is enabled by calling GAP_MakeDiscoverable t...

Page 98: ...efore has a large code size approx 165kB On the other hand SimpleBLEBroadcaster is configured to only support the GAP broadcaster role and therefore has a very small code size approx 39kB The function GAPRole_SendUpdateParam in peripheral c has been made public to allow a peripheral application to send an L2CAP connection parameter update request at any time The names and configuration of the Blue...

Page 99: ... slave device will now dynamically widen it s Rx window when a previous connection event was missed This improves connection stability by accounting for additional clock drift that may have occurred since the last successful connection event The application now has the capability to change the permissions of the device name in the GAP service by calling GGS_SetParameter and changing the value of t...

Page 100: ... wear algorithm which at some point may cause an NV page erase which can disrupt system real time processing It is therefore recommended that the NV memory be used sparingly or only when a connection is not active Duplicate filtering does not work when scan is used in combination with a connection For technical support visit the Texas Instruments Bluetooth Low Energy E2E Forum http e2e ti com supp...

Page 101: ...ngle is initiating The following additional new controller stack features are included in this release Support for multiple simultaneous connections as a master details above HCI Vendor Specific function HCI_EXT_SetSCACmd allows you to specify the exact sleep clock accuracy as any value from 0 to 500 PPM in order to support any crystal accuracy with optimal power consumption This feature is only a...

Page 102: ... Read Local Supported Features now returns the proper value Use of two advertising channels now works When connecting to a device on the whitelist the correct peer device address is returned to the host The following bugs have been fixed in the host stack Pairing no longer fails when either device is using a static private resolvable or private non resolvable address The following bugs have been f...

Page 103: ... API Guide Install Directory Documents BLE_API_Guide_main htm Vendor Specific HCI Guide Install Directory Documents TI_BLE_Vendor_Specific_HCI_Guide pdf HAL Drive API Guide Install Directory Documents hal HAL Driver API pdf OSAL API Guide Install Directory Documents osal OSAL API pdf The following software projects are included all built using IAR Embedded Workbench v7 51A SimpleBLEPeripheral Inst...

Page 104: ...ware release 1 1b 11 15 2011 Updated for BLEv1 1b software release 1 2 2 13 2012 Updated for BLEv1 2 software release 1 3 1 4 13 2012 Updated for BLEv1 2 1 software release 1 3 12 19 2012 Updated for BLEv1 3 software release 1 3 1 4 5 2013 Updated for BLEv1 3 1 software release 1 3 2 6 12 2013 Updated for BLEv1 3 2 software release 1 4 0 9 12 2013 Updated for BLEv1 4 0 software release 1 4 1 5 15 ...

Page 105: ...remain advertising in Discovery mode Setting this to 0 turns off this time out thus advertising infinitely Default is 0 TGAP_LIM_ADV_TIMEOUT Maximum time sec to remain advertising in Limited Discovery mode Default is 180 seconds TGAP_GEN_DISC_SCAN Minimum time ms to perform scanning for General Discovery TGAP_LIM_DISC_SCAN Minimum time ms to perform scanning for Limited Discovery TGAP_CONN_EST_ADV...

Page 106: ..._INT_MAX Maximum Link Layer connection interval when using Connection Establishment procedure n 1 25 ms TGAP_CONN_EST_SCAN_INT Scan interval used during Link Layer Initiating state when using Connection Establishment procedure n 0 625 ms TGAP_CONN_EST_SCAN_WIND Scan window used during Link Layer Initiating state when using Connection Establishment procedure n 0 625 ms TGAP_CONN_EST_SUPERV_TIMEOUT ...

Page 107: ...opyright 2010 2019 Texas Instruments Incorporated GAP API ParamID Description TGAP_SCAN_RSP_RSSI_MIN Minimum RSSI required for scan responses to be reported to the application Default 127 TGAP_REJECT_CONN_PARAMS Whether or not to reject Connection Parameter Update Request received on Central device Default FALSE ...

Page 108: ...APRole or GAPBondMgr layers Whether they are handled by the GAPRole or GAPBondmgr layers they pass as a GAP_MSG_EVENT with a header The following is a list of the possible headers and the associated events For other definitions in these events see gap h GAP_DEVICE_INIT_DONE_EVENT Sent when the Device Initialization completes GAP_DEVICE_DISCOVERY_EVENT Sent when the Device Discovery Process complet...

Page 109: ...GAP API GAP_END_DISCOVERABLE_DONE_EVENT Sent when the Advertising ends GAP_LINK_ESTABLISHED_EVENT Sent when the Establish Link Request completes GAP_LINK_TERMINATED_EVENT Sent when a connection terminates GAP_LINK_PARAM_UPDATE_EVENT Sent when an Update Parameters Event is received GAP_RANDOM_ADDR_CHANGED_EVENT Sent when a random address changes ...

Page 110: ...e signature counter of the device updates GAP_AUTHENTICATION_COMPLETE_EVENT Sent when the Authentication pairing process completes GAP_PASSKEY_NEEDED_EVENT Sent when a Passkey is needed This is part of the pairing process GAP_SLAVE_REQUESTED_SECURITY_EVENT Sent when a Slave Security Request is received GAP_DEVICE_INFO_EVENT Sent during the Device Discovery Process when a device is discovered ...

Page 111: ...Revised April 2019 Submit Documentation Feedback Copyright 2010 2019 Texas Instruments Incorporated GAP API GAP_BOND_COMPLETE_EVENT Sent when the bonding process completes GAP_PAIRING_REQ_EVENT Sent when an unexpected Pairing Request is received ...

Page 112: ...nnot start connectable advertising because nonconnectable advertising is enabled bStatus_t GAPRole_GetParameter uint16 param void pValue Set a GAP Role parameter Parameters param Profile parameter ID Section B 2 pValue pointer to location to get parameter This is dependent on the parameter ID and will be cast to the appropriate data type Returns SUCCESS INVALIDPARAMETER param was not valid bStatus...

Page 113: ...connection Parameters ConnInterval the new connection interval latency the new slave latency connTimeout the new time out value handleFailure what to do if the update does not occur Available actions GAPROLE_NO_ACTION 0 Take no action upon unsuccessful parameter updates GAPROLE_RESEND_PARAM_UPDATE 1 Continue to resend request until successful update GAPROLE_TERMINATE_LINK 2 Terminate link upon uns...

Page 114: ...CAN_RSP_DATA R W uint8 32 Scan Response data Default is all 0s GAPROLE_ADV_EVENT_TYPE R W uint8 Advertisement type Default is GAP_ADTYPE_IND from gap h GAPROLE_ADV_DIRECT_TYPE R W uint8 Direct advertisement type Default is ADDRTYPE_PUBLIC from gap h GAPROLE_ADV_DIRECT_ADDR R W uint8 6 Direct advertisement address Default is 0 GAPROLE_ADV_CHANNEL_MAP R W uint8 Which channels to advertise on Default...

Page 115: ...callbacks are functions whose pointers are passed from the application to the GAPRole so the GAPRole can return events to the application They are passed as the following For an example see the SimpleBLEPeripheral application B 3 1 State Change Callback pfnStateChange This callback passes the current GAPRole state to the application whenever the state changes This function is of the following type...

Page 116: ...pheral Role API B 3 2 RSSI Callback pfnRssiRead When enabled this function reports the RSSI to the application at a rate set by the GAPROLE_RSSI_READ_RATE GAPRole parameter Setting this parameter to 0 disables the RSSI reporting This function is defined as follows This function passes a signed 1 byte value newRSSI of the last reported RSSI to the application ...

Page 117: ...dyInRequestedMode Device already started bStatus_t GAPCentralRole_SetParameter uint16 param uint8 len void pValue Set a GAP Role parameter Parameters param Profile parameter ID see Section C 2 len length of data to write pValue pointer to value to set parameter This is dependent on the parameter ID and is cast to the appropriate data type Returns SUCCESS INVALIDPARAMETER param was not valid bleInv...

Page 118: ...d bleIncorrectMode there is no active connection LL_STATUS_ERROR_CTRL_PROC_ALREADY_ACTIVE terminate procedure already started bStatus_t GAPCentralRole_EstablishLink uint8 highDutyCycle uint8 whiteList uint8 addrTypePeer uint8 peerAddr Establishes a link to a peer device Parameters highDutyCycle TRUE to high duty cycle scan FALSE if not whiteList determines use of the white list addrTypePeer addres...

Page 119: ... spec requirements STO 1 Slave Latency Connection Interval 2 LL_STATUS_ERROR_INACTIVE_CONNECTION connHandle is not active LL_STATUS_ERROR_CTRL_PROC_ALREADY_ACTIVE there is already a param update in process LL_STATUS_ERROR_UNACCEPTABLE_CONN_INTERVAL connection interval wont work because it is not a multiple or divisor of other simultaneous connection s intervals or the connection s interval is not ...

Page 120: ...leIncorrectMode Not in discovery mode bStatus_t GAPCentralRole_StartRssi uint16 connHandle uint16 period Start periodic RSSI reads on a link Parameters connHandle connection handle of link period RSSI read period in ms Returns SUCCESS RSSI calculation has started bleIncorrectMode No active link bleNoResources No resources for allocation bStatus_t GAPCentralRole_CancelRssi uint16 connHandle Cancel ...

Page 121: ...t8 6 Device address read from controller This can be set with the HCI_EXT_SetBDADDRCmd GAPCENTRALROLE_MAX_SCAN_RES R W uint8 Maximum number of discover scan results to receive Default is 8 0 is unlimited C 3 Callbacks These callbacks are functions whose pointers are passed from the application to the GAPRole so that the GAPRole can return events to the application They are passed as the following ...

Page 122: ...s function if the GAPRole is to deallocate the event message FALSE should be returned if the application deallocates By default TRUE is always returned If the event message is to be processed by the application at a later time not just in the callback context FALSE should be returned The possible GAPRole central states are in the following list For more information on these events see Section A 3 ...

Page 123: ...esults of this command For more information see Section 7 7 Parameters connHandle connection to use pInd pointer to indication to be sent authenticated whether an authenticated link is required taskId task to be notified of acknowledgment Corresponding Events If the return status is SUCCESS the calling application task will receive a GATT_MSG_EVENT message with type ATT_HANDLE_VALUE_CFM upon an ac...

Page 124: ...the calling application task receives multiple GATT_MSG_EVENT messages with type ATT_READ_BY_GRP_TYPE_RSP or ATT_ERROR_RSP if an error occurred on the server This sub procedure is complete when either ATT_READ_BY_GRP_TYPE_RSP with bleProcedureComplete or bleTimeout status or the calling application task receives the ATT_ERROR_RSP with SUCCESS status bStatus_t GATT_DiscPrimaryServiceByUUID uint16 c...

Page 125: ...curred on the server This sub procedure is complete when either ATT_FIND_BY_TYPE_VALUE_RSP with bleProcedureComplete or bleTimeout status or the calling application task recieves the ATT_ERROR_RSP with SUCCESS status bStatus_t GAPRole_GetParameter uint16 param void pValue Get a GAP Role parameter Parameters param Profile parameter ID See Section F 3 pValue pointer to a location to get the value Th...

Page 126: ...find all the characteristic descriptor s Attribute Handles and AttributeTypes within a characteristic definition when only the characteristic handle range is known Parameters connHandle connection to use startHandle start handle endHandle end handle taskId task to be notified of response Notes If the return status is SUCCESS the calling application task receives multiple GATT_MSG_EVENT messages wi...

Page 127: ...f the Characteristic Value is longer than can be sent in a single Read Response Attribute Protocol message Parameters connHandle connection to use pReq pointer to request to be sent taskId task to be notified of response Notes If the return status is SUCCESS the calling application task receives multiple GATT_MSG_EVENT messages with type ATT_READ_BLOB_RSP or ATT_ERROR_RSP if an error occurred on t...

Page 128: ...c Properties authenticated bit is enabled and the client and server device share a bond as defined in the GAP Parameters connHandle connection to use pReq pointer to command to be sent Notes No response is sent to the calling application task for this sub procedure If the authenticated Characteristic Value is the wrong size or has an invalid value as defined by the profile or the signed value fail...

Page 129: ...nt8 taskId Used to read a characteristic descriptor from a server when the client knows the attribute handle of the characteristic descriptor declaration Parameters connHandle connection to use pReq pointer to request to be sent taskId task to be notified of response Notes If the return status from this function is SUCCESS the calling application task receives an OSAL GATT_MSG_EVENT message with t...

Page 130: ...T_ERROR_RSP if an error occurred on the server This sub procedure is complete when either ATT_PREPARE_WRITE_RSP with bleTimeout status ATT_EXECUTE_WRITE_RSP with SUCCESS or bleTimeout status or the calling application task recieves the ATT_ERROR_RSP with SUCCESS status D 4 Return Values SUCCESS 0x00 Command was executed as expected For corresponding events to expect see the command API INVALIDPARA...

Page 131: ...stack message sent as an OSAL message The events are received as the following structure where the method signifies the ATT event and the message is a union of the ATT events This section lists the ATT events by their method and display their structure that is used in the message payload These events are in the att h file ATT_ERROR_RSP 0x01 ATT_FIND_INFO_RSP 0x03 ATT_FIND_BY_TYPE_VALUE_RSP 0x07 AT...

Page 132: ...back Copyright 2010 2019 Texas Instruments Incorporated GATT ATT API ATT_READ_MULTI_RSP 0x0F ATT_READ_BY_GRP_TYPE_RSP 0x11 ATT_WRITE_RSP 0x13 ATT_PREPARE_WRITE_RSP 0x17 ATT_EXECUTE_WRITE_RSP 0x19 ATT_HANDLE_VALUE_NOTI 0x1B ATT_HANDLE_VALUE_IND 0x1D ATT_HANDLE_VALUE_CFM 0x1E Empty msg field ...

Page 133: ...rror codes that can exist in the ATT_ERROR_RSP event and their possible causes ATT_ERR_INVALID_HANDLE 0x01 Attribute handle value given was not valid on this attribute server ATT_ERR_READ_NOT_PERMITTED 0x02 Attribute cannot be read ATT_ERR_WRITE_NOT_PERMITTED 0x03 Attribute cannot be written ATT_ERR_INVALID_PDU 0x04 The attribute PDU was invalid ATT_ERR_INSUFFICIENT_AUTHEN 0x05 The attribute requi...

Page 134: ... Incorporated GATT ATT API ATT_ERR_INSUFFICIENT_ENCRYPT 0x0F The attribute requires encryption before it can be read or written ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10 The attribute type is not a supported grouping attribute as defined by a higher layer specification ATT_ERR_INSUFFICIENT_RESOURCES 0x11 Insufficient resources exist to complete the request ...

Page 135: ...s characteristic is bStatus_t GATTServApp_ProcessCharCfg gattCharCfg_t charCfgTbl uint8 pValue uint8 authenticated gattAttribute_t attrTbl uint16 numAttrs uint8 taskId pfnGATTReadAttrCB_t pfnReadAttrCB Process Client Characteristic Configuration change Parameters charCfgTbl profile characteristic configuration table pValue pointer to attribute value authenticated whether an authenticated link is r...

Page 136: ...e record if found NULL if not found bStatus_t GATTServApp_ProcessCCCWriteReq uint16 connHandle gattAttribute_t pAttr uint8 pValue uint8 len uint16 offset uint16 validCfg Process the client characteristic configuration write request for a given client Parameters connHandle connection message was received on pAttr pointer to attribute value pValue pointer to data to be written len length of data off...

Page 137: ...eter ID and is cast to the appropriate data type Returns SUCCESS parameter was set INVALIDPARAMETER param was not valid bleInvalidRange len is not valid for the given param bStatus_t GAPBondMgr_GetParameter uint16 param void pValue Get a GAP Bond Manager parameter Parameters param Profile parameter ID see Section F 3 pValue pointer to a location to get the value This pointer depends on the param I...

Page 138: ...P_BONDINGS_MAX if address was not found bStatus_t GAPBondMgr_ServiceChangeInd uint16 connectionHandle uint8 setParam Set clear the service change indication in a bond record Parameters connHandle connection handle of the connected device or 0xFFFF for devices in database setParam TRUE to set the service change indication FALSE to clear it Returns SUCCESS bond record found and changed bleNoResource...

Page 139: ...ue containing the passcode Returns SUCCESS connection found and passcode was changed bleIncorrectMode connectionHandle connection not found or pairing has not started INVALIDPARAMETER passcode is out of range bleMemAllocError heap is out of memory uint8 GAPBondMgr_ProcessGAPMsg gapEventHdr_t pMsg This is a bypass mechanism to let the bond manager process GAP messages Note NOTE This bypass mechanis...

Page 140: ...BOND_OOB_DATA R W uint8 16 OOB Data Default is 0s GAPBOND_BONDING_ENABLED R W uint8 Request Bonding during the pairing process if enabled Default is 0 disabled GAPBOND_KEY_DIST_LIST uint8 The key distribution list for bonding Default is sEncKey sIdKey mIdKey mSign enabled GAPBOND_DEFAULT_PASSCODE uint32 The default passcode for MITM protection Range is 0 to SWRU2718752999 999 Default is 0 GAPBOND_...

Page 141: ...cation the peer device information when a passcode is requested by the peer device during the paring process This function is defined as the following Based on the parameters passed to this callback like the pairing interface inputs and outputs the application displays the passcode or initiates the entrance of a passcode F 4 2 Pairing State Callback pairStateCB This callback returns the current pa...

Page 142: ...ails to authenticate SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04 the confirm value fails to match the calculated compare value SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05 pairing is not supported SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06 encryption key size is insufficient SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07 The SMP command received is unsupported on this device SMP_PAIRING_FAILED_UNSPECIFIED 0x08 encryption...

Page 143: ...ents that you should check by the calling application G 2 Commands hciStatus_t HCI_EXT_AdvEventNoticeCmd uint8 taskID uint16 taskEvent This command configures the device to set an event in the user task after each advertisement event completes A non zero taskEvent value is enable while a zero valued taskEvent is disable Note NOTE This command fails to return any events but has a meaningful return ...

Page 144: ...rough the HCI but no event will be returned Parameters Mode HCI_EXT_SET_APP_REVISION HCI_EXT_READ_BUILD_REVISION userRevNum Any 16 bit value Returns only when mode HCI_EXT_SET_USER_REVISION SUCCESS build revision set succesfully LL_STATUS_ERROR_BAD_PARAMETER an invalid mode Corresponding Events only when mode HCI_EXT_SET_USER_REVISION HCI_VendorSpecifcCommandCompleteEvent hciStatus_t HCI_EXT_ConnE...

Page 145: ...Low Energy operations the controller can bypass internal checks that reduce overhead processing This capability reduces average power consumption Note NOTE This command is allowed only when the Bluetooth Low Energy controller is idle If you use NV when declaring it is not in use a hung Bluetooth Low Energy connection may occur Parameters mode one of HCI_EXT_NV_NOT_IN_USE HCI_EXT_NV_IN_USE Correspo...

Page 146: ...ion the new delay value will be applied the next time the delay is used Note NOTE This delay applies only to reset and sleep If a periodic timer is used or an active Bluetooth Low Energy operation and only sleep is used this delay occurs only after reset No distinction exists between a hard and soft reset The delay if non zero is applied the same way in both cases Parameters delay 0x0000 0x003E8 i...

Page 147: ...ws a maximum Tx output power of 10 dBm the specified Bluetooth Low Energy maximum and increases Rx sensitivity This capability extends the RF range of the CC254x When using this command the configuration fails to change unless the CC254x is reset Automatic control of the CC2590 is achieved using the CC254x Observables which take control of GPIO P1 2 and P1 3 The GPIO P1 1 controls RF gain These GP...

Page 148: ...central devices for the CC254x as peripheral devices can only have one simultaneous connection If all parameters are NULL the call to this command is a network processor call through a transport layer and the results are provided by the host through a vendor specific command complete event If any parameter is not NULL the call to this command is a direct function call and the valid pointers store ...

Page 149: ...s not halted the peak current is higher but the system is more responsive When the MCU is halted the peak current consumption is reduced but the system is less responsive The default value is Enable Note NOTE If there are any active Bluetooth Low Energy connections this command is disallowed If the halt during RF is disabled the HCI_EXT_ClkDivOnHaltCmd is disallowed Parameters mode one of HCI_EXT_...

Page 150: ... and Output UART Timers Port 1 pins to Observables Digital Regulator status UART Timers Port 2 pins to an external 32 kHz XOSC The selected port or pin will be configured as an output GPIO with interrupts masked Using this command carelessly can result in a reconfiguration that could disrupt the system If a port or pin is used as part of the serial interface for the device the pin or port is recon...

Page 151: ...HCI_EXT_SetTxPowerCmd Corresponding Events HCI_VendorSpecifcCommandCompleteEvent hciStatus_t HCI_EXT_ModemTestRxCmd uint8 rxFreq This API starts a continuous receiver modem test using a modulated carrier wave tone at the frequency that corresponds to the specific RF channel Any received data is discarded Receiver gain may be adjusted using the HCI_EXT_SetRxGain command RSSI may be read during this...

Page 152: ...r Size command in The default limit is one the default flushOnEvt flag is FALSE Note NOTE The purpose of this command is to minimize the overhead of sending multiple number of completed packet events Minimizing this number of events maximizes the processing available to increase wireless throughput This command is often used in conjunction with HCI_EXT_OverlappedProcessingCmd Parameters limit From...

Page 153: ...R_EVT Corresponding Events HCI_VendorSpecifcCommandCompleteEvent this event is returned only if the setting is changing from enable to disable or disable to enable hciStatus_t HCI_EXT_OverlappedProcessingCmd uint8 mode This command enables or disables overlapped processing The default is disabled Parameters mode one of the following HCI_EXT_DISABLE_OVERLAPPED_PROCESSING HCI_EXT_ENABLE_OVERLAPPED_P...

Page 154: ...ounters by clearing them if required before starting accumulation The counters are 16 bits At the shortest connection interval this provides a bit over 8 minutes of data This command can be used combined with HCI_EXT_PacketErrorRateCmd Parameters connHandle The connection ID to accumulate the data perByChan Pointer to PER by channel data or NULL Corresponding Events HCI_VendorSpecifcCommandComplet...

Page 155: ...endorSpecifcCommandCompleteEvent hciStatus_t HCI_EXT_SetFastTxResponseTimeCmd uint8 control This command configures the link layer fast transmit response time feature The default system value for this feature is enabled Note NOTE This command is valid only for a slave controller When the host transmits data the controller ensures the packet is sent over the LL connection with minimal delay even wh...

Page 156: ...uint8 localFeatures This command sets the local supported features of the controller Note NOTE This command can be issued either before or after one or more connections are formed The local features set are only effective if performed before a feature exchange procedure has been initiated by the master When this control procedure has been completed for a connection only the exchanged feature set f...

Page 157: ...is 5 dBm This command changes the value used by DTM Note NOTE When DTM is ended by a call to HCI_LE_TestEndCmd or a HCI_Reset is used the transmitter output power setting is restored to the default value of 0 dBm Parameters txPower one of HCI_EXT_TX_POWER_MINUS_21_DBM HCI_EXT_TX_POWER_MINUS_18_DBM HCI_EXT_TX_POWER_MINUS_15_DBM HCI_EXT_TX_POWER_MINUS_12_DBM HCI_EXT_TX_POWER_MINUS_9_DBM HCI_EXT_TX_P...

Page 158: ...ue is used directly The system default value for a master and slave device is 50 ppm and 40 ppm respectively Note NOTE This command is allowed only when the device is disconnected The SCA value of the device remains unaffected by an HCI reset Parameters scaInPPM The SCA of the device in PPM from 0 to 500 Corresponding Events HCI_VendorSpecifcCommandCompleteEvent hciStatus_t HCI_EXT_SetSlaveLatency...

Page 159: ...r this feature is 0 dBm Parameters txPower Device s transmit power one of the following Corresponding Events HCI_VendorSpecifcCommandCompleteEvent HCI_EXT_TX_POWER_MINUS_21_DBM HCI_EXT_TX_POWER_MINUS_18_DBM HCI_EXT_TX_POWER_MINUS_15_DBM HCI_EXT_TX_POWER_MINUS_12_DBM HCI_EXT_TX_POWER_MINUS_9_DBM HCI_EXT_TX_POWER_MINUS_6_DBM HCI_EXT_TX_POWER_MINUS_3_DBM HCI_EXT_TX_POWER_0_DBM HCI_EXT_TX_POWER_1_DBM ...

Page 160: ... code description for each failure error code Table G 1 Host Error Codes Value Parameter Description 0x00 SUCCESS 0x01 FAILURE 0x02 INVALIDPARAMETER 0x03 INVALID_TASK 0x04 MSG_BUFFER_NOT_AVAIL 0x05 INVALID_MSG_POINTER 0x06 INVALID_EVENT_ID 0x07 INVALID_INTERRUPT_ID 0x08 NO_TIMER_AVAIL 0x09 NV_ITEM_UNINIT 0x0A NV_OPER_FAILED 0x0B INVALID_MEM_SIZE 0x0C NV_BAD_ITEM_LEN 0x10 bleNotReady 0x11 bleAlread...

Page 161: ...ory NOTE Page numbers for previous revisions may differ from page numbers in the current version Changes from G Revision September 2015 to H Revision Page Updates were made in Related Documentation 7 Update was made in Section 1 1 8 Update was made in Section 1 2 8 Update was made in Section 2 4 14 Updates were made in Section 8 2 71 Added new Section 9 2 81 Added new Section 9 3 82 ...

Page 162: ...se resources are subject to change without notice TI grants you permission to use these resources only for development of an application that uses the TI products described in the resource Other reproduction and display of these resources is prohibited No license is granted to any other TI intellectual property right or to any third party intellectual property right TI disclaims responsibility for...

Reviews: