witmotion-react-native
Version:
React Native SDK for WitMotion BLE IMU sensors (WT901, WT901BLECL, etc.)
60 lines (59 loc) • 1.33 kB
TypeScript
/**
* WitMotion BLE Parser for React Native
*
* Parses packets according to the official WIT Standard Protocol.
* Supports:
* - Standard packets (0x50–0x5A, 11 bytes with checksum)
* - Combined packets 0x61 (20 bytes without checksum, or fragmented)
* - Register packets 0x71 (20 or 22 bytes, depending on firmware version)
*
* Reference: WitMotion SDK / WT901BLECL Datasheet
*/
export type WitData = {
acc?: {
x: number;
y: number;
z: number;
};
gyro?: {
x: number;
y: number;
z: number;
};
angle?: {
roll: number;
pitch: number;
yaw: number;
};
mag?: {
x: number;
y: number;
z: number;
};
quat?: {
w: number;
x: number;
y: number;
z: number;
};
temp?: number;
};
/**
* Register codes for 0x71 packets (mirroring the official SDK).
* Extend this enum if your device firmware provides additional registers.
*/
export declare enum WitReg {
Quaternion = 0,
Magnetometer = 1,
Temperature = 2
}
export declare class WitStreamParser {
private buf;
private comb61;
onData?: (d: WitData) => void;
push(bytes: Uint8Array): void;
private i16;
private decode61;
private decodeStd;
private decode71;
}