aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-09-09 21:32:03 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:20 +0100
commitd7238403c485d040dc77b3c2e428b876c3b33bdf (patch)
tree5cbb93a6f9aae6a57971f8316fc5f4b2df7e6491
parentf7b1d99fa0ac00889a65b22905939e4f86061902 (diff)
port-probe: new type to define commands used during probing
The new `MMPortProbeAtCommand' type defines what command will be sent to the serial AT port, and also a response processor method to parse the string returned by the port. The response processor gets as input either the text reply string or an error, and it should give as output either a GValue (type depends on the probing kind being done) or a new error (which will force the whole probing process to be aborted.
-rw-r--r--src/Makefile.am1
-rw-r--r--src/mm-port-probe-at-command.h54
2 files changed, 55 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 86bcfd24..acad86ef 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -132,6 +132,7 @@ modem_manager_SOURCES = \
mm-modem-simple.h \
mm-port-probe.h \
mm-port-probe.c \
+ mm-port-probe-at-command.h \
mm-plugin.c \
mm-plugin.h \
mm-plugin-base.c \
diff --git a/src/mm-port-probe-at-command.h b/src/mm-port-probe-at-command.h
new file mode 100644
index 00000000..9377560f
--- /dev/null
+++ b/src/mm-port-probe-at-command.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org>
+ */
+
+#ifndef MM_PORT_PROBE_AT_COMMAND_H
+#define MM_PORT_PROBE_AT_COMMAND_H
+
+#include <glib.h>
+
+/* Struct to configure port probing commands */
+typedef struct {
+ /* The AT command */
+ const gchar *command;
+
+ /* The response processor. The expected result depends on the
+ * probing type:
+ * - AT --> G_TYPE_BOOLEAN
+ * - Capabilities --> G_TYPE_UINT
+ * - Vendor --> G_TYPE_STRING
+ * - Product --> G_TYPE_STRING
+ * When a result is given, TRUE is returned.
+ * When no result is given, FALSE is returned and:
+ * - If result_error given, it should be treated as a critical error,
+ * and abort the probing.
+ * - If no result_error is given, we can just go on to the next command
+ * in the group.
+ *
+ * A special case to consider is the initialization commands, used by
+ * some plugins. In this case, there is no expected result, but plugins may
+ * set an optional boolean result, specifying whether the port is an AT port
+ * or not.
+ * - Initialization --> NONE | G_TYPE_BOOLEAN
+ * When the initialization is considered enough, TRUE is returned, and
+ * FALSE otherwise.
+ */
+ gboolean (* response_processor) (const gchar *response,
+ const GError *error,
+ GValue *result,
+ GError **result_error);
+} MMPortProbeAtCommand;
+
+#endif /* MM_PORT_PROBE_AT_COMMAND_H */
+