net_modem.c: Make sure the CONNECT response gets through

This commit is contained in:
Cacodemon345 2024-03-14 01:10:29 +06:00
parent bd6eb8e869
commit 7c9e94fb9b

View file

@ -112,6 +112,7 @@ typedef struct modem_t
bool connected, ringing;
bool echo, numericresponse;
bool tcpIpMode, tcpIpConnInProgress;
bool cooldown;
bool telnet_mode;
bool dtrstate;
uint32_t tcpIpConnCounter;
@ -369,13 +370,17 @@ host_to_modem_cb(void *priv)
if (!((modem->serial->mctrl & 2) || modem->flowcontrol != 3))
goto no_write_to_machine;
if (modem->mode == MODEM_MODE_DATA && fifo8_num_used(&modem->rx_data)) {
if (modem->mode == MODEM_MODE_DATA && fifo8_num_used(&modem->rx_data) && !modem->cooldown) {
serial_write_fifo(modem->serial, fifo8_pop(&modem->rx_data));
} else if (fifo8_num_used(&modem->data_pending)) {
uint8_t val = fifo8_pop(&modem->data_pending);
serial_write_fifo(modem->serial, val);
}
if (fifo8_num_used(&modem->data_pending) == 0) {
modem->cooldown = false;
}
no_write_to_machine:
timer_on_auto(&modem->host_to_serial_timer, (1000000.0 / (double)modem->baudrate) * (double)9);
}
@ -524,6 +529,7 @@ modem_enter_connected_state(modem_t* modem)
modem->ringing = false;
modem->connected = true;
modem->tcpIpMode = true;
modem->cooldown = true;
plat_netsocket_close(modem->serversocket);
modem->serversocket = -1;
memset(&modem->telClient, 0, sizeof(modem->telClient));