aboutsummaryrefslogtreecommitdiff
path: root/src/modem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modem.c')
-rw-r--r--src/modem.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/modem.c b/src/modem.c
index ab95593..d8b09fc 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -193,3 +193,33 @@ int modem_run(int fd, int argc, char* argv[])
close(fd); //Auto closes connection
return 0;
}
+
+void dialup_server(struct prog_params params)
+{
+ printf("Starting dialup server\n");
+
+ while(1) {
+ //Serial port is reopened for every new connection to reset modem over DTR
+ int fd = open (params.serial_port, O_RDWR | O_NOCTTY | O_SYNC);
+ if (fd < 0) {
+ LOGPRINTF(_LOG_ERROR, "Failed to open serial port");
+ return;
+ }
+
+ set_interface_attribs (fd, params.serial_baudrate, 0);
+ set_blocking (fd, 0);
+
+ int ret = modem_accept_wait(fd);
+
+ if(ret) {
+ LOGPRINTF(_LOG_NOTE, "Connection not established: %i", ret);
+ close(fd);
+ break;
+ }
+
+ LOGPRINTF(_LOG_NOTE,"Connection");
+
+ modem_run(fd, params.run_argc, params.run_argv);
+ close (fd);
+ }
+}