aboutsummaryrefslogtreecommitdiff
path: root/src/mm-port-probe-at.h
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-03-07 14:21:11 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-16 14:53:22 +0100
commit690777986b0efe6a38135ea8f42f392a6320cf77 (patch)
tree38a372d05dc769376d53ced20cc5c43911947663 /src/mm-port-probe-at.h
parent70103fdef3556551cb282849fb8fb1dbcd102deb (diff)
port-probe: refactor AT command handling
Make it use a GVariant in the response processor, as the AT command handling in the MMBaseModem.
Diffstat (limited to 'src/mm-port-probe-at.h')
-rw-r--r--src/mm-port-probe-at.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/mm-port-probe-at.h b/src/mm-port-probe-at.h
new file mode 100644
index 00000000..ee21b7aa
--- /dev/null
+++ b/src/mm-port-probe-at.h
@@ -0,0 +1,79 @@
+/* -*- 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 - 2012 Aleksander Morgado <aleksander@gnu.org>
+ * Copyright (C) 2012 Google, Inc.
+ */
+
+#ifndef MM_PORT_PROBE_AT_H
+#define MM_PORT_PROBE_AT_H
+
+#include <glib.h>
+
+/* The response processor. The expected result depends on the
+ * probing type:
+ * - AT --> Boolean
+ * - Vendor --> String
+ * - Product --> String
+ *
+ * TRUE must be returned when the operation is to be considered successful,
+ * and a result may be given.
+ *
+ * FALSE must be returned when:
+ * - A GError is propagated into result_error, which will be treated as a
+ * critical error and therefore the operation will be aborted.
+ * - When no result_error is given, to instruct the operation to go on with
+ * the next scheduled command.
+ *
+ * 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 or Boolean
+ * When the initialization is considered enough, TRUE is returned, and
+ * FALSE otherwise.
+ */
+typedef gboolean (* MMPortProbeAtResponseProcessor) (const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
+
+/* Struct to configure port probing commands */
+typedef struct {
+ /* The AT command */
+ gchar *command;
+ /* Timeout of the command, in seconds */
+ guint timeout;
+ /* The response processor */
+ MMPortProbeAtResponseProcessor response_processor;
+} MMPortProbeAtCommand;
+
+/* Common helper response processors */
+
+/* Every string received as response, will be set as result */
+gboolean mm_port_probe_response_processor_string (const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
+/* Generic response parser for AT probing, useful also in custom init commands */
+gboolean mm_port_probe_response_processor_is_at (const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error);
+
+#endif /* MM_PORT_PROBE_AT_H */