import { B as BaseProfile } from '../base-n3IBbs7i.mjs'; import '../error-taxonomy-CWrJx3aZ.mjs'; /** * Service UUIDs a Heart Rate device may reach after connection (the SIG Heart * Rate Service, 0x180D). Canonical 128-bit form (resolved from the SIG alias via * the core registry — single source of truth). Use with `optionalServices` / * `Beacio.registerServices`, or via {@link deriveOptionalServices} given * {@link HeartRateProfile}. */ declare const HEART_RATE_SERVICES: readonly string[]; /** * Parsed heart rate measurement data from the Heart Rate Measurement * characteristic (UUID 0x2A37). * * Fields are populated based on the flags byte in the BLE payload. * Optional fields are `null` when the corresponding flag bit is unset. */ interface HeartRateData { /** Heart rate value in beats per minute (BPM). May be 8-bit or 16-bit depending on the flags byte. */ bpm: number; /** Whether the sensor has skin contact. `null` if the sensor does not support contact detection. */ contact: boolean | null; /** Cumulative energy expended in kilojoules since the last reset. `null` if not present in this measurement. */ energyExpended: number | null; /** RR-interval values in seconds (1/1024 s resolution). Empty array if not present in this measurement. */ rrIntervals: number[]; } /** * BLE Heart Rate Service profile (UUID 0x180D). * * Provides access to heart rate measurements, body sensor location, * and the energy-expended reset control point as defined by the * Bluetooth SIG Heart Rate Service specification. * * The measurement characteristic (0x2A37) uses a flags byte: * bit 0 = HR format (0 = UINT8, 1 = UINT16), bits 1-2 = sensor contact, * bit 3 = energy expended present, bit 4 = RR-interval present. * * @example * ```ts * import { HeartRateProfile } from '@beacio/core/profiles'; * * const hr = new HeartRateProfile(device); * await hr.connect(); * * // Subscribe to real-time heart rate data * const unsubscribe = hr.onHeartRate((data) => { * console.log(`BPM: ${data.bpm}`); * if (data.contact === false) { * console.warn('No skin contact detected'); * } * if (data.rrIntervals.length > 0) { * console.log('RR intervals (s):', data.rrIntervals); * } * }); * * // Read sensor location (e.g. 1 = Chest, 2 = Wrist) * const location = await hr.readSensorLocation(); * * // Clean up * unsubscribe(); * hr.stop(); * ``` */ declare class HeartRateProfile extends BaseProfile { /** Services this profile's device may reach after connection (Heart Rate, 0x180D). Read by {@link deriveOptionalServices}. */ static readonly services: readonly string[]; protected readonly service = "heart_rate"; /** Subscribe to heart rate measurements. Returns unsubscribe function. */ onHeartRate(callback: (data: HeartRateData) => void): () => void; /** Read body sensor location (0=Other, 1=Chest, 2=Wrist, ...) */ readSensorLocation(): Promise; /** Reset energy expended counter */ resetEnergyExpended(): Promise; } /** * Parse a raw Heart Rate Measurement characteristic value (UUID 0x2A37) * into a structured {@link HeartRateData} object. * * The first byte is a flags field that determines the format and which * optional fields are present. This function handles all flag combinations * defined by the Bluetooth SIG specification. * * @param dv - Raw characteristic value as a {@link DataView}. * @returns Parsed heart rate data with BPM, contact status, energy, and RR intervals. * * @example * ```ts * import { parseHeartRate } from '@beacio/core/profiles'; * * // Manually parse a DataView from a notification * const data = parseHeartRate(characteristicValue); * console.log(`Heart rate: ${data.bpm} BPM`); * ``` */ declare function parseHeartRate(dv: DataView): HeartRateData; export { HEART_RATE_SERVICES, type HeartRateData, HeartRateProfile, parseHeartRate };