iOS8.1rx580不支持win8.1HID Over GATT吗

TI_学霸学习网
Texas Instruments CC2540/41 Bluetooth? Low Energy Sample Applications Guide v1.3.2Document Number: SWRU297Copyright ?
Texas Instruments, Inc. Table Of ContentsTABLE OF CONTENTS .............................................................................................................................. 2 REFERENCES .............................................................................................................................................. 5 1 2 OVERVIEW........................................................................................................................................... 6 1.1 INTRODUCTION ................................................................................................................................. 6 BLOOD PRESSURE SENSOR ............................................................................................................ 6 2.1 PROJECT OVERVIEW ......................................................................................................................... 6 2.1.1 User Interface .......................................................................................................................... 6 2.1.2 Basic Operation ....................................................................................................................... 6 2.2 SOFTWARE DESCRIPTION.................................................................................................................. 7 2.2.1 Initialization ............................................................................................................................. 7 2.2.2 Event Processing ..................................................................................................................... 7 2.2.3 Callbacks ................................................................................................................................. 7 2.2.4 Sending Blood Pressure Measurement Indications ................................................................. 8 2.2.5 Sending Intermediate Measurement Notifications ................................................................... 8 2.2.6 Blood Pressure Measurement .................................................................................................. 8 3 HEALTH THERMOMETER .............................................................................................................. 8 3.1 PROJECT OVERVIEW ......................................................................................................................... 8 3.1.1 User Interface .......................................................................................................................... 8 3.1.2 Basic Operation ....................................................................................................................... 9 3.2 SOFTWARE DESCRIPTION.................................................................................................................. 9 3.2.1 Initialization ............................................................................................................................. 9 3.2.2 Event Processing ................................................................................................................... 10 3.2.3 Callbacks ............................................................................................................................... 10 3.2.4 Sending Temperature Indications .......................................................................................... 10 3.2.5 Sending Intermediate Measurement Notifications ................................................................. 10 3.2.6 Sending Interval Change Indications ..................................................................................... 10 3.2.7 Thermometer Measurement Format ...................................................................................... 11 4 HEART RATE SENSOR .................................................................................................................... 11 4.1 PROJECT OVERVIEW ....................................................................................................................... 11 4.1.1 User Interface ........................................................................................................................ 11 4.1.2 Basic Operation ..................................................................................................................... 11 4.2 SOFTWARE DESCRIPTION................................................................................................................ 11 4.2.1 Initialization ........................................................................................................................... 12 4.2.2 Event Processing ................................................................................................................... 12 4.2.3 Callbacks ............................................................................................................................... 12 4.2.4 Sending Notifications ............................................................................................................. 12 5 CYCLING SPEED AND CADENCE (CSC) SENSOR .................................................................... 12 5.1 PROJECT OVERVIEW ....................................................................................................................... 13 5.1.1 User Interface ...................................................................................................................... 13 5.1.2 Basic Operation ................................................................................................................... 13 5.2 SOFTWARE DESCRIPTION................................................................................................................ 13 5.2.1 Initialization .......................................................................................................................... 14 5.2.2 Event Processing ................................................................................................................ 14 5.2.3 Callbacks .............................................................................................................................. 14 5.2.4 Sending Notifications .......................................................................................................... 14 5.2.5 Confirming Indications ........................................................................................................ 14 5.2.6 Reading from the Sensor ................................................................................................... 14 5.2.7 Writing to the Sensor .......................................................................................................... 15 5.2.8 Neglect Timer ...................................................................................................................... 15 6 RUNNING SPEED AND CADENCE (RSC) SENSOR .................................................................... 15 6.1 PROJECT OVERVIEW ....................................................................................................................... 15Page 2 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.26.1.1 User Interface ...................................................................................................................... 15 6.1.2 Basic Operation ................................................................................................................... 16 6.2 SOFTWARE DESCRIPTION................................................................................................................ 16 6.2.1 Initialization .......................................................................................................................... 16 6.2.2 Event Processing ................................................................................................................ 16 6.2.3 Callbacks .............................................................................................................................. 17 6.2.4 Sending Notifications .......................................................................................................... 17 6.2.5 Confirming Indications ........................................................................................................ 17 6.2.6 Reading from the Sensor ................................................................................................... 17 6.2.7 Writing to the Sensor .......................................................................................................... 17 6.2.8 Neglect Timer ...................................................................................................................... 18 7 GLUCOSE COLLECTOR ................................................................................................................. 18 7.1 PROJECT OVERVIEW ....................................................................................................................... 18 7.1.1 User Interface ........................................................................................................................ 18 7.1.2 Basic Operation ..................................................................................................................... 18 7.1.3 Record Filter Configuration .................................................................................................. 19 7.2 SOFTWARE DESCRIPTION................................................................................................................ 19 7.2.1 Initialization ........................................................................................................................... 19 7.2.2 Event Processing ................................................................................................................... 19 7.2.3 Callbacks ............................................................................................................................... 19 7.2.4 Service Discovery .................................................................................................................. 20 7.2.5 Service Configuration ............................................................................................................ 20 7.2.6 Record Access Control Point ................................................................................................. 20 8 GLUCOSE SENSOR ........................................................................................................................... 20 8.1 PROJECT OVERVIEW ....................................................................................................................... 20 8.1.1 User Interface ........................................................................................................................ 20 8.1.2 Basic Operation ..................................................................................................................... 21 8.2 SOFTWARE DESCRIPTION................................................................................................................ 21 8.2.1 Initialization ........................................................................................................................... 21 8.2.2 Event Processing ................................................................................................................... 21 8.2.3 Callbacks ............................................................................................................................... 21 8.2.4 Sending Notifications and Indications ................................................................................... 22 8.2.5 Record Access Control Point Processing .............................................................................. 22 9 10 HID ADVANCED REMOTE CONTROL ........................................................................................ 22 HID EMULATED KEYBOARD .................................................................................................... 22 10.1 PROJECT OVERVIEW ....................................................................................................................... 22 10.1.1 User Interface ........................................................................................................................ 23 10.1.2 Basic Operation ..................................................................................................................... 23 10.2 SOFTWARE DESCRIPTION................................................................................................................ 23 10.3 HIDEMUKBD APPLICATION ............................................................................................................ 23 10.3.1 Initialization ........................................................................................................................... 23 10.3.2 Event Processing ................................................................................................................... 23 10.3.3 Callbacks ............................................................................................................................... 24 10.3.4 Sending Notifications ............................................................................................................. 24 10.4 HID DEVICE PROFILE ..................................................................................................................... 24 10.4.1 Initialization ........................................................................................................................... 24 10.4.2 Event Processing ................................................................................................................... 24 10.4.3 Callbacks ............................................................................................................................... 24 10.4.4 GATT Read and Write Callbacks ........................................................................................... 25 10.4.5 Mapping HID Reports to HID Characteristics ...................................................................... 25 10.4.6 Sending and Receiving HID Reports ..................................................................................... 25 10.4.7 Advertising and Connection Procedures ............................................................................... 25 11 12 12.1 HOSTTESTRELEASE- BLE NETWORK PROCESSOR .......................................................... 25 KEYFOBDEMO .............................................................................................................................. 25 PROJECT OVERVIEW ....................................................................................................................... 26Page 3 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.212.1.1 User Interface ........................................................................................................................ 26 12.1.2 Battery Operation .................................................................................................................. 26 12.1.3 Accelerometer Operation ....................................................................................................... 26 12.1.4 Keys ....................................................................................................................................... 26 12.1.5 Proximity ............................................................................................................................... 27 12.2 SOFTWARE DESCRIPTION................................................................................................................ 27 12.2.1 Initialization ........................................................................................................................... 27 12.2.2 Event Processing ................................................................................................................... 27 12.2.3 Callbacks ............................................................................................................................... 27 13 13.1 13.2 14 15 16 SENSORTAG................................................................................................................................... 28 OPERATION..................................................................................................................................... 28 SENSORS ......................................................................................................................................... 28 SIMPLEBLECENTRAL ................................................................................................................ 28 SIMPLEBLEPERIPHERAL .......................................................................................................... 29 TIMEAPP- BLE WATCH .............................................................................................................. 2916.1 PROJECT OVERVIEW ....................................................................................................................... 29 16.1.1 User Interface ........................................................................................................................ 29 16.1.2 Basic Operation ..................................................................................................................... 29 16.2 SOFTWARE DESCRIPTION................................................................................................................ 30 16.2.1 Initialization ........................................................................................................................... 30 16.2.2 Event Processing ................................................................................................................... 30 16.2.3 Callbacks ............................................................................................................................... 31 16.2.4 Service Discovery .................................................................................................................. 31 16.2.5 Service Configuration ............................................................................................................ 31 16.2.6 Handling Indications and Notifications ................................................................................. 31 16.2.7 Clock Time ............................................................................................................................. 31 17 SERIAL BOOTLOADER ............................................................................................................... 32 17.1 BASIC OPERATION .......................................................................................................................... 32 17.1.1 Build and Flash the SBL ........................................................................................................ 32 17.1.2 Build the Project to be Bootloaded ........................................................................................ 32 17.1.3 Download the User Project Image (.bin) ............................................................................... 32 18 USB BOOTLOADER ...................................................................................................................... 32 18.1 BASIC OPERATION .......................................................................................................................... 32 18.1.1 Flash UBL .............................................................................................................................. 32 18.1.2 Build the Project to be Bootloaded ........................................................................................ 32 18.1.3 Download the User Project Image (.bin) ............................................................................... 33 19 19.1 19.2 19.3 20 20.1 21 22 OVER AIR DOWNLOAD .............................................................................................................. 33 TARGET REQUIREMENTS ................................................................................................................ 33 SERVER REQUIREMENTS ................................................................................................................. 33 OAD DEVELOPER’S GUIDE ............................................................................................................ 33 GENERAL INFORMATION ......................................................................................................... 35 DOCUMENT HISTORY ..................................................................................................................... 35 ADDRESS INFORMATION .......................................................................................................... 35 TI WORLDWIDE TECHNICAL SUPPORT ............................................................................... 35Page 4 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2ReferencesIncluded with Texas Instruments Bluetooth Low Energy v1.3.2 Stack Release (All path and file references in this document assume that the BLE development kit software has been installed to the default path C:\Texas Instruments\BLE-CC254x-1.3.2\): [1] Texas Instruments Bluetooth? Low Energy Software Developer’s Guide (SWRU271B) C:\Texas Instruments\BLE-CC254x-.3.2\Documents\TI_BLE_Software_Developer's_Guide.pdf Adopted Bluetooth specifications (which can be downloaded from https://www.bluetooth.org/Technical/Specifications/adopted.htm): [2] Blood Pressure Profile (BLP) Specification v1.0 [3] Blood Pressure Service (BLS) Specification v1.0 [4] Health Thermometer Profile (HTP) Specification v1.0 [5] Health Thermometer Service (HTS) Specification v1.0 [6] Heart Rate Profile (HRP) Specification v1.0 [7] Heart Rate Service (HRS) Specification v1.0 [8] HID over GATT Profile (HOGP) Specification v1.0 [9] HID Service (HIDS) Specification v1.0 [10] Scan Parameters Profile (ScPP) v1.0 [11] Scan Parameters Service (ScPS) v1.0 [12] Device Information Service (DIS) Specification v1.1 [13] Battery Service (BAS) specification v1.0 [14] Proximity Profile (PXP) Specification v1.0 [15] Find Me Profile (FMP) Specification v1.0 [16] Link Loss Service (LLS) Specification v1.0 [17] Immediate Alert Service (IAS) Specification v1.0 [18] Tx Power Service (TPS) Specification v1.0 [19] Time Profile (TIP) Specification v1.0 [20] Alert Notification Profile (ANP) Specification v1.0 [21] Phone Alert Status (PASP) Specification v1.0 [22] Running Speed and Cadence Profile [23] Running Speed and Cadence Service [24] Cycling Speed and Cadence Profile [25] Cycling Speed and Cadence ServicePage 5 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.21OverviewThe purpose of this document is to give an overview of the sample applications that are included in the Texas Instruments CC2540/41 Bluetooth? low energy (BLE) software development kit. It is recommended that you read [1] before attempting to use these sample applications, as some knowledge of the CC2540/41 BLE protocol stack and software is required. 1.1 IntroductionVersion 1.3.2 of the Texas Instruments CC2540/41 BLE software development kit includes several sample applications implementing a variety of GATT-based profiles. Some of these implementations are based on specifications that have been adopted by the Bluetooth Special Interest Group (BT SIG), while others are based on specifications that are a work-in-progress and have not been finalized. In addition, some applications are not based on any standardized profile being developed by the BT SIG, but rather are custom implementations developed by Texas Instruments. In order to interoperate with other Bluetooth low energy devices (such as a mobile phone), an application would need to be written on the other device which implements the proper GATT client and/or server functionality that matches the CC2540/41 sample application. The status of the implementation of each profile/application is included in this document. The information in this guide specifically mentions only CC2540 however all of the applications and configurations (with the exception of those that use the USB interface) also can run on the CC2541. Be sure to open the correct project file depending on the chipset that is being used.2Blood Pressure SensorThis sample project implements the Blood Pressure profiles in a BLE peripheral device to provide an example blood pressure monitor using simulated measurement data. The application implements the &Sensor& role of the blood pressure profile. The project is based on the adopted profile and service specifications for Blood Pressure ([2] and [3]). The project also includes the Device Information Service ([12]). The project can be opened with the following IAR workspace file: C:\Texas Instruments\BLE-CC254x-1.3.2\ Projects\ble\BLoodPressure\CC2540DB\bloodpressure.eww 2.1 Project OverviewThe project structure is very similar to that of the SimpleBLEPeripheral project. The APP directory contains the application source code and header files. The project contains two configurations. 2.1.1 CC2540DK-MINI Keyfob Slave: using the keyfob hardware platform. CC2540 Slave: using the SmartRF platform. User InterfaceThere are two button inputs for this application. KeyFob Right or SmartRF Joystick Right When not connected, this button is used to toggle advertising on and off. When in a connection, this increases the value of various measurements. KeyFob Left or SmartRF Joystick Up This button cycle through different optional measurement formats. 2.1.2 Basic Operation Power up the device and press the right button to enable advertising. From a blood pressure collector peer device, initiate a device discovery and connection procedure to discover and connect to the blood pressure sensor. The peer device should discover the blood pressure service and configure it to enable indication or notifications of the blood pressure measurement.Page 6 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2The peer device may also discover the device information service for more information such as mfg and serial number. Once blood pressure measurements have been enabled the application will begin sending data to the peer containing simulated measurement values. Pressing the left button cycles through different data formats as follows: ? ? ? ? ? ? MMHG | TIMESTAMP | PULSE | USER | STATUS MMHG | TIMESTAMP MMHG KPA KPA | TIMESTAMP KPA |TIMESTAMP | PULSEIf the peer device initiates pairing, the blood pressure sensor will request a passcode. The passcode is “000000”. Upon termination, the BPM will not begin to advertising again until the button is pressed. The peer device may also query the blood pressure for read only device information. Further details on the supported items are listed in the GATT_DB excel sheet for this project. Examples are model number, serial number, etc. 2.2 Software DescriptionThe application is implemented in the file bloodpressure.c. 2.2.1 Initialization The initialization of the application occurs in two phases: first, the Bloodpressure_Init function is called by the OSAL. This function configures parameters in the peripheral profile, GAP, and GAP bond manager. It also sets up the blood pressure service along with standard GATT and GAP services in the attribute server. Then it sets an OSAL START_DEVICE_EVT event. This triggers the second phase of the initialization, which can be found within the Bloodpressure_ProcessEvent function. During this phase, the GAPRole_StartDevice function is called to set up the GAP functions of the application. Then GAPBondMgr_Register is called to register with the bond manager. 2.2.2 Event Processing The application has two main event processing functions, Bloodpressure_ProcessEvent and Bloodpressure_ProcessOSALMsg. Function Bloodpressure_ProcessEvent handles events as follows: ? ? ? ? ? ? SYS_EVENT_MSG: Service the OSAL queue and process OSAL messages. BP_START_DEVICE_EVT: Start the device, as described in the previous section. BP_START_DISCOVERY_EVT: Start discovery, search for time service on collector. TIMER_BPMEAS_EVT: Perform final measurement BP_TIMER_CUFF_EVT: Perform a cutoff measurement BP_DISCONNECT_EVT: Disconnect after sending measurementFunction Bloodpressure_ProcessOSALMsg handles OSAL messages as follows: ? ? 2.2.3 ? KEY_CHANGE: Handle key presses. GATT_MSG_EVENT: This will handle reception of time information from collector. Callbacks PeripheralStateNotificationCB: This is the GAP event callback. It processes GAP events for startup and link connect/disconnect.The application callback functions are as follows:Page 7 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2? ? ? 2.2.4bpServiceCB: This is the blood pressure service callback. It handles enabling or disabling measurements. TimeAppPairStateCB: This is a GAPBOND callback to handle pairing states. TimeAppPasscodeCB: Returns the passcode of 0. Sending Blood Pressure Measurement IndicationsThe application sends indication of the blood pressure measurement when configured to do so by the peer device. When the peer device configures the blood pressure measurement for indication the application will receive a blood pressure service callback. The application starts a timer to begin periodic simulated blood pressure measurements. When the timer expires the application calls bpSendStoredMeas to build and send a measurement using the blood pressure service API. The application expects the peer device to send back an indication confirmation. 2.2.5 Sending Intermediate Measurement Notifications The application sends notification of the blood pressure measurement when configured to do so by the peer device. When the peer device configures the blood pressure measurement for notification the application will receive a blood pressure service callback. The application starts a timer to begin periodic simulated blood pressure measurements. When the timer expires the application calls bloodPressureIMeasNotify to build and send a measurement using the blood pressure service API. 2.2.6 Blood Pressure Measurement Flags Size 1 octet Blood Pressure Measurement Value Systolic 2 octets Diastolic 2 octets MAP 2 octets 7 octets 2 octets 1 octet Time Stamp Pulse Rate User ID3Health ThermometerThis sample project implements a Health Thermometer and Device Information profile in a BLE peripheral device to provide an example health thermometer application using simulated measurement data. The application implements the &Sensor& role of the Health Thermometer profile. The project is based on the adopted profile and service specifications for Health Thermometer (see [4] and [5]). The project also includes the Device Information Service ([12]). The project can be opened with the following IAR workspace file: C:\TexasInstruments\BLE-CC254x1.3.2.1\Projects\ble\Thermometer\CC2540DB\thermometer.eww 3.1 Project OverviewThe project structure is very similar to that of the SimpleBLEPeripheral project. The APP directory contains the application source code and header files. The project contains two configurations. ? ? 3.1.1CC2540DK-MINI Keyfob Slave: using the keyfob hardware platform. CC2540 Slave: using the SmartRF platform.User InterfaceThere are two button inputs for this application. KeyFob Right | SmartRF Joystick Right When not connected and not configured to take measurements, this button is used to toggle advertising on and off.Page 8 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2When in a connection or configured to take measurements, this increases the temperature by 1 degree Celsius. After 3 degrees in temperature rise, the interval will be set to 30 seconds and if configured, this will indicate to the peer an interval change initiated at the thermometer. KeyFob Left | SmartRF Joystick Up This button cycle through different measurement formats. 3.1.2 Basic Operation Power up the device and press the right button to enable advertising. From a thermometer collector peer device, initiate a device discovery and connection procedure to discover and connect to the thermometer sensor. The peer device should discover the thermometer service and configure it to enable indication or notifications of the thermometer measurement. The peer device may also discover the device information service for more information such as mfg and serial number. Once thermometer measurements have been enabled the application will begin sending data to the peer containing simulated measurement values. Pressing the left button cycles through different data formats as follows: ? ? ? ? ? ? CELCIUS | TIMESTAMP | TYPE CELCIUS | TIMESTAMP CELCIUS FARENHEIT FARENHEIT | TIMESTAMP FARENHEIT | TIMESTAMP | TYPEIf the peer device initiates pairing, the the HT will request a passcode. The passcode is “000000”. The HT operates in the following states: ? ? ? ? Idle C In this state, the thermometer will wait for the right button to be pressed to start advertising. Idle Configured C The thermometer waits the interval before taking a measurement and proceeding to Idle Measurement Ready state. Idle Measurement Ready C The thermometer has a measurement ready and will advertise to allow connection. The thermometer will periodically advertise in this state. Connected Not Configured - The thermometer may be configured to enable measurement reports. The thermometer will not send stored measurements until the CCC is enabled. Once connection is established, the thermometer sets a timer to disconnect in 20 seconds. Connected Configured - The thermometer will send any stored measurements if CCC is set to send measurement indications. Connected Bonded - The thermometer will send any stored measurements if CCC was previously set to send measurement indications.? ?The peer device may also query the thermometers read only device information. Examples are model number, serial number, etc. 3.2 Software DescriptionThe application is implemented in the file thermometer.c. 3.2.1 Initialization The initialization of the application occurs in two phases: first, the Thermometer_Init function is called by the OSAL. This function configures parameters in the peripheral profile, GAP, and GAP bond manager. It also sets up the thermometer service along with standard GATT and GAP services in the attribute server. Then it sets an OSAL START_DEVICE_EVT event. This triggers the second phase of the initialization, which can be found within the Thermometer_ProcessEvent function. During this phase, the GAPRole_StartDevice function isPage 9 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2called to set up the GAP functions of the application. Then GAPBondMgr_Register is called to register with the bond manager. 3.2.2 Event Processing The application has two main event processing functions, Thermometer_ProcessEvent and Thermometer_ProcessOSALMsg. Function Thermometer_ProcessEvent handles events as follows: ? ? ? ? ? ? SYS_EVENT_MSG: Service the OSAL queue and process OSAL messages. START_DEVICE_EVT: Start the device, as described in the previous section. TH_START_DISCOVERY_EVT: Start discovery, search for time service on collector. TH_PERIODIC_MEAS_EVT: Start a measurement. TH_PERIODIC_IMEAS_EVT: Send immediate measurement. TH_DISCONNECT_EVT: Terminate connection.Function Thermometer_ProcessOSALMsg handles OSAL messages as follows: ? ? 3.2.3 ? ? ? ? 3.2.4 KEY_CHANGE: Handle key presses. GATT_MSG_EVENT: This will handle reception of time information from collector. Callbacks PeripheralStateNotificationCB: This is the GAP event callback. It processes GAP events for startup and link connect/disconnect. ThermometerCB: This is the thermometer service callback. It handles enabling or disabling measurements. TimeAppPairStateCB: This is a GAPBOND callback to handle pairing states. TimeAppPasscodeCB: Returns the passcode of 0. Sending Temperature IndicationsThe application callback functions are as follows:The application enables indication of the thermometer measurement when configured to do so by the peer device. When the peer device configures the thermometer measurement for indication the application will receive a thermometer service callback. The application starts a timer to begin periodic simulated thermometer measurements. When the timer expires the application calls thermometerMeasIndicate to build and store a measurement. Once a measurement is ready, the thermometer will enter connectable state and send advertisements. If the peer device connects and the CCC is enabled, the thermometer will send the stored measurements. The thermometer expects the peer device to send back an indication confirmation for each indication sent. 3.2.5 Sending Intermediate Measurement Notifications The application sends notification of the thermometer measurement when configured to do so by the peer device. When the peer device configures the thermometer measurement for notification the application will receive a thermometer service callback. The application starts a timer to begin periodic simulated thermometer measurements. When the timer expires the application calls thermometerIMeasIndicate to build and send a measurement using the thermometer service API. 3.2.6 Sending Interval Change Indications If the CCC for interval change is enabled, the thermometer will send an indication to the peer if the interval is changed by the thermometer. This can be triggered by pressing the right button three times which will increase the simulated temperature by 3 degrees and also reset the interval to 30 seconds.Page 10 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.23.2.7Thermometer Measurement Format Flags Temperature Measurement Value 4 octets Based on bit 0 of Flags field Time Stamp (if present) 0 or 7 octets Smallest unit in seconds Temperature Type (if present) 0 or 1 octet NoneSize Units1 octet None4Heart Rate SensorThis sample project implements the Heart Rate and Battery profiles in a BLE peripheral device to provide an example heart rate sensor using simulated measurement data. The application implements the &Sensor& role of the Heart Rate profile and the &Battery Reporter& role of the Battery profile. The project is based on adopted profile and service specifications for Health Rate ([6] and [7]). The project also includes the Device Information Service ([12]). The project can be opened with the following IAR workspace file: C:\Texas Instruments\BLE-CC254x-1.3.2\Projects\ble\HeartRate\CC2540DB\heartrate.eww 4.1 Project OverviewThe project structure is very similar to that of the SimpleBLEPeripheral project. The APP directory contains the application source code and header files. The project contains one configuration, CC2540DK-MINI Keyfob Slave, using the keyfob hardware platform. 4.1.1 User Interface When not connected, the keyfob's right button is used to toggle advertising on and off. When in a connection, the keyfob's left button cycles through different heart rate sensor data formats and the right button sends a battery level-state notification. 4.1.2 Basic Operation Power up the device and press the right button to enable advertising. From a heart rate collector peer device, initiate a device discovery and connection procedure to discover and connect to the heart rate sensor. The peer device should discover the heart rate service and configure it to enable notifications of the heart rate measurement. The peer device may also discover and configure the battery service for battery level-state notifications. Once heart rate measurement notifications have been enabled the application will begin sending data to the peer containing simulated measurement values. Pressing the left button cycles through different data formats as follows: ? ? ? ? ? ? ? Sensor contact not supported. Sensor contact not detected. Sensor contact and energy expended set. Sensor contact and R-R Interval set. Sensor contact, energy expended, and R-R Interval set. Sensor contact, energy expended, R-R Interval, and UINT16 heart rate set. Nothing set.If the peer device initiates pairing then the devices will pair. Only &just works& pairing is supported by the application (pairing without a passcode). The application advertises using either a fast interval or a slow interval. When advertising is initiated by a button press or when a connection is terminated due to link loss, the application will start advertising at the fast interval for 30 seconds followed by the slow interval. When a connection is terminated for any other reason the application will start advertising at the slow interval. The advertising intervals and durations are configurable in file heartrate.c. 4.2 Software DescriptionPage 11 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2The application is implemented in the file heartrate.c. 4.2.1 Initialization The initialization of the application occurs in two phases: first, the HeartRate_Init function is called by the OSAL. This function configures parameters in the peripheral profile, GAP, and GAP bond manager. It also sets up the heart rate service and the battery service along with standard GATT and GAP services in the attribute server. Then it sets an OSAL START_DEVICE_EVT event. This triggers the second phase of the initialization, which can be found within the HeartRate_ProcessEvent function. During this phase, the GAPRole_StartDevice function is called to set up the GAP functions of the application. Then GAPBondMgr_Register is called to register with the bond manager. 4.2.2 Event Processing The application has two main event processing functions, HeartRate_ProcessEvent and HeartRate_ProcessOSALMsg. Function HeartRate_ProcessEvent handles events as follows: ? ? ? ? SYS_EVENT_MSG: Service the OSAL queue and process OSAL messages. START_DEVICE_EVT: Start the device, as described in the previous section. HEART_PERIODIC_EVT: Send periodic heart rate measurements. BATT_PERIODIC_EVT: Check the battery level and send notification if it changed.Function HeartRate_ProcessOSALMsg handles OSAL messages as follows: ? 4.2.3 ? ? KEY_CHANGE messages: Call function HeartRate_HandleKeys to handle key presses. Callbacks HeartRateGapStateCB: This is the GAP event callback. It processes GAP events for startup and link connect/disconnect. HeartRateCB: This is the heart rate service callback. It handles enabling or disabling periodic heart rate measurements when notifications of the heart rate measurement are enabled or disabled. HeartRateBattCB: This is the battery service callback. It handles enabling or disabling periodic battery measurements when notifications of the battery level-state are enabled or disabled. Sending NotificationsThe application callback functions are as follows:?4.2.4The application sends notifications of the heart rate measurement and the battery level-state when configured to do so by the peer device. When the peer device configures the heart rate measurement for notification the application will receive a heart rate service callback. The application starts a timer to begin periodic simulated heart rate measurements. When the timer expires the application calls heartRateMeasNotify to build and send a measurement using the heat rate service API. When the peer device configures the battery level-state for notification the application will receive a battery service callback. The application starts a timer to periodically measure the battery level. When the timer expires the application calls battery service API function Batt_MeasLevel to measure the battery level using the CC2450 ADC. Notification of the battery level-state is handled inside if the battery level has dropped since the previous measurement a notification is sent.5Cycling Speed and Cadence (CSC) SensorThis sample project implements the Cycling Speed and Cadence (CSC) profile in a BLE peripheral device to provide a sample application of sensor that would be placed on a bicycle, using simulated measurement data. The application implements the “Sensor” role of the CyclingPage 12 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2Speed and Cadence Profile. This profile also makes use of the optional Device Info Service, which has default values that may be altered at compile or runtime to aid in identifying a specific BLE device. This information is available in: C:\Texas Instruments\BLE-CC254x-1.3.2\Projects\ble\Profiles\DevInfo\devinfoservice.c The project can be opened with the following IAR workspace file:C:\Texas Instruments\BLE-CC254x-1.3.2\Projects\ble\CyclingSensor\CC2541DB\CyclingSensor.eww5.1 Project Overview The project is very similar to the heart rate sensor project. The APP directory contains the application source code and header files. The project contains two configurations: ? CC2541DK-MINI Keyfob Slave: using the keyfob hardware platform. ? CC2541: using the SmartRF platform. 5.1.1 User InterfaceWhen not connected, the keyfob’s right button is used to toggle advertising on and off. When in a connection, the keyfob’s left button cycles through different cycling speed and cadence sensor data formats. Holding both keys down for 5 seconds initiates a “soft reset.” This includes: ? Terminate all current connections ? Clearing all bond data ? Clearing white list of all peer addresses 5.1.2 Basic OperationPower up the device and press the right button to enable advertising. From a CSC collector peer device, initiate a device discovery and connection procedure to discover and connect to the cycling sensor. The peer device should receive a slave security request and initiate a bond. Once bonded, the collector should discover the CSC service and configure it to enable cycling speed and cadence measurements. Once CSC measurement notifications have been enabled the application will begin sending data to the peer containing simulated measurement values. Pressing the left button cycles through different data formats as follows: ? Sensor at rest (no speed or cadence detected). ? Sensor detecting speed but no cadence. ? Sensor detecting cadence but no speed. ? Sensor detecting speed and cadence. The application advertises using either a fast interval or a slow interval. When advertising is initiated by a button press or when a connection is terminated due to link loss, the application will start advertising at the fast interval for 30 seconds. If the sensor has successfully bonded to a peer device and stored the devices address in its white list, then for the for the first 10 seconds of advertising the sensor will only attempt to connect to any device addresses stored in its white list. After 10 seconds, the sensor will attempt to connect to any peer device that wishes to connect. Independent of white list use, after 30 seconds of fast interval connection, a 30 second period of slow interval advertising passes. After this, the device sleeps and waits for the right button to be pressed before resuming advertising again. If the device terminates connection for any other reason, the sensor will advertise for 60 seconds at a slow interval and then sleep if no connection is made. It will begin advertising again only if the right button is pressed. 5.2 Software DescriptionPage 13 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2The application is implemented in the file cyclingSensor.c. 5.2.1 InitializationInitialization of the application occurs in two phases: first, the CyclingSensor_Init function is called by the OSAL. This function configures parameters in the peripheral profile, GAP, and GAP bond manager. It also sets up the CSC service along with standard GATT and GAP services in the attribute server. Then it sets an OSAL START_DEVICE_EVT event. This triggers the second phase of the initialization, which can be found within the CyclingSensor_ProcessEvent function. During this phase, the GAPRole_StartDevice function is called to set up the GAP functions of the application. Then GAPBOND_Mgr_Register is called to register with the bond manager. 5.2.2 Event Processing The application has two main event processing functions, CyclingSensor_ProcessEvent and sensor_ProcessOSALMsg. Function CyclingSensor_ProcessEvent handles events as follows: ? SYS_EVENT_MSG: Service the OSAL queue and process OSAL messages. ? START_DEVICE_EVT: Start the device, as described in the previous section. ? CSC_PERIODIC_EVT: Send periodic CSC measurements. ? CSC_CONN_PARAM_UPDATE_EVT: send parameter update until successful ? CSC_NEGLET_TIMEOUT_EVT: see section 5.2.8 ? CSC_RESET_EVT: reset device as described above Function cycling_ProcessOSALMsg handles OSAL messages as follows: ? 5.2.3 ? ? KEY_CHANGE message: Call function sensor_HandleKeys to handle key presses.Callbacks SensorGAPStateCB: This is the GAP event callback. It processes GAP events for startup and link connect/disconnect. SensorCB: This is the CSC service callback. It handles enabling or disabling periodic CSC measurements when notifications of the CSC measurements are enabled or disabled. Additionally, it informs the application when the peer device has updated a sensor location or changed the cumulative distance traveled.The application callback functions are as follows:5.2.4Sending NotificationsThe application sends notifications of the CSC measurements when configured to do so by the peer device. When the peer device configures the CSC measurements for notification the application will receive a CSC service callback. The application starts a timer to begin periodic simulated CSC measurements for a bicycle. When the timer expires the application calls sensorMeasNotify to build and send a measurement using the CSC service API. 5.2.5 Confirming IndicationsWhen the peer device writes to the sensors control point characteristic the peer device will receive an indication in response. When the indication is received by the peer device, the device must send an ATT_HandleValueConfirmation back to the server. 5.2.6 Reading from the SensorThe CSC service has 2 readable characteristics: Features and Sensor Location. Sending a read request to the Features characteristic triggers a response packet containing a byte array of the feature capabilities of the sensor which are as follows: ? Wheel revolutions ? Crank revolutionsPage 14 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2? Total distance ? Multiple sensor locations Sending a read request to the Sensor Location characteristic triggers a response packet containing the set position of the sensor on the bicycle. This value may be set by writing to the control point (see below), requesting a sensor location update. 5.2.7 Writing to the SensorThe CSC service has one writeable characteristic: the Control Point. A write request can be set with the following requests: ? ? ? ? CSC_SET_CUMM_VAL: Set the total distance traveled field. CSC_START_SENS_CALIB: Calibrate the sensor. Not supported under current profile spec, but it is required. CSC_UPDATE_SENS_LOC: Update the location of the sensor. CSC_REQ_SUPP_SENS_LOC: Request the list of supported sensor locations.A response will be sent as an indication to the peer device after a write response it received. The indication includes the CSC_COMMAND_RSP code, the requested operation code, and a code indicating success or failure. If the command was a request for a list of valid sensor locations, then the indication will also include a byte array containing the valid sensor locations. 5.2.8 Neglect TimerThis device has a compile time option that allows the sensor to terminate a connection if it sees no user input for 15 seconds. In the context of this application, this means that after the device has connected and notifications are disabled, the application starts a timer. This timer is restarted whenever a read or write request comes from the peer device, and is disabled while notifications are enabled. If the value USING_NEGLECT_TIMEOUT is set to FALSE at compile, then this timer is permanently disabled at runtime.6Running Speed and Cadence (RSC) SensorThis sample project implements the Running Speed and Cadence (RSC) profile in a BLE peripheral device to provide a sample application of sensor that would be placed on a bicycle, using simulated measurement data. The application implements the “Sensor” role of the Running Speed and Cadence Profile. This profile also makes use of the optional Device Info Service in the same manner as the Cycling Sensor. The project can be opened with the following IAR workspace file:C:\Texas Instruments\BLE-CC254x-1.3.2\Projects\ble\RunningSensor\CC2541DB\RunningSensor.eww6.1 Project Overview The project is very similar to the Cycling Sensor project. The APP directory contains the application source code and header files. The project contains two configurations: ? CC2541DK-MINI Keyfob Slave: using the keyfob hardware platform. ? CC2541: using the SmartRF platform. 6.1.1 User InterfaceWhen not connected, the keyfob’s right button is used to toggle advertisi ng on and off. When in a connection, the keyfob’s left button cycles through different running speed and cadence sensor data formats. Holding both keys down for 5 seconds initiates a “soft reset.” This includes: ? Terminate all current connections ? Clearing all bond data ? Clearing white list of all peer addressesPage 15 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.26.1.2Basic OperationPower up the device and press the right button to enable advertising. From a RSC collector peer device, initiate a device discovery and connection procedure to discover and connect to the cycling sensor. The peer device should receive a slave security request and initiate a bond. Once bonded, the collector should discover the RSC service and configure it to enable running speed and cadence measurements. Once RSC measurement notifications have been enabled the application will begin sending data to the peer containing simulated measurement values. Pressing the left button cycles through different data formats as follows: ? At rest: neither instantaneous stride length nor total distance is included in measurement. ? Stride: instantaneous stride length is included in measurement. ? Distance: total distance is included in measurement. ? All: both stride length and total distance are included in measurement. The application advertises using either a fast interval or a slow interval. When advertising is initiated by a button press or when a connection is terminated due to link loss, the application will start advertising at the fast interval for 30 seconds. If the sensor has successfully bonded to a peer device and stored the devices address in its white list, then for the for the first 10 seconds of advertising the sensor will only attempt to connect to any device addresses stored in its white list. After 10 seconds, the sensor will attempt to connect to any peer device that wishes to connect. Independent of white list use, after 30 seconds of fast interval connection, a 30 second period of slow interval advertising passes. After this, the device sleeps and waits for the right button to be pressed before resuming advertising again. If the device terminates connection for any other reason, the sensor will advertise for 60 seconds at a slow interval and then sleep if no connection is made. It will begin advertising again only if the right button is pressed. 6.2 Software Description The application is implemented in the file runningSensor.c. 6.2.1 InitializationInitialization of the application occurs in two phases: first, the RunningSensor_Init function is called by the OSAL. This function configures parameters in the peripheral profile, GAP, and GAP bond manager. It also sets up the RSC service along with standard GATT and GAP services in the attribute server. Then it sets an OSAL START_DEVICE_EVT event. This triggers the second phase of the initialization, which can be found within the RunningSensor_ProcessEvent function. During this phase, the GAPRole_StartDevice function is called to set up the GAP functions of the application. Then GAPBOND_Mgr_Register is called to register with the bond manager. 6.2.2 Event Processing The application has two main event processing functions, RunningSensor_ProcessEvent and sensor_ProcessOSALMsg. Function RunningSensor_ProcessEvent handles events as follows: ? SYS_EVENT_MSG: Service the OSAL queue and process OSAL messages. ? START_DEVICE_EVT: Start the device, as described in the previous section. ? RSC_PERIODIC_EVT: Send periodic CSC measurements. ? RSC_CONN_PARAM_UPDATE_EVT: send parameter update until successful ? RSC_NEGLECT_TIMEOUT_EVT: see section 6.2.8 ? RSC_RESET_EVT: reset device as described abovePage 16 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2Function cycling_ProcessOSALMsg handles OSAL messages as follows: ? 6.2.3 ? ? KEY_CHANGE message: Call function sensor_HandleKeys to handle key presses.Callbacks SensorGAPStateCB: This is the GAP event callback. It processes GAP events for startup and link connect/disconnect. SensorCB: This is the RSC service callback. It handles enabling or disabling periodic RSC measurements when notifications of the RSC measurements are enabled or disabled. Additionally, it informs the application when the peer device has updated a sensor location or changed the cumulative distance traveled.The application callback functions are as follows:6.2.4Sending NotificationsThe application sends notifications of the RSC measurements when configured to do so by the peer device. When the peer device configures the RSC measurements for notification the application will receive a RSC service callback. The application starts a timer to begin periodic simulated RSC measurements for a bicycle. When the timer expires the application calls sensorMeasNotify to build and send a measurement using the RSC service API. 6.2.5 Confirming IndicationsWhen the peer device writes to the sensors control point characteristic the peer device will receive an indication in response. When the indication is received by the peer device, the device must send an ATT_HandleValueConfirmation back to the server. 6.2.6 Reading from the SensorThe RSC service has 2 readable characteristics: Features and Sensor Location. Sending a read request to the Features characteristic triggers a response packet containing a byte array of the feature capabilities of the sensor which are as follows: ? Instantaneous Stride Length ? Walking or Running Status ? Total distance ? Multiple sensor locations ? Sensor Calibration Procedure Supported Sending a read request to the Sensor Location characteristic triggers a response packet containing the set position of the sensor on the body. This value may be set by writing to the control point (see below), requesting a sensor location update. 6.2.7 Writing to the SensorThe CSC service has one writeable characteristic: the Control Point. A write request can be set with the following requests: ? ? ? ? RSC_SET_CUMM_VAL: Set the total distance traveled field. RSC_START_SENS_CALIB: Calibrate the sensor. Not supported under current profile spec, but it is required. RSC_UPDATE_SENS_LOC: Update the location of the sensor. RSC_REQ_SUPP_SENS_LOC: Request the list of supported sensor locations.A response will be sent as an indication to the peer device after a write response it received. The indication includes the RSC_COMMAND_RSP code, the requested operation code, and a code indicating success or failure. If the command was a request for a list of valid sensor locations, then the indication will also include a byte array containing the valid sensor locations.Page 17 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.26.2.8Neglect TimerThis device has a compile time option that allows the sensor to terminate a connection if it sees no user input for 15 seconds. In the context of this application, this means that after the device has connected and notifications are disabled, the application starts a timer. This timer is restarted whenever a read or write request comes from the peer device, and is disabled while notifications are enabled. If the value USING_NEGLECT_TIMEOUT is set to FALSE at compile, then this timer is permanently disabled at runtime.7Glucose CollectorThis sample project implements a Glucose Collector. The application is designed to connect to the glucose sensor sample application to demonstrate the operation of the Glucose Profile. 7.1 Project OverviewThe Glucose Collector project structure is very similar to that of the SimpleBLECentral project. The APP directory contains the application source code and header files. The project contains one configuration, CC2540EM Master, using the SmartRF05EB + CC2540EM hardware platform. 7.1.1 User Interface The SmartRF05EB joystick and display provide a user interface for the application. The joystick and buttons are used as follows: ? ? ? ? ? Joystick Up: If not connected, start or stop device discovery. If connected to a glucose sensor, request the number of records that meet configured filter criteria. Joystick Left: Scroll through device discovery results. If connected to a glucose sensor, send a record access abort message. Joystick Center: Connect or disconnect to/from the currently selected device. Joystick Right: If connected, request records that meet configured filter criteria. Joystick Down: If connected, clear records that meet configured filter criteria. If not connected, erase all bonds.The LCD display is used to display the following information: ? ? ? ? ? ? Device BD address. Device discovery results. Connection state. Pairing and bonding status. Number of records requested. Sequence number, glucose concentration, and Hba1c value of received glucose measurement and context notifications. Basic Operation7.1.2When the application powers up it displays &Gluc. Collector& and the BD address of the device. Press Joystick Up to start device discovery. When discovery completes the number of devices found will be displayed. Press Joystick Left to scroll through the devices. To connect to the selected device press Joystick Center. The connection status will be displayed. Once connected, the application will attempt to discover the Glucose service and Device Information service on the peer device. Since the Glucose profile required security the application will also initiate bonding. When the bonding is complete, other operations such as reading or erasing records can be performed described in the previous section. It is important to note that, due to the input / output capabilities of the keyfob, we have to use a fixed password in order to achieve authenticated pairing. We have set the I/O capabilities of the keyfob to display only. The idea is that the keyfob will display the passcode and it will be entered on the SmartRF. However, because the keyfob and SmartRF don’t actually have these I/O capabilities, we hard code the passcode in the sensor and collector projects to be 19655.Page 18 of 37 Copyright ?
Texas Instruments, Inc TI CC2540 Bluetooth Low Energy Sample Applications Guide v1.3.2SWRU297 Version 1.3.2To disconnect press Joystick Center again. Joystick Center again. 7.1.3 Record Filter ConfigurationTo reconnect to the same device again pressGlucose record requests use filters to select the records that will be operated on by the request. These filters are configured in the collector using compile time configuration. In file glucoseCollector.c, macro GLUCOSE_FILTER_ENABLED controls whether filters are used. When set to FALSE, operations that read, erase, or get the number of records will operate on all records. When set to TRUE, these operations will use either a time filter or sequence number filter, as configured in macro DEFAULT_FILTER_TYPE. When set to CTL_PNT_FILTER_SEQNUM the collector will filter on sequence number. When set to CTL_PNT_FILTER_TIME the collector will filter on time. File glucoseCollector.c has hardcoded time and sequence number filter values. These are set in variabl

我要回帖

更多关于 一键还原 支持win8.1 的文章

 

随机推荐