mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 09:58:17 +00:00
Removal of some pointless callback parameters in the spandsp AT command
interpreter, and fixes for my congential inability to reliably spell psuedo, er, pseudo, er, whatever.
This commit is contained in:
@@ -504,7 +504,7 @@ SPAN_DECLARE(int) decode_msg(ademco_contactid_report_t *report, const char buf[]
|
||||
int x;
|
||||
char buf2[20];
|
||||
|
||||
/* We need to remap normal DTMF (0-0, *, #, A-D) to Ademco's psuedo-hex (0-0, B-F, nothing for A)
|
||||
/* We need to remap normal DTMF (0-0, *, #, A-D) to Ademco's pseudo-hex (0-0, B-F, nothing for A)
|
||||
and calculate the checksum */
|
||||
for (sum = 0, s = buf, t = buf2; *s; s++, t++)
|
||||
{
|
||||
|
@@ -222,9 +222,9 @@ SPAN_DECLARE(void) at_put_response(at_state_t *s, const char *t)
|
||||
buf[1] = s->p.s_regs[4];
|
||||
buf[2] = '\0';
|
||||
if (s->p.result_code_format == ASCII_RESULT_CODES)
|
||||
s->at_tx_handler(s, s->at_tx_user_data, buf, 2);
|
||||
s->at_tx_handler(s, s->at_tx_user_data, (uint8_t *) t, strlen(t));
|
||||
s->at_tx_handler(s, s->at_tx_user_data, buf, 2);
|
||||
s->at_tx_handler(s->at_tx_user_data, buf, 2);
|
||||
s->at_tx_handler(s->at_tx_user_data, (uint8_t *) t, strlen(t));
|
||||
s->at_tx_handler(s->at_tx_user_data, buf, 2);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -249,7 +249,7 @@ SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code)
|
||||
break;
|
||||
case NUMERIC_RESULT_CODES:
|
||||
snprintf((char *) buf, sizeof(buf), "%d%c", code, s->p.s_regs[3]);
|
||||
s->at_tx_handler(s, s->at_tx_user_data, buf, strlen((char *) buf));
|
||||
s->at_tx_handler(s->at_tx_user_data, buf, strlen((char *) buf));
|
||||
break;
|
||||
default:
|
||||
/* No result codes */
|
||||
@@ -361,7 +361,7 @@ SPAN_DECLARE(void) at_call_event(at_state_t *s, int event)
|
||||
{
|
||||
s->rx_data[s->rx_data_bytes++] = DLE;
|
||||
s->rx_data[s->rx_data_bytes++] = ETX;
|
||||
s->at_tx_handler(s, s->at_tx_user_data, s->rx_data, s->rx_data_bytes);
|
||||
s->at_tx_handler(s->at_tx_user_data, s->rx_data, s->rx_data_bytes);
|
||||
s->rx_data_bytes = 0;
|
||||
}
|
||||
if (s->at_rx_mode != AT_MODE_OFFHOOK_COMMAND && s->at_rx_mode != AT_MODE_ONHOOK_COMMAND)
|
||||
@@ -881,7 +881,7 @@ static int process_class1_cmd(at_state_t *s, const char **t)
|
||||
|
||||
result = true;
|
||||
if (s->class1_handler)
|
||||
result = s->class1_handler(s, s->class1_user_data, direction, operation, val);
|
||||
result = s->class1_handler(s->class1_user_data, direction, operation, val);
|
||||
switch (result)
|
||||
{
|
||||
case 0:
|
||||
@@ -5461,7 +5461,7 @@ SPAN_DECLARE(int) at_modem_control(at_state_t *s, int op, const char *num)
|
||||
break;
|
||||
}
|
||||
/*endswitch*/
|
||||
return s->modem_control_handler(s, s->modem_control_user_data, op, num);
|
||||
return s->modem_control_handler(s->modem_control_user_data, op, num);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -5474,7 +5474,7 @@ SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len)
|
||||
const char *t;
|
||||
|
||||
if (s->p.echo)
|
||||
s->at_tx_handler(s, s->at_tx_user_data, (uint8_t *) cmd, len);
|
||||
s->at_tx_handler(s->at_tx_user_data, (uint8_t *) cmd, len);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
@@ -5582,6 +5582,15 @@ SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t hand
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(void) at_set_modem_control_handler(at_state_t *s,
|
||||
at_modem_control_handler_t modem_control_handler,
|
||||
void *modem_control_user_data)
|
||||
{
|
||||
s->modem_control_handler = modem_control_handler;
|
||||
s->modem_control_user_data = modem_control_user_data;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(logging_state_t *) at_get_logging_state(at_state_t *s)
|
||||
{
|
||||
return &s->logging;
|
||||
|
@@ -38,9 +38,9 @@ modem control commands.
|
||||
|
||||
typedef struct at_state_s at_state_t;
|
||||
|
||||
typedef int (*at_modem_control_handler_t)(at_state_t *s, void *user_data, int op, const char *num);
|
||||
typedef int (*at_tx_handler_t)(at_state_t *s, void *user_data, const uint8_t *buf, size_t len);
|
||||
typedef int (*at_class1_handler_t)(at_state_t *s, void *user_data, int direction, int operation, int val);
|
||||
typedef int (*at_modem_control_handler_t)(void *user_data, int op, const char *num);
|
||||
typedef int (*at_tx_handler_t)(void *user_data, const uint8_t *buf, size_t len);
|
||||
typedef int (*at_class1_handler_t)(void *user_data, int direction, int operation, int val);
|
||||
|
||||
enum at_rx_mode_e
|
||||
{
|
||||
@@ -173,6 +173,11 @@ SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t hand
|
||||
\return A pointer to the logging context */
|
||||
SPAN_DECLARE(logging_state_t *) at_get_logging_state(at_state_t *s);
|
||||
|
||||
|
||||
SPAN_DECLARE(void) at_set_modem_control_handler(at_state_t *s,
|
||||
at_modem_control_handler_t modem_control_handler,
|
||||
void *modem_control_user_data);
|
||||
|
||||
/*! Initialise an AT interpreter context.
|
||||
\brief Initialise an AT interpreter context.
|
||||
\param s The AT context.
|
||||
|
@@ -1358,55 +1358,54 @@ SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int t31_modem_control_handler(at_state_t *s, void *user_data, int op, const char *num)
|
||||
static int t31_modem_control_handler(void *user_data, int op, const char *num)
|
||||
{
|
||||
t31_state_t *t;
|
||||
t31_state_t *s;
|
||||
|
||||
t = (t31_state_t *) user_data;
|
||||
s = (t31_state_t *) user_data;
|
||||
switch (op)
|
||||
{
|
||||
case AT_MODEM_CONTROL_CALL:
|
||||
t->call_samples = 0;
|
||||
t38_core_restart(&t->t38_fe.t38);
|
||||
s->call_samples = 0;
|
||||
t38_core_restart(&s->t38_fe.t38);
|
||||
break;
|
||||
case AT_MODEM_CONTROL_ANSWER:
|
||||
t->call_samples = 0;
|
||||
t38_core_restart(&t->t38_fe.t38);
|
||||
s->call_samples = 0;
|
||||
t38_core_restart(&s->t38_fe.t38);
|
||||
break;
|
||||
case AT_MODEM_CONTROL_ONHOOK:
|
||||
if (t->non_ecm_tx.holding)
|
||||
if (s->non_ecm_tx.holding)
|
||||
{
|
||||
t->non_ecm_tx.holding = false;
|
||||
s->non_ecm_tx.holding = false;
|
||||
/* Tell the application to release further data */
|
||||
at_modem_control(&t->at_state, AT_MODEM_CONTROL_CTS, (void *) 1);
|
||||
at_modem_control(&s->at_state, AT_MODEM_CONTROL_CTS, (void *) 1);
|
||||
}
|
||||
/*endif*/
|
||||
if (t->at_state.rx_signal_present)
|
||||
if (s->at_state.rx_signal_present)
|
||||
{
|
||||
t->at_state.rx_data[t->at_state.rx_data_bytes++] = DLE;
|
||||
t->at_state.rx_data[t->at_state.rx_data_bytes++] = ETX;
|
||||
t->at_state.at_tx_handler(&t->at_state,
|
||||
t->at_state.at_tx_user_data,
|
||||
t->at_state.rx_data,
|
||||
t->at_state.rx_data_bytes);
|
||||
t->at_state.rx_data_bytes = 0;
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE;
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX;
|
||||
s->at_state.at_tx_handler(s->at_state.at_tx_user_data,
|
||||
s->at_state.rx_data,
|
||||
s->at_state.rx_data_bytes);
|
||||
s->at_state.rx_data_bytes = 0;
|
||||
}
|
||||
/*endif*/
|
||||
restart_modem(t, FAX_MODEM_SILENCE_TX);
|
||||
restart_modem(s, FAX_MODEM_SILENCE_TX);
|
||||
break;
|
||||
case AT_MODEM_CONTROL_RESTART:
|
||||
restart_modem(t, (int) (intptr_t) num);
|
||||
restart_modem(s, (int) (intptr_t) num);
|
||||
return 0;
|
||||
case AT_MODEM_CONTROL_DTE_TIMEOUT:
|
||||
if (num)
|
||||
t->dte_data_timeout = t->call_samples + ms_to_samples((intptr_t) num);
|
||||
s->dte_data_timeout = s->call_samples + ms_to_samples((intptr_t) num);
|
||||
else
|
||||
t->dte_data_timeout = 0;
|
||||
s->dte_data_timeout = 0;
|
||||
/*endif*/
|
||||
return 0;
|
||||
}
|
||||
/*endswitch*/
|
||||
return t->modem_control_handler(t, t->modem_control_user_data, op, num);
|
||||
return s->modem_control_handler(s, s->modem_control_user_data, op, num);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -1437,8 +1436,7 @@ static void non_ecm_rx_status(void *user_data, int status)
|
||||
{
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE;
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX;
|
||||
s->at_state.at_tx_handler(&s->at_state,
|
||||
s->at_state.at_tx_user_data,
|
||||
s->at_state.at_tx_handler(s->at_state.at_tx_user_data,
|
||||
s->at_state.rx_data,
|
||||
s->at_state.rx_data_bytes);
|
||||
s->at_state.rx_data_bytes = 0;
|
||||
@@ -1480,8 +1478,7 @@ static void non_ecm_put_bit(void *user_data, int bit)
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = (uint8_t) s->audio.current_byte;
|
||||
if (s->at_state.rx_data_bytes >= 250)
|
||||
{
|
||||
s->at_state.at_tx_handler(&s->at_state,
|
||||
s->at_state.at_tx_user_data,
|
||||
s->at_state.at_tx_handler(s->at_state.at_tx_user_data,
|
||||
s->at_state.rx_data,
|
||||
s->at_state.rx_data_bytes);
|
||||
s->at_state.rx_data_bytes = 0;
|
||||
@@ -1515,8 +1512,7 @@ static void non_ecm_put(void *user_data, const uint8_t buf[], int len)
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = buf[i];
|
||||
if (s->at_state.rx_data_bytes >= 250)
|
||||
{
|
||||
s->at_state.at_tx_handler(&s->at_state,
|
||||
s->at_state.at_tx_user_data,
|
||||
s->at_state.at_tx_handler(s->at_state.at_tx_user_data,
|
||||
s->at_state.rx_data,
|
||||
s->at_state.rx_data_bytes);
|
||||
s->at_state.rx_data_bytes = 0;
|
||||
@@ -1860,7 +1856,7 @@ static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int
|
||||
/*endfor*/
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE;
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX;
|
||||
s->at_state.at_tx_handler(&s->at_state, s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes);
|
||||
s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes);
|
||||
s->at_state.rx_data_bytes = 0;
|
||||
if (msg[1] == 0x13 && ok)
|
||||
{
|
||||
@@ -2025,8 +2021,8 @@ static void t31_v21_rx(t31_state_t *s)
|
||||
s->hdlc_tx.len = 0;
|
||||
s->hdlc_tx.final = false;
|
||||
s->dled = false;
|
||||
hdlc_rx_init(&s->audio.modems.hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept_frame, s);
|
||||
fax_modems_start_slow_modem(&s->audio.modems, FAX_MODEM_V21_RX);
|
||||
hdlc_rx_init(&s->audio.modems.hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept_frame, s);
|
||||
s->at_state.transmit = true;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@@ -2447,7 +2443,7 @@ static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int operation, int val)
|
||||
static int process_class1_cmd(void *user_data, int direction, int operation, int val)
|
||||
{
|
||||
int new_modem;
|
||||
int new_transmit;
|
||||
@@ -2549,7 +2545,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int
|
||||
/*endfor*/
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE;
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX;
|
||||
s->at_state.at_tx_handler(&s->at_state, s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes);
|
||||
s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes);
|
||||
s->at_state.rx_data_bytes = 0;
|
||||
}
|
||||
/*endif*/
|
||||
@@ -2710,7 +2706,7 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len)
|
||||
{
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE;
|
||||
s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX;
|
||||
s->at_state.at_tx_handler(&s->at_state, s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes);
|
||||
s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes);
|
||||
}
|
||||
/*endif*/
|
||||
s->at_state.rx_data_bytes = 0;
|
||||
@@ -2983,6 +2979,7 @@ static int t31_t38_fe_init(t31_state_t *t,
|
||||
|
||||
t->hdlc_tx.ptr = 0;
|
||||
|
||||
/* Prepare the non-ecm HDLC bit stream -> T.38 HDLC -> non-ecm HDLC bit stream path */
|
||||
hdlc_tx_init(&s->hdlc_tx_non_ecm, false, 1, false, hdlc_tx_underflow2, s);
|
||||
hdlc_rx_init(&s->hdlc_rx_non_ecm, false, true, 2, hdlc_accept_non_ecm_frame, t);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user