UNPKG

@hangtime/grip-connect

Version:

Griptonite Motherboard, Tindeq Progressor, PitchSix Force Board, CTS500, WHC-06, Entralpi, Climbro, mySmartBoard: Bluetooth API Force-Sensing strength analysis for climbers

173 lines 7.05 kB
import { Device } from "../device.model.js"; import type { CTS500BaudRate, CTS500SamplingRate, ICTS500 } from "../../interfaces/device/cts500.interface.js"; /** * Represents the CTS500 Climbing Training Scale, marketed as "Jlyscales CTS500". * Supplier: Hunan Jinlian Cloud Information Technology Co., Ltd. * {@link https://www.huaying-scales.com/} * {@link https://www.alibaba.com/product-detail/Mini-Climbing-Training-Scale-CTS500-Aluminum_1601637814595.html} */ export declare class CTS500 extends Device implements ICTS500 { private bufferedFrames; private pendingFrame; private requestQueue; private isStreaming; private commandOpcodes; constructor(); /** * Retrieves battery voltage from the device. * The returned string uses two decimal places, e.g. "3.55". * @returns {Promise<string | undefined>} A Promise that resolves with the battery voltage. */ battery: () => Promise<string | undefined>; /** * Retrieves firmware version from the device. * @returns {Promise<string | undefined>} A Promise that resolves with the firmware version. */ firmware: () => Promise<string | undefined>; /** * Retrieves hardware version from the device. * @returns {Promise<string | undefined>} A Promise that resolves with the hardware version. */ hardware: () => Promise<string | undefined>; /** * Retrieves manufacturer information from the device. * @returns {Promise<string | undefined>} A Promise that resolves with the manufacturer information. */ manufacturer: () => Promise<string | undefined>; /** * Retrieves model number from the device. * @returns {Promise<string | undefined>} A Promise that resolves with the model number. */ model: () => Promise<string | undefined>; /** * Sets whether the device should reset to zero on power-up. * @param {boolean} enabled - Whether power-on reset should be enabled. * @returns {Promise<void>} A promise that resolves when the command is acknowledged. */ powerOnReset: (enabled: boolean) => Promise<void>; /** * Enables or disables the device peak mode. * @param {boolean} [enabled=true] - Whether peak mode should be enabled. * @returns {Promise<void>} A promise that resolves when the command is acknowledged. */ peakMode: (enabled?: boolean) => Promise<void>; /** * Configures the device UART baud rate. * @param {CTS500BaudRate} baudRate - Desired baud rate. * @returns {Promise<void>} A promise that resolves when the command is acknowledged. */ setBaudRate: (baudRate: CTS500BaudRate) => Promise<void>; /** * Configures the device A/D sampling rate. * @param {CTS500SamplingRate} samplingRate - Desired A/D sampling rate in Hz. * @returns {Promise<void>} A promise that resolves when the command is acknowledged. */ setSamplingRate: (samplingRate: CTS500SamplingRate) => Promise<void>; /** * Retrieves serial number from the device. * @returns {Promise<string | undefined>} A Promise that resolves with the serial number. */ serial: () => Promise<string | undefined>; /** * Retrieves software version from the device. * @returns {Promise<string | undefined>} A Promise that resolves with the software version. */ software: () => Promise<string | undefined>; /** * Starts automatic weight uploads. * @param {number} [duration=0] - Optional delay before the promise resolves. * @returns {Promise<void>} A promise that resolves once upload mode has been enabled. */ stream: (duration?: number) => Promise<void>; /** * Stops automatic weight uploads. * @returns {Promise<void>} A promise that resolves once upload mode has been disabled. */ stop: () => Promise<void>; /** * Reads the current temperature from the device. * @returns {Promise<string | undefined>} A Promise that resolves with the temperature in Celsius. */ temperature: () => Promise<string | undefined>; /** * Uses the device's hardware tare command when connected and falls back to software tare otherwise. * @param {number} [duration=5000] - Software tare duration when the device is not connected. * @returns {boolean} `true` when the tare operation started successfully. */ tare: (duration?: number) => boolean; /** * Reads the current weight from the device in kilograms. * @returns {Promise<number | undefined>} A Promise that resolves with the current weight. */ weight: () => Promise<number | undefined>; /** * Updates the device hardware zero point. * @returns {Promise<void>} A promise that resolves when the command is acknowledged. */ zero: () => Promise<void>; /** * Parses UART frames received over the MY-BT102 notify characteristic. * Supports fragmented BLE notifications by buffering until a complete CTS500 frame is available. * * @param {DataView} value - The notification payload from the device. */ handleNotifications: (value: DataView) => void; /** * Waits for a specific frame pattern after sending a CTS500 command. */ private queryFrame; /** * Sends a command that should be acknowledged with a 6-byte echo frame. */ private expectAck; /** * Sends a configuration command that may reply with either a 6-byte echo, a typed response, or no reply after applying. */ private applyConfigCommand; /** * Resolves the currently pending frame promise if the incoming frame matches. * @returns {boolean} Whether a pending request consumed the frame. */ private consumePendingFrame; /** * Clears the currently pending frame wait, if any. */ private clearPendingFrame; /** * Extracts the next valid CTS500 frame from the local notification buffer. */ private extractNextFrame; /** * Routes a validated CTS500 frame to pending requests, callbacks, and stream processing. */ private handleFrame; /** * Returns whether a frame is a 6-byte command acknowledgment echo for the given opcode. */ private isAckFrame; /** * Returns whether a frame is a typed command response (`05 80 <opcode> ... checksum`). */ private isCommandResponse; /** * Returns whether a frame contains a weight measurement payload. */ private isWeightFrame; /** * Updates rolling statistics and emits a force measurement from a CTS500 weight frame. */ private recordWeightMeasurement; /** * Validates a CTS500 frame checksum. */ private isValidFrame; /** * Registers a pending frame matcher with a timeout. */ private waitForFrame; /** * Serializes CTS500 command/response operations so query-style methods can be called in parallel by consumers. */ private enqueueRequest; } //# sourceMappingURL=cts500.model.d.ts.map