TinyModem
Header-only software audio modem library
Loading...
Searching...
No Matches
tinymodem::AX25Encoder Class Reference

AX.25 packet radio modulator (APRS, 1200 baud AFSK). The written data is converted to AX.25 frames, which are sent with HDLC framing (flags, bit stuffing, frame check sequence) and NRZI coding. More...

#include <AX25Encoder.h>

Inheritance diagram for tinymodem::AX25Encoder:
Collaboration diagram for tinymodem::AX25Encoder:

Public Member Functions

 AX25Encoder ()=default
 AX25Encoder (Print &out)
AX25Config defaultConfig ()
 Provides a default configuration: APRS (1200 baud AFSK).
void setAudioInfo (audio_tools::AudioInfo info) override
 Defines the sample rate and number of channels of the generated audio.
audio_tools::AudioInfo audioInfo () override
bool begin (AX25Config config)
 Starts the processing with the indicated configuration.
bool begin () override
void end () override
size_t write (const uint8_t *data, size_t len) override
 Provide the frames as text lines or KISS frames.
bool writeFrame (const uint8_t *frame, size_t len)
 Sends a frame (without FCS).
bool endTransmission (size_t silence_samples=0) override
bool writeIdle (size_t nsamples) override
 Sends flags for the indicated number of samples.
bool isTransmitting () override
 true between the first frame and endTransmission()
float symbolRate () override
 Bits per second.
size_t frameCount ()
 Number of sent frames.
AX25Config & config ()
 The configuration which was provided in begin().
 operator bool () override
Public Member Functions inherited from tinymodem::ModemEncoder
void setOutput (Print &out) override
void setGenerator (audio_tools::SoundGenerator< int16_t > &generator)
audio_tools::SoundGenerator< int16_t > & getGenerator ()
 Provides the active tone generator.
void writeSilence (size_t nsamples)
 Writes the indicated number of samples of silence.
void writeTone (float freq, size_t nsamples)
 Writes a tone for the indicated number of samples.
void flush ()
 Ends the transmission.
const char * mime () override

Protected Types

enum class  KissState { IDLE , COMMAND , DATA , ESCAPE }

Protected Member Functions

void writeText (uint8_t ch)
void writeKiss (uint8_t ch)
void addKiss (uint8_t ch)
void startTransmission ()
void sendPreamble (int ms)
 Flags (IL2P: 0x55) for the indicated time.
bool writeFX25 (const uint8_t *frame, size_t len)
 FX.25: correlation tag and Reed-Solomon code word (NRZI, no stuffing).
bool writeIL2P (const uint8_t *frame, size_t len)
 IL2P: preamble, sync word and the encoded frame (no NRZI).
void sendBits (uint8_t value)
 least significant bit first without bit stuffing (NRZI)
void sendRawByte (uint8_t value)
 most significant bit first without NRZI: 1 = mark
void sendFlag ()
 0x7E without bit stuffing
void sendByte (uint8_t value)
 least significant bit first with bit stuffing
void sendBit (int bit)
 NRZI: a 0 changes the tone, a 1 keeps it.
void sendTone ()
 sends the current tone for one bit

Protected Attributes

AX25Config cfg
bool is_active = false
bool transmitting = false
double samples_per_bit = 40
uint64_t bit_index = 0
bool nrzi_tone = true
int ones = 0
size_t frames = 0
char input [AX25Frame::MAX_FRAME+100]
int input_len = 0
uint8_t frame [AX25Frame::MAX_FRAME]
KissState kiss_state = KissState::IDLE
bool kiss_data_frame = false
Protected Attributes inherited from tinymodem::ModemEncoder
ToneOutput tones

Detailed Description

AX.25 packet radio modulator (APRS, 1200 baud AFSK). The written data is converted to AX.25 frames, which are sent with HDLC framing (flags, bit stuffing, frame check sequence) and NRZI coding.

