spandsp  0.0.6
adsi.c File Reference
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "spandsp/stdbool.h"
#include "floating_fudge.h"
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/fast_convert.h"
#include "spandsp/logging.h"
#include "spandsp/queue.h"
#include "spandsp/complex.h"
#include "spandsp/dds.h"
#include "spandsp/power_meter.h"
#include "spandsp/async.h"
#include "spandsp/crc.h"
#include "spandsp/fsk.h"
#include "spandsp/tone_detect.h"
#include "spandsp/tone_generate.h"
#include "spandsp/super_tone_rx.h"
#include "spandsp/dtmf.h"
#include "spandsp/adsi.h"
#include "spandsp/private/logging.h"
#include "spandsp/private/queue.h"
#include "spandsp/private/tone_generate.h"
#include "spandsp/private/async.h"
#include "spandsp/private/fsk.h"
#include "spandsp/private/dtmf.h"
#include "spandsp/private/adsi.h"

Macros

#define BAUDOT_FIGURE_SHIFT   0x1B
 
#define BAUDOT_LETTER_SHIFT   0x1F
 

Enumerations

enum  {
  SOH = 0x01, STX = 0x02, ETX = 0x03, DLE = 0x10,
  SUB = 0x1A
}
 

Functions

int adsi_rx (adsi_rx_state_t *s, const int16_t amp[], int len)
 Receive a chunk of ADSI audio. More...
 
logging_state_tadsi_rx_get_logging_state (adsi_rx_state_t *s)
 Get the logging context associated with an ADSI receive context. More...
 
adsi_rx_state_tadsi_rx_init (adsi_rx_state_t *s, int standard, put_msg_func_t put_msg, void *user_data)
 Initialise an ADSI receive context. More...
 
int adsi_rx_release (adsi_rx_state_t *s)
 Release an ADSI receive context. More...
 
int adsi_rx_free (adsi_rx_state_t *s)
 Free the resources of an ADSI receive context. More...
 
int adsi_tx (adsi_tx_state_t *s, int16_t amp[], int max_len)
 Generate a block of ADSI audio samples. More...
 
void adsi_tx_send_alert_tone (adsi_tx_state_t *s)
 Request generation of an ADSI alert tone. More...
 
void adsi_tx_set_preamble (adsi_tx_state_t *s, int preamble_len, int preamble_ones_len, int postamble_ones_len, int stop_bits)
 Adjust the preamble associated with an ADSI transmit context. More...
 
int adsi_tx_put_message (adsi_tx_state_t *s, const uint8_t *msg, int len)
 Put a message into the input buffer of an ADSI transmit context. More...
 
logging_state_tadsi_tx_get_logging_state (adsi_tx_state_t *s)
 
adsi_tx_state_tadsi_tx_init (adsi_tx_state_t *s, int standard)
 Initialise an ADSI transmit context. More...
 
int adsi_tx_release (adsi_tx_state_t *s)
 Release an ADSI transmit context. More...
 
int adsi_tx_free (adsi_tx_state_t *s)
 Free the resources of an ADSI transmit context. More...
 
int adsi_next_field (adsi_rx_state_t *s, const uint8_t *msg, int msg_len, int pos, uint8_t *field_type, uint8_t const **field_body, int *field_len)
 Get a field from an ADSI message. More...
 
int adsi_add_field (adsi_tx_state_t *s, uint8_t *msg, int len, uint8_t field_type, uint8_t const *field_body, int field_len)
 Insert the header or a field into an ADSI message. More...
 
const char * adsi_standard_to_str (int standard)
 Return a short name for an ADSI standard. More...
 

Macro Definition Documentation

◆ BAUDOT_FIGURE_SHIFT

#define BAUDOT_FIGURE_SHIFT   0x1B

The baudot code to shift from alpha to digits and symbols

◆ BAUDOT_LETTER_SHIFT

#define BAUDOT_LETTER_SHIFT   0x1F

The baudot code to shift from digits and symbols to alpha

Function Documentation

◆ adsi_add_field()

int adsi_add_field ( adsi_tx_state_t s,
uint8_t *  msg,
int  len,
uint8_t  field_type,
uint8_t const *  field_body,
int  field_len 
)

Insert the header or a field into an ADSI message.

Parameters
sThe ADSI transmit context.
msgThe message buffer.
lenThe current length of the message.
field_typeThe type code for the new field.
field_bodyPointer to the body of the new field.
field_lenThe length of the new field.

◆ adsi_next_field()

int adsi_next_field ( adsi_rx_state_t s,
const uint8_t *  msg,
int  msg_len,
int  pos,
uint8_t *  field_type,
uint8_t const **  field_body,
int *  field_len 
)

Get a field from an ADSI message.

Parameters
sThe ADSI receive context.
msgThe message buffer.
msg_lenThe length of the message.
posCurrent position within the message. Set to -1 when starting a message.
field_typeThe type code for the field.
field_bodyPointer to the body of the field.
field_lenThe length of the field, or -1 for no more fields, or -2 for message structure corrupt.

◆ adsi_rx()

int adsi_rx ( adsi_rx_state_t s,
const int16_t  amp[],
int  len 
)

Receive a chunk of ADSI audio.

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

◆ adsi_rx_free()

int adsi_rx_free ( adsi_rx_state_t s)

Free the resources of an ADSI receive context.

Parameters
sThe ADSI receive context.
Returns
0 for OK.

◆ adsi_rx_get_logging_state()

logging_state_t* adsi_rx_get_logging_state ( adsi_rx_state_t s)

Get the logging context associated with an ADSI receive context.

Get the logging context associated with an ADSI receive context.

Parameters
sThe ADSI receive context.
Returns
A pointer to the logging context

◆ adsi_rx_init()

adsi_rx_state_t* adsi_rx_init ( adsi_rx_state_t s,
int  standard,
put_msg_func_t  put_msg,
void *  user_data 
)

Initialise an ADSI receive context.

Parameters
sThe ADSI receive context.
standardThe code for the ADSI standard to be used.
put_msgA callback routine called to deliver the received messages to the application.
user_dataAn opaque pointer for the callback routine.
Returns
A pointer to the initialised context, or NULL if there was a problem.

◆ adsi_rx_release()

int adsi_rx_release ( adsi_rx_state_t s)

Release an ADSI receive context.

Parameters
sThe ADSI receive context.
Returns
0 for OK.

◆ adsi_standard_to_str()

const char* adsi_standard_to_str ( int  standard)

Return a short name for an ADSI standard.

Parameters
standardThe code for the standard.
Returns
A pointer to the name.

◆ adsi_tx()

int adsi_tx ( adsi_tx_state_t s,
int16_t  amp[],
int  max_len 
)

Generate a block of ADSI audio samples.

Parameters
sThe ADSI transmit context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated.

◆ adsi_tx_free()

int adsi_tx_free ( adsi_tx_state_t s)

Free the resources of an ADSI transmit context.

Parameters
sThe ADSI transmit context.
Returns
0 for OK.

◆ adsi_tx_init()

adsi_tx_state_t* adsi_tx_init ( adsi_tx_state_t s,
int  standard 
)

Initialise an ADSI transmit context.

Parameters
sThe ADSI transmit context.
standardThe code for the ADSI standard to be used.
Returns
A pointer to the initialised context, or NULL if there was a problem.

◆ adsi_tx_put_message()

int adsi_tx_put_message ( adsi_tx_state_t s,
const uint8_t *  msg,
int  len 
)

Put a message into the input buffer of an ADSI transmit context.

Parameters
sThe ADSI transmit context.
msgThe message.
lenThe length of the message.
Returns
The length actually added. If a message is already in progress in the transmitter, this function will return zero, as it will not successfully add the message to the buffer. If the message is invalid (e.g. it is too long), this function will return -1.

◆ adsi_tx_release()

int adsi_tx_release ( adsi_tx_state_t s)

Release an ADSI transmit context.

Parameters
sThe ADSI transmit context.
Returns
0 for OK.

◆ adsi_tx_send_alert_tone()

void adsi_tx_send_alert_tone ( adsi_tx_state_t s)

Request generation of an ADSI alert tone.

Parameters
sThe ADSI transmit context.

◆ adsi_tx_set_preamble()

void adsi_tx_set_preamble ( adsi_tx_state_t s,
int  preamble_len,
int  preamble_ones_len,
int  postamble_ones_len,
int  stop_bits 
)

Adjust the preamble associated with an ADSI transmit context.

Parameters
sThe ADSI transmit context.
preamble_lenThe number of bits of preamble.
preamble_ones_lenThe number of bits of continuous one before a message.
postamble_ones_lenThe number of bits of continuous one after a message.
stop_bitsThe number of stop bits per character.