AmendHub

Download:

jcs

/

subtext

/

amendments

/

528

serial: Make number of rings before answering a configurable setting

Defaults to 1 as before, but can be increased to allow caller id
strings to come through the logger.

jcs made amendment 528 7 months ago
--- db.c Mon Aug 28 08:47:54 2023 +++ db.c Wed Nov 8 21:02:07 2023 @@ -77,6 +77,9 @@ struct struct_field config_fields[] = { { "Modem Init String", CONFIG_TYPE_STRING, offsetof(struct config, modem_init), 1, member_size(struct config, modem_init) }, + { "Modem Answer After Rings", CONFIG_TYPE_SHORT, + offsetof(struct config, modem_rings), + 1, 100 }, { "Max Idle Minutes", CONFIG_TYPE_SHORT, offsetof(struct config, max_idle_minutes), @@ -355,6 +358,7 @@ db_migrate(struct db *tdb, short is_new, Str255 fullpa tdb->config.modem_speed = 9600; sprintf(tdb->config.modem_init, "ATQ0V1S0=2&D2"); sprintf(tdb->config.modem_parity, "8N1"); + tdb->config.modem_rings = 1; tdb->config.max_idle_minutes = 5; tdb->config.max_sysop_idle_minutes = 60; tdb->config.max_login_seconds = 90; @@ -589,6 +593,19 @@ db_migrate(struct db *tdb, short is_new, Str255 fullpa bile_flush(sessions_bile, true); xfree(&ids); bile_close(sessions_bile); + break; + } + case 19: { + /* 19->20, modem rings */ + struct config new_config = { 0 }; + + bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config, + sizeof(new_config)); + + new_config.modem_rings = 1; + + bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config, + sizeof(new_config)); break; } } --- db.h Wed Jun 14 17:49:15 2023 +++ db.h Wed Nov 8 20:43:00 2023 @@ -19,7 +19,7 @@ #include <time.h> -#define DB_CUR_VERS 19 +#define DB_CUR_VERS 20 #define SUBTEXT_CREATOR 'SUBT' #define DB_TYPE 'STDB' @@ -105,6 +105,7 @@ struct config { unsigned long ftn_max_tossed_message_size; short max_sysop_idle_minutes; char ipdb_path[255]; + short modem_rings; }; extern struct struct_field config_fields[]; --- serial.c Sun Aug 27 21:35:23 2023 +++ serial.c Wed Nov 8 20:49:54 2023 @@ -62,6 +62,8 @@ static short serial_out_refnum = 0, serial_in_refnum = static char serial_input_internal_buf[1024]; static char serial_input_buf[128]; static size_t serial_input_buf_len = 0; +static short serial_rings = 0; +static unsigned long serial_last_ring = 0; static ParamBlockRec serial_write_pbr = { 0 }; enum { @@ -224,6 +226,8 @@ serial_init(void) the_serial_node.answered_at = 0; serial_input_buf_len = 0; + serial_rings = 0; + serial_last_ring = 0; } void @@ -444,6 +448,14 @@ serial_idle(void) return; if (strstr(line, "RING") != NULL) { + if (Time - serial_last_ring > 10) + serial_rings = 0; + + serial_last_ring = Time; + serial_rings++; + if (serial_rings < db->config.modem_rings) + break; + sprintf(tty, "ttym%d", (db->config.modem_port == 2 ? 1 : 0)); the_serial_node.session = session_create(tty, "modem", &serial_node_funcs); @@ -457,7 +469,8 @@ serial_idle(void) the_serial_node.state = SERIAL_STATE_ANSWERED; the_serial_node.answered_at = Time; - logger_printf("[modem] Answering call"); + logger_printf("[modem] Answering call after %d ring%s", + serial_rings, serial_rings == 1 ? "" : "s"); serial_printf("ATA\r"); } break;