HxM Bluetooth API Guide
Document History Version 1.1 1.2 1.3 1.4 1.5 1.6 1.7 Date 16-05-2008 14-07-2008 28-08-2008 19-01-2009 19-05-2010 31-05-2010 22-07-2010 Description Initial version Added requirement for a security passkey to the security section. Added comms. packet information Added HyperTerminal Hardware Check Remove cadence Correct stride rollover value to 128 Add Packet Logger Utility Document Notes All numbers in this document are written in decimal, except hexadecimal numbers which are prefixed by ‘0x’.
Contents 1. 2. 3. 4. 5. 6. 7. 8. 9. REFERENCES ........................................................................................................................................ 4 ABBREVIATIONS.................................................................................................................................... 4 INTRODUCTION ..................................................................................................................................... 4 SYSTEM OVERVIEW .........
1. References Ref # [1] ID 9700.0028c Description General Comms Link Specification. 2. Abbreviations Abbreviation API ECG HRM HxM PC RTC SPP Description Application Programmer’s Interface ElectroCardioGram Heart Rate Monitor Heart Rate / Speed and Distance Monitor Personal Computer Real Time Clock Serial Port Profile 3.
4. System Overview 4.1. System Architecture Mobile Device HxM Bluetooth Link Figure 1 : HxM System Architecture The diagram above shows that the Bluetooth HxM typically communicates with a mobile device over the Bluetooth link. The HxM only supports one link at a time and uses the Bluetooth SPP (Serial Port Profile) to communicate with other devices with the following low-level protocol: • • • • 115,200 baud 8 data bits 1 stop bit No parity 4.2. Connecting to HxM Device The device is discoverable.
Figure 2 : Scan for Bluetooth devices in range The device is discoverable. The discoverable name of the device is its serial number. To connect to the device a passkey must be used. The passkey is “1234”, and cannot be changed. Figure 3 : Pair with HxM and provide PIN Figure 4 : Discover services of HxM device Page 6 of 21 Ph: 1-443-569-3603 9700.0031 Fax: 1-443-926-9402 © Zephyr Technology 2010 Web: www.zephyr-technology.
Figure 5 : Connect to Bluetooth HxM serial port Figure 6 : Connected to Bluetooth HxM serial port Page 7 of 21 Ph: 1-443-569-3603 9700.0031 Fax: 1-443-926-9402 © Zephyr Technology 2010 Web: www.zephyr-technology.
5. HxM Communications Link Once a Bluetooth connection has been established with the HxM, the data packets can be received by the connecting device. The following sequence diagram shows an example session: Mobile Device or PC HxM Bluetooth Link Heart Rate, Speed & Distance Packet 1 Second Figure 7 : Example link session The diagram shows that after the mobile device has connected to the HRM it receives a data packet from the HxM at 1 second intervals.
6. Communications Packet Structure Overview The serial communication between the HxM device and the paired device operates in a simplex mode. The HxM device transmits the HxM data packet and does not process any received data. 6.1. Basic Message Format HxM Transmitted Data Packet: STX Msg ID Data Payload DLC Number of bytes in the Data Payload 0…128 bytes CRC ETX Calculated over the Data Payload area Figure 8 : Basic Message Format 6.1.1.
6.1.5. CRC An 8-bit CRC is used and has a polynomial of 0x8C (CRC-8), with the accumulator being initialised to zero before the CRC calculation begins. The following source code indicates the required implementation: crc: Ch: The current CRC. Value to add to the CRC calculation.
7. Standard HxM Data Message 7.1. MSG:0x26 – Heart Rate, Speed & Distance packet This message contains the heart rate data, including the last 15 RR timestamps, and speed & distance data. The packet is transmitted periodically at 1Hz. Byte/Bit 0 1 2 3 5 7 9 11 12 13 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 55 56 58 59 7 Table 7.
7.1.1. Packing Format All bytes are little endian. All 16 bit unsigned integers are sent least significant byte first. Firmware ID & Version Zephyr Firmware releases are identified with identification codes of the following form “9500.xxxx.Vyz” where xxxx is a number indentifying the firmware type (0000 - 9999), and y is the major version (1 – 9) and z is the minor version (A – Z, or a-z). The firmware ID field represents xxxx, and the firmware version field is two ASCII bytes representing yz.
Heart Beat Timestamp (1 to 15) The heart beat timestamp is a 16 bit unsigned integer, representing the time at which the heart beat occurred, in milliseconds. (Valid range 0 – 65535ms) The time used to populate the timestamp rolls over after 65535ms. This should be taken into consideration when calculating the heart beat interval (RR time). The R to R data consists of a series of R-detection timestamps with 1 millisecond resolution. The internal clock rolls over at 65535 ms.
8. Hardware Check Using Hyper Terminal The following steps can be used to confirm output from the device using Hyper Terminal. In this example, the Bluetooth Utility used is IVT BlueSoleil in a desktop PC in conjunction with a USB Bluetooth dongle. 1. Start your Bluetooth utility and establish a connection with the HxM In the example above the device is HxM001127 2. Establish a Connection with the device using Passkey ‘1234’ Page 14 of 21 Ph: 1-443-569-3603 9700.
3. Determine which COM Port is being used: The Serial Port Service is COM47 in this example Use Windows > Start > All Programs > Accessories > Communications > Hyper Terminal Enter ‘HxM Test’ or similar as a New Connection name. Page 15 of 21 Ph: 1-443-569-3603 9700.0031 Fax: 1-443-926-9402 © Zephyr Technology 2010 Web: www.zephyr-technology.
4. Select the COM Port from the pulldown list and click OK 5. Set the Connection Properties as shown Page 16 of 21 Ph: 1-443-569-3603 9700.0031 Fax: 1-443-926-9402 © Zephyr Technology 2010 Web: www.zephyr-technology.
6. The Hyper Terminal Window should now show output from the device Note that the device outputs binary data. Hyper Terminal displays this as ASCII. Notes: 1. The device has wear-detect circuitry which switches on data output. If no data is observed, moisten the sensors pads with water. Excessively dry skin may not have sufficient conductivity to turn the device on. Page 17 of 21 Ph: 1-443-569-3603 9700.0031 Fax: 1-443-926-9402 © Zephyr Technology 2010 Web: www.zephyr-technology.
9. HxM Packet Logger Utility A PC Tool is included as part of the SDK to allow you to receive and record data from a PC with a Bluetooth Interface. This can be a native PC Bluetooth card, or a Bluetooth USB dongle. 9.1. Installation 9.1.1. .NET 3.5 SP1 This utilities requires that Microsoft® .NET3.5SP1 be installed on your PC for it to operate (this framework is embed in Windows 7). To install, browse the CD to locate .. \BT HxM SDK\Microsoft\DotNetFX35SP1\dotNetFx35setup.
9.2. Operation In order to use the Packet Logger, you must determine which COM Port is receiving the HxM data. Wear the device and moisten the sensor pads to power it on. Use the Bluetooth Interface of your PC, or that supplied with your Bluetooth USB dongle, to display the Properties of the connection to the device: Note the COM Port number which has been allocated to the connection. Page 19 of 21 Ph: 1-443-569-3603 9700.0031 Fax: 1-443-926-9402 © Zephyr Technology 2010 Web: www.zephyr-technology.
Start the Packet Logger utility, enter the COM Port number, and click Open to start the tool: To record data, click the browse buttons , find a suitable location and enter the name of the file you want recorded. Do this for both the RR Log (text) file and the 1Hz Log (.csv) file Page 20 of 21 Ph: 1-443-569-3603 9700.0031 Fax: 1-443-926-9402 © Zephyr Technology 2010 Web: www.zephyr-technology.
Click the Start Logging button to create the log files. Click Stop Logging when required. Note: Each time the Start Logging button is clicked subsequently, the utility will overwrite any data already in the file displayed in the log file path. A new file must be created prior to clicking the Start Logging button if you don’t want to over-write data already recorded. 9.2.1. RR Log data The text file contains heart rate RR intervals, measured in milliseconds. There is no timestamp information. 9.2.2.