spandsp  3.0.0
fsk.c File Reference
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include "spandsp/stdbool.h"
#include "floating_fudge.h"
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/complex.h"
#include "spandsp/dds.h"
#include "spandsp/power_meter.h"
#include "spandsp/bit_operations.h"
#include "spandsp/async.h"
#include "spandsp/fsk.h"
#include "spandsp/private/power_meter.h"
#include "spandsp/private/fsk.h"

Functions

int fsk_tx (fsk_tx_state_t *s, int16_t amp[], int len)
 Generate a block of FSK modem audio samples. More...
 
void fsk_tx_power (fsk_tx_state_t *s, float power)
 Adjust an FSK modem transmit context's power output. More...
 
void fsk_tx_set_get_bit (fsk_tx_state_t *s, span_get_bit_func_t get_bit, void *user_data)
 
void fsk_tx_set_modem_status_handler (fsk_tx_state_t *s, span_modem_status_func_t handler, void *user_data)
 Change the modem status report function associated with an FSK modem transmit context. More...
 
int fsk_tx_restart (fsk_tx_state_t *s, const fsk_spec_t *spec)
 
fsk_tx_state_tfsk_tx_init (fsk_tx_state_t *s, const fsk_spec_t *spec, span_get_bit_func_t get_bit, void *user_data)
 Initialise an FSK modem transmit context. More...
 
int fsk_tx_release (fsk_tx_state_t *s)
 
int fsk_tx_free (fsk_tx_state_t *s)
 
void fsk_rx_set_signal_cutoff (fsk_rx_state_t *s, float cutoff)
 Adjust an FSK modem receive context's carrier detect power threshold. More...
 
float fsk_rx_signal_power (fsk_rx_state_t *s)
 
void fsk_rx_set_put_bit (fsk_rx_state_t *s, span_put_bit_func_t put_bit, void *user_data)
 
void fsk_rx_set_modem_status_handler (fsk_rx_state_t *s, span_modem_status_func_t handler, void *user_data)
 Change the modem status report function associated with an FSK modem receive context. More...
 
void fsk_rx_set_frame_parameters (fsk_rx_state_t *s, int data_bits, int parity, int stop_bits)
 Set the framing parameters. More...
 
int fsk_rx_get_parity_errors (fsk_rx_state_t *s, bool reset)
 
int fsk_rx_get_framing_errors (fsk_rx_state_t *s, bool reset)
 
int fsk_rx (fsk_rx_state_t *s, const int16_t *amp, int len)
 Process a block of received FSK modem audio samples. More...
 
int fsk_rx_fillin (fsk_rx_state_t *s, int len)
 Fake processing of a missing block of received FSK modem audio samples. More...
 
int fsk_rx_restart (fsk_rx_state_t *s, const fsk_spec_t *spec, int framing_mode)
 
fsk_rx_state_tfsk_rx_init (fsk_rx_state_t *s, const fsk_spec_t *spec, int framing_mode, span_put_bit_func_t put_bit, void *user_data)
 Initialise an FSK modem receive context. More...
 
int fsk_rx_release (fsk_rx_state_t *s)
 
int fsk_rx_free (fsk_rx_state_t *s)
 

Variables

const fsk_spec_t preset_fsk_specs []
 

Function Documentation

◆ fsk_rx()

int fsk_rx ( fsk_rx_state_t s,
const int16_t *  amp,
int  len 
)

Process a block of received FSK modem audio samples.

Process a block of received FSK modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

◆ fsk_rx_fillin()

int fsk_rx_fillin ( fsk_rx_state_t s,
int  len 
)

Fake processing of a missing block of received FSK modem audio samples.

Fake processing of a missing block of received FSK modem audio samples (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

References dds_advance(), complexi32_t::im, and complexi32_t::re.

◆ fsk_rx_init()

fsk_rx_state_t* fsk_rx_init ( fsk_rx_state_t s,
const fsk_spec_t spec,
int  framing_mode,
span_put_bit_func_t  put_bit,
void *  user_data 
)

Initialise an FSK modem receive context.

Initialise an FSK modem receive context.

Parameters
sThe modem context.
specThe specification of the modem tones and rate.
framing_mode
put_bitThe callback routine used to put the received data.
user_dataAn opaque pointer.
Returns
A pointer to the modem context, or NULL if there was a problem.

◆ fsk_rx_set_frame_parameters()

void fsk_rx_set_frame_parameters ( fsk_rx_state_t s,
int  data_bits,
int  parity,
int  stop_bits 
)

Set the framing parameters.

Set the framing parameters for a an FSK modem receive context in FSK_FRAME_MODE_FRAMED mode.

Parameters
sThe modem context.
data_bits;
parity;
stop_bits;

References fsk_rx_state_s::framing_mode.

◆ fsk_rx_set_modem_status_handler()

void fsk_rx_set_modem_status_handler ( fsk_rx_state_t s,
span_modem_status_func_t  handler,
void *  user_data 
)

Change the modem status report function associated with an FSK modem receive context.

Change the modem status report function associated with an FSK modem receive context.

Parameters
sThe modem context.
handlerThe callback routine used to report modem status changes.
user_dataAn opaque pointer.

References fsk_rx_state_s::status_handler, and fsk_rx_state_s::status_user_data.

◆ fsk_rx_set_signal_cutoff()

void fsk_rx_set_signal_cutoff ( fsk_rx_state_t s,
float  cutoff 
)

Adjust an FSK modem receive context's carrier detect power threshold.

Adjust an FSK modem receive context's carrier detect power threshold.

Parameters
sThe modem context.
cutoffThe power level, in dBm0

References power_meter_level_dbm0().

◆ fsk_rx_signal_power()

float fsk_rx_signal_power ( fsk_rx_state_t s)

Get the current received signal power.

Parameters
sThe modem context.
Returns
The signal power, in dBm0.

References power_meter_current_dbm0().

◆ fsk_tx()

int fsk_tx ( fsk_tx_state_t s,
int16_t  amp[],
int  len 
)

Generate a block of FSK modem audio samples.

Generate a block of FSK modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples to be generated.
Returns
The number of samples actually generated.

◆ fsk_tx_init()

fsk_tx_state_t* fsk_tx_init ( fsk_tx_state_t s,
const fsk_spec_t spec,
span_get_bit_func_t  get_bit,
void *  user_data 
)

Initialise an FSK modem transmit context.

Initialise an FSK modem transmit context.

Parameters
sThe modem context.
specThe specification of the modem tones and rate.
get_bitThe callback routine used to get the data to be transmitted.
user_dataAn opaque pointer.
Returns
A pointer to the modem context, or NULL if there was a problem.

◆ fsk_tx_power()

void fsk_tx_power ( fsk_tx_state_t s,
float  power 
)

Adjust an FSK modem transmit context's power output.

Adjust an FSK modem transmit context's power output.

Parameters
sThe modem context.
powerThe power level, in dBm0

◆ fsk_tx_set_modem_status_handler()

void fsk_tx_set_modem_status_handler ( fsk_tx_state_t s,
span_modem_status_func_t  handler,
void *  user_data 
)

Change the modem status report function associated with an FSK modem transmit context.

Change the modem status report function associated with an FSK modem transmit context.

Parameters
sThe modem context.
handlerThe callback routine used to report modem status changes.
user_dataAn opaque pointer.

References fsk_tx_state_s::status_handler, and fsk_tx_state_s::status_user_data.