@rodit/hola-mfsk 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/LICENSE +661 -0
- package/README.md +49 -2
- package/index.d.ts +97 -0
- package/index.js +3 -0
- package/lib/mfsk.js +596 -0
- package/package.json +60 -4
package/README.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rodit/hola-mfsk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Isomorphic **4-tone MFSK** physical layer for IdentyClaw HOLA over the air / voice path.
|
|
4
|
+
|
|
5
|
+
> **Face ≠ proof.** This package moves framed text (usually a HOLA line or short `HEY/…` challenge). Presentation (Anam / LiveKit face) is not trust. Trust is the live HOLA line (or a short guest offer URL from `POST /api/hola/offer`). Classic dit-dah Morse is **not** the product.
|
|
6
|
+
|
|
7
|
+
## PHY (keep identical across hosts)
|
|
8
|
+
|
|
9
|
+
| Param | Value |
|
|
10
|
+
|-------|--------|
|
|
11
|
+
| Tones | **1800 / 2100 / 2400 / 2700 Hz** (2 bits/symbol) |
|
|
12
|
+
| Baud | **100** (~200 bps) |
|
|
13
|
+
| Sample rate default | 16 000 Hz (48 kHz synth also decodes) |
|
|
14
|
+
| Frame | AGC warmup → SOF chirp → `COBS(payload‖CRC-16)‖0x00` → EOF chirp |
|
|
15
|
+
|
|
16
|
+
Host adapters (Expo `Audio`, Web Audio, LiveKit `agent-audio`) stay **outside** this package.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @rodit/hola-mfsk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const {
|
|
28
|
+
encodeHolaToPcm,
|
|
29
|
+
decodePcmToHola,
|
|
30
|
+
decodePcmToFramedText,
|
|
31
|
+
isMfskBandBusy,
|
|
32
|
+
FSK_TONES_HZ,
|
|
33
|
+
FSK_BAUD,
|
|
34
|
+
} = require("@rodit/hola-mfsk");
|
|
35
|
+
|
|
36
|
+
const { samples, sampleRate, durationMs } = encodeHolaToPcm(holaLine);
|
|
37
|
+
const { hola } = decodePcmToHola(float32Pcm, sampleRate);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Deep import: `@rodit/hola-mfsk/lib/mfsk`.
|
|
41
|
+
|
|
42
|
+
## Related
|
|
43
|
+
|
|
44
|
+
- [`@rodit/hola-qr`](../hola-qr/) — QR payload parse/build + Node PNG/RGBA encode
|
|
45
|
+
- [`@rodit/hola-air`](../hola-air/) — `HEY/<id>/<32hex>/<checksum>` air challenge
|
|
46
|
+
- [`@rodit/hola-client`](../hola-client/) — create / sign HOLA lines
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
[AGPL-3.0-only](LICENSE)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Harmonic 4-tone MFSK for audible HOLA transport (isomorphic PHY). */
|
|
2
|
+
|
|
3
|
+
export const FSK_SAMPLE_RATE: 16000;
|
|
4
|
+
/** Base frequencies (2 bits/symbol). */
|
|
5
|
+
export const FSK_TONES_HZ: readonly [1800, 2100, 2400, 2700];
|
|
6
|
+
/** ~100 baud × 2 bits ≈ 200 bps. */
|
|
7
|
+
export const FSK_BAUD: 100;
|
|
8
|
+
export const FSK_BITS_PER_SYMBOL: 2;
|
|
9
|
+
|
|
10
|
+
export function markerSampleCount(sampleRate?: number): number;
|
|
11
|
+
export function sofConfirmSamples(sampleRate?: number): number;
|
|
12
|
+
|
|
13
|
+
/** Frame text as COBS(payload ‖ CRC-16) ‖ 0x00. */
|
|
14
|
+
export function frameHolaBytes(text: string): Uint8Array;
|
|
15
|
+
/** Scan bit stream for COBS‖0x00 frames; first valid CRC-16 UTF-8 payload. */
|
|
16
|
+
export function deframeFramedText(bits: number[]): string | null;
|
|
17
|
+
/** Deframe then extract a HOLA/… line (or raw hola/ prefix). */
|
|
18
|
+
export function deframeHolaBytes(bits: number[]): string | null;
|
|
19
|
+
|
|
20
|
+
export type MfskBandBusyScore = {
|
|
21
|
+
busy: boolean;
|
|
22
|
+
recent: number;
|
|
23
|
+
noise: number;
|
|
24
|
+
ratio: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** PHY carrier sense — MFSK-band energy only (no SOF / framing). */
|
|
28
|
+
export function scoreMfskBandBusy(
|
|
29
|
+
pcm: Float32Array | Int16Array,
|
|
30
|
+
sampleRate?: number
|
|
31
|
+
): MfskBandBusyScore;
|
|
32
|
+
|
|
33
|
+
export function isMfskBandBusy(
|
|
34
|
+
pcm: Float32Array | Int16Array,
|
|
35
|
+
sampleRate?: number
|
|
36
|
+
): boolean;
|
|
37
|
+
|
|
38
|
+
export function findSofOffset(
|
|
39
|
+
pcm: Float32Array | Int16Array,
|
|
40
|
+
sampleRate?: number,
|
|
41
|
+
fromOffset?: number,
|
|
42
|
+
toOffset?: number
|
|
43
|
+
): number | null;
|
|
44
|
+
|
|
45
|
+
export function findEofOffset(
|
|
46
|
+
pcm: Float32Array | Int16Array,
|
|
47
|
+
sampleRate?: number,
|
|
48
|
+
fromOffset?: number,
|
|
49
|
+
toOffset?: number
|
|
50
|
+
): number | null;
|
|
51
|
+
|
|
52
|
+
export function payloadStartAfterSof(
|
|
53
|
+
sofOffset: number,
|
|
54
|
+
sampleRate?: number
|
|
55
|
+
): number;
|
|
56
|
+
|
|
57
|
+
export function estimatePlaceholderHola(holaCharEstimate?: number): string;
|
|
58
|
+
export function estimatePlaceholderChallenge(charEstimate?: number): string;
|
|
59
|
+
export function maxDemodSamplesAfterPayload(sampleRate?: number): number;
|
|
60
|
+
export function estimateFskDurationMs(text: string, sampleRate?: number): number;
|
|
61
|
+
|
|
62
|
+
export type EncodedHolaPcm = {
|
|
63
|
+
samples: Int16Array;
|
|
64
|
+
sampleRate: number;
|
|
65
|
+
durationMs: number;
|
|
66
|
+
layout: {
|
|
67
|
+
warmupSamples: number;
|
|
68
|
+
sofSamples: number;
|
|
69
|
+
payloadSamples: number;
|
|
70
|
+
eofSamples: number;
|
|
71
|
+
sofStart: number;
|
|
72
|
+
payloadStart: number;
|
|
73
|
+
eofStart: number;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export function encodeHolaToPcm(
|
|
78
|
+
text: string,
|
|
79
|
+
options?: { sampleRate?: number }
|
|
80
|
+
): EncodedHolaPcm;
|
|
81
|
+
|
|
82
|
+
export type DecodePcmOptions = {
|
|
83
|
+
/** Absolute sample index where SOF begins. */
|
|
84
|
+
sofOffset?: number;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export function decodePcmToFramedText(
|
|
88
|
+
pcm: Float32Array | Int16Array,
|
|
89
|
+
sampleRate?: number,
|
|
90
|
+
options?: DecodePcmOptions
|
|
91
|
+
): { text: string | null };
|
|
92
|
+
|
|
93
|
+
export function decodePcmToHola(
|
|
94
|
+
pcm: Float32Array | Int16Array,
|
|
95
|
+
sampleRate?: number,
|
|
96
|
+
options?: DecodePcmOptions
|
|
97
|
+
): { hola: string | null; text: string };
|
package/index.js
ADDED