In AX25Format::TEXT each line (terminated by '
') is a frame in the monitor format SRC>DEST,DIGI1,DIGI2:info. In AX25Format::KISS the data consists of KISS frames. A frame is sent as soon as it is complete: the first frame of a transmission is preceded by tx_delay_ms of flags. Call endTransmission() (or flush()) to send the tail flags.

AX25Config::layer2 selects FX.25 (the HDLC frame is sent as data of a Reed-Solomon code word with a correlation tag) or IL2P (preamble 0x55, sync word, scrambled header and payload with Reed-Solomon parity, without NRZI) instead of standard AX.25.

Member Enumeration Documentation

◆ KissState

enum class tinymodem::AX25Encoder::KissState
strongprotected
Enumerator
IDLE 
COMMAND 
DATA 
ESCAPE 

Constructor & Destructor Documentation

◆ AX25Encoder() [1/2]

tinymodem::AX25Encoder::AX25Encoder ( )
default

◆ AX25Encoder() [2/2]

tinymodem::AX25Encoder::AX25Encoder ( Print & out)
inline

Member Function Documentation

◆ addKiss()

void tinymodem::AX25Encoder::addKiss ( uint8_t ch)
inlineprotected

◆ audioInfo()

audio_tools::AudioInfo tinymodem::AX25Encoder::audioInfo ( )
inlineoverride

◆ begin() [1/2]

bool tinymodem::AX25Encoder::begin ( )
inlineoverride

◆ begin() [2/2]

bool tinymodem::AX25Encoder::begin ( AX25Config config)
inline

Starts the processing with the indicated configuration.

◆ config()

AX25Config & tinymodem::AX25Encoder::config ( )
inline

The configuration which was provided in begin().

◆ defaultConfig()

AX25Config tinymodem::AX25Encoder::defaultConfig ( )
inline

Provides a default configuration: APRS (1200 baud AFSK).

◆ end()

void tinymodem::AX25Encoder::end ( )
inlineoverride

◆ endTransmission()

bool tinymodem::AX25Encoder::endTransmission ( size_t silence_samples = 0)
inlineoverridevirtual

Sends the tail flags (and optional silence): returns true if a transmission was ended.

Implements tinymodem::ModemEncoder.

◆ frameCount()

size_t tinymodem::AX25Encoder::frameCount ( )
inline

Number of sent frames.

◆ isTransmitting()

bool tinymodem::AX25Encoder::isTransmitting ( )
inlineoverridevirtual

true between the first frame and endTransmission()

Implements tinymodem::ModemEncoder.

◆ operator bool()

tinymodem::AX25Encoder::operator bool ( )
inlineoverride

◆ sendBit()

void tinymodem::AX25Encoder::sendBit ( int bit)
inlineprotected

NRZI: a 0 changes the tone, a 1 keeps it.

◆ sendBits()

void tinymodem::AX25Encoder::sendBits ( uint8_t value)
inlineprotected

least significant bit first without bit stuffing (NRZI)

◆ sendByte()

void tinymodem::AX25Encoder::sendByte ( uint8_t value)
inlineprotected

least significant bit first with bit stuffing

◆ sendFlag()

void tinymodem::AX25Encoder::sendFlag ( )
inlineprotected

0x7E without bit stuffing

◆ sendPreamble()

void tinymodem::AX25Encoder::sendPreamble ( int ms)
inlineprotected

Flags (IL2P: 0x55) for the indicated time.

◆ sendRawByte()

void tinymodem::AX25Encoder::sendRawByte ( uint8_t value)
inlineprotected

most significant bit first without NRZI: 1 = mark

◆ sendTone()

void tinymodem::AX25Encoder::sendTone ( )
inlineprotected

sends the current tone for one bit

◆ setAudioInfo()

void tinymodem::AX25Encoder::setAudioInfo ( audio_tools::AudioInfo info)
inlineoverride

Defines the sample rate and number of channels of the generated audio.

◆ startTransmission()

void tinymodem::AX25Encoder::startTransmission ( )
inlineprotected

◆ symbolRate()

float tinymodem::AX25Encoder::symbolRate ( )
inlineoverridevirtual

Bits per second.

Implements tinymodem::ModemEncoder.

◆ write()

size_t tinymodem::AX25Encoder::write ( const uint8_t * data,
size_t len )
inlineoverride

Provide the frames as text lines or KISS frames.

◆ writeFrame()

bool tinymodem::AX25Encoder::writeFrame ( const uint8_t * frame,
size_t len )
inline

Sends a frame (without FCS).

◆ writeFX25()

bool tinymodem::AX25Encoder::writeFX25 ( const uint8_t * frame,
size_t len )
inlineprotected

FX.25: correlation tag and Reed-Solomon code word (NRZI, no stuffing).

◆ writeIdle()

bool tinymodem::AX25Encoder::writeIdle ( size_t nsamples)
inlineoverridevirtual

Sends flags for the indicated number of samples.

Reimplemented from tinymodem::ModemEncoder.

◆ writeIL2P()

bool tinymodem::AX25Encoder::writeIL2P ( const uint8_t * frame,
size_t len )
inlineprotected

IL2P: preamble, sync word and the encoded frame (no NRZI).

◆ writeKiss()

void tinymodem::AX25Encoder::writeKiss ( uint8_t ch)
inlineprotected

◆ writeText()

void tinymodem::AX25Encoder::writeText ( uint8_t ch)
inlineprotected

Member Data Documentation

◆ bit_index

uint64_t tinymodem::AX25Encoder::bit_index = 0
protected

◆ cfg

AX25Config tinymodem::AX25Encoder::cfg
protected

◆ frame

uint8_t tinymodem::AX25Encoder::frame[AX25Frame::MAX_FRAME]
protected

◆ frames

size_t tinymodem::AX25Encoder::frames = 0
protected

◆ input

char tinymodem::AX25Encoder::input[AX25Frame::MAX_FRAME+100]
protected

◆ input_len

int tinymodem::AX25Encoder::input_len = 0
protected

◆ is_active

bool tinymodem::AX25Encoder::is_active = false
protected

◆ kiss_data_frame

bool tinymodem::AX25Encoder::kiss_data_frame = false
protected

◆ kiss_state

KissState tinymodem::AX25Encoder::kiss_state = KissState::IDLE
protected

◆ nrzi_tone

bool tinymodem::AX25Encoder::nrzi_tone = true
protected

◆ ones

int tinymodem::AX25Encoder::ones = 0
protected

◆ samples_per_bit

double tinymodem::AX25Encoder::samples_per_bit = 40
protected

◆ transmitting

bool tinymodem::AX25Encoder::transmitting = false
protected

The documentation for this class was generated from the following file: