ggwave-python icon indicating copy to clipboard operation
ggwave-python copied to clipboard

Configuring the CUSTOM_0 - CUSTOM_9 Protocols

Open stefankind1905 opened this issue 1 year ago • 0 comments

Hello!

I really like your python wrapper for ggwave. It's quite easy and user-friendly to integrate the transmission protocol now, thanks!

As my C++ skills are really poor, I was wondering if there would also be a way to configure the CUSTOM_1 - CUSTOM_9 protocols in Python? I'd mainly like to just change F0, the lowest starting frequency of the transmission!

Thanks for your work!

I just found this ProtocolID class in the library but there is no way to adjust the protocols here!

`class ProtocolId(IntEnum): """Defines different transmission protocols available in GGWave.

# Modulation (Tx)

The current approach uses a multi-frequency Frequency-Shift Keying (FSK) modulation scheme.
The data to be transmitted is first split into 4-bit chunks.
At each moment of time, 3 bytes are transmitted using 6 tones - one tone for each 4-bit chunk.
The 6 tones are emitted in a 4.5kHz range divided in 96 equally-spaced frequencies

Freq_Hz = F0 + chunk_no * dF

For all protocols: dF = 46.875 Hz.
For non-ultrasonic protocols: F0 = 1875.000 Hz.
For ultrasonic protocols: F0 = 15000.000 Hz.

The original data is encoded using Reed-Solomon error codes.
The number of ECC bytes is determined based on the length of the original data.
The encoded data is the one being transmitted.

# Demodulation (Rx)

Beginning and ending of the transmission are marked with special sound markers.
The receiver listens for these markers and records the in-between sound data.
The recorded data is then Fourier transformed to obtain a frequency spectrum.
The detected frequencies are decoded back to binary data in the same way they were encoded.

Reed-Solomon decoding is finally performed to obtain the original data.

# Markers

The begin marker uses the first 32 frequency bins: F0 + 00*df to F0 + 31*df.
We produce a waveform which consists of 16 frequencies:

F0 + 00*df
F0 + 03*df
F0 + 04*df
F0 + 07*df
F0 + 08*df
F0 + 11*df
F0 + 12*df
F0 + 15*df
F0 + 16*df
F0 + 19*df
F0 + 20*df
F0 + 23*df
F0 + 24*df
F0 + 27*df
F0 + 28*df
F0 + 31*df

The end marker consists again of 16 frequencies - the ones that are missing in the begin marker.
For each frame of input samples, compute the FFT and analyze the 32 bins.
"""

AUDIBLE_NORMAL = 0  # Standard audible range transmission
AUDIBLE_FAST = 1
AUDIBLE_FASTEST = 2
ULTRASOUND_NORMAL = 3  # Ultrasound transmission (above human hearing)
ULTRASOUND_FAST = 4
ULTRASOUND_FASTEST = 5
DT_NORMAL = 6  # Dual-tone protocol (DTMF-like)
DT_FAST = 7
DT_FASTEST = 8
MT_NORMAL = 9  # Multi-tone protocol (higher data rates)
MT_FAST = 10
MT_FASTEST = 11
CUSTOM_0 = 12  # Custom user-defined protocol
CUSTOM_1 = 13
CUSTOM_2 = 14
CUSTOM_3 = 15
CUSTOM_4 = 16
CUSTOM_5 = 17
CUSTOM_6 = 18
CUSTOM_7 = 19
CUSTOM_8 = 20
CUSTOM_9 = 21`

stefankind1905 avatar Apr 16 '25 01:04 stefankind1905