import { describe, it, expect } from 'vitest' // @ts-ignore import { DEVICE_PROFILE, getBleProfile, guessProfileByRadarFrame } from '@/ble/protocols/profiles' describe('protocol profiles', () => { it('ED713:雷达签名 0x7C、支持窄床模式、不支持跌倒参数 67', () => { const p = getBleProfile(DEVICE_PROFILE.ED713) expect(p.radar.notifySignature).toBe(0x7c) expect(p.cmd.supportsNarrowMode).toBe(true) expect(p.cmd.supportsFallParam67).toBe(false) }) it('ED719:雷达签名 0x67、支持跌倒参数 67、不支持窄床模式', () => { const p = getBleProfile(DEVICE_PROFILE.ED719) expect(p.radar.notifySignature).toBe(0x67) expect(p.cmd.supportsFallParam67).toBe(true) expect(p.cmd.supportsNarrowMode).toBe(false) }) it('未知 profileId 兜底返回 UNKNOWN profile', () => { const p = getBleProfile('NOT_EXIST') expect(p.id).toBe(DEVICE_PROFILE.UNKNOWN) }) it('guessProfileByRadarFrame 按签名第 4 字节推断型号', () => { const ed713Frame = new Uint8Array([0, 0, 0, 0x7c]) const ed719Frame = new Uint8Array([0, 0, 0, 0x67]) expect(guessProfileByRadarFrame(ed713Frame)).toBe(DEVICE_PROFILE.ED713) expect(guessProfileByRadarFrame(ed719Frame)).toBe(DEVICE_PROFILE.ED719) }) it('packet 分片规则:head 0xA7 / chunkSize 18 / maxChunk 15', () => { const p = getBleProfile(DEVICE_PROFILE.ED713) expect(p.packet.head).toBe(0xa7) expect(p.packet.chunkSize).toBe(18) expect(p.packet.maxChunk).toBe(15) }) })