#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "floating_fudge.h"
#include <assert.h>
#include "spandsp/telephony.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"
Defines | |
#define | BAUDOT_FIGURE_SHIFT 0x1B |
#define | BAUDOT_LETTER_SHIFT 0x1F |
#define | SOH 0x01 |
#define | STX 0x02 |
#define | ETX 0x03 |
#define | DLE 0x10 |
#define | SUB 0x1A |
Functions | |
int | adsi_rx (adsi_rx_state_t *s, const int16_t *amp, int len) |
Receive a chunk of ADSI audio. | |
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. | |
int | adsi_tx (adsi_tx_state_t *s, int16_t *amp, int max_len) |
Generate a block of ADSI audio samples. | |
void | adsi_tx_send_alert_tone (adsi_tx_state_t *s) |
Request generation of an ADSI alert tone. | |
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. | |
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. | |
adsi_tx_state_t * | adsi_tx_init (adsi_tx_state_t *s, int standard) |
Initialise an ADSI transmit context. | |
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. | |
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. | |
const char * | adsi_standard_to_str (int standard) |
Return a short name for an ADSI standard. |
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.
s | The ADSI transmit context. | |
msg | The message buffer. | |
len | The current length of the message. | |
field_type | The type code for the new field. | |
field_body | Pointer to the body of the new field. | |
field_len | The length of the new field. |
References CLIP_DTMF_HASH_UNSPECIFIED, and adsi_tx_state_t::standard.
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.
s | The ADSI receive context. | |
msg | The message buffer. | |
msg_len | The length of the message. | |
pos | Current position within the message. Set to -1 when starting a message. | |
field_type | The type code for the field. | |
field_body | Pointer to the body of the field. | |
field_len | The length of the field, or -1 for no more fields, or -2 for message structure corrupt. |
References CLIP_DTMF_HASH_UNSPECIFIED, and adsi_rx_state_t::standard.
int adsi_rx | ( | adsi_rx_state_t * | s, | |
const int16_t * | amp, | |||
int | len | |||
) |
Receive a chunk of ADSI audio.
s | The ADSI receive context. | |
amp | The audio sample buffer. | |
len | The number of samples in the buffer. |
References adsi_rx_state_t::dtmfrx, fsk_rx(), adsi_rx_state_t::fskrx, adsi_rx_state_t::in_progress, adsi_rx_state_t::msg_len, and adsi_rx_state_t::standard.
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.
s | The ADSI receive context. | |
standard | The code for the ADSI standard to be used. | |
put_msg | A callback routine called to deliver the received messages to the application. | |
user_data | An opaque pointer for the callback routine. |
References ASYNC_PARITY_NONE, async_rx_init(), async_rx_put_bit(), adsi_rx_state_t::asyncrx, adsi_rx_state_t::dtmfrx, fsk_rx_init(), adsi_rx_state_t::fskrx, adsi_rx_state_t::logging, adsi_rx_state_t::put_msg, adsi_rx_state_t::standard, and adsi_rx_state_t::user_data.
const char* adsi_standard_to_str | ( | int | standard | ) |
Return a short name for an ADSI standard.
standard | The code for the standard. |
int adsi_tx | ( | adsi_tx_state_t * | s, | |
int16_t * | amp, | |||
int | max_len | |||
) |
Generate a block of ADSI audio samples.
s | The ADSI transmit context. | |
amp | The audio sample buffer. | |
max_len | The number of samples to be generated. |
References adsi_tx_state_t::alert_tone_gen, adsi_tx_state_t::dtmftx, fsk_tx(), adsi_tx_state_t::fsktx, adsi_tx_state_t::standard, and adsi_tx_state_t::tx_signal_on.
adsi_tx_state_t* adsi_tx_init | ( | adsi_tx_state_t * | s, | |
int | standard | |||
) |
Initialise an ADSI transmit context.
s | The ADSI transmit context. | |
standard | The code for the ADSI standard to be used. |
References adsi_tx_set_preamble(), adsi_tx_state_t::alert_tone_desc, adsi_tx_state_t::logging, make_tone_gen_descriptor(), and adsi_tx_state_t::standard.
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.
s | The ADSI transmit context. | |
msg | The message. | |
len | The length of the message. |
References adsi_tx_state_t::bit_no, adsi_tx_state_t::bit_pos, adsi_tx_state_t::byte_no, crc_itu16_calc(), adsi_tx_state_t::dtmftx, adsi_tx_state_t::msg, adsi_tx_state_t::msg_len, adsi_tx_state_t::standard, and adsi_tx_state_t::tx_signal_on.
void adsi_tx_send_alert_tone | ( | adsi_tx_state_t * | s | ) |
Request generation of an ADSI alert tone.
s | The ADSI transmit context. |
References adsi_tx_state_t::alert_tone_desc, and adsi_tx_state_t::alert_tone_gen.
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.
s | The ADSI transmit context. | |
preamble_len | The number of bits of preamble. | |
preamble_ones_len | The number of bits of continuous one before a message. | |
postamble_ones_len | The number of bits of continuous one after a message. | |
stop_bits | The number of stop bits per character. |
References adsi_tx_state_t::postamble_ones_len, adsi_tx_state_t::preamble_len, adsi_tx_state_t::preamble_ones_len, adsi_tx_state_t::standard, and adsi_tx_state_t::stop_bits.
Referenced by adsi_tx_init().