All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Kraglak <marcin.kraglak@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 1/9] shared: Add skeleton of hfp_at parser
Date: Tue, 25 Feb 2014 10:23:39 +0100	[thread overview]
Message-ID: <1393320227-10931-2-git-send-email-marcin.kraglak@tieto.com> (raw)
In-Reply-To: <1393320227-10931-1-git-send-email-marcin.kraglak@tieto.com>

It will parse AT frames in HFP profile implementation. Use can register
handlers for specified prefixes. Callbacks will be called with one of
hfp_cmd_type. Default handler will have prefix NULL, and type passed
to callback will be always HFP_AT_UNKNOWN.
---
 src/shared/hfp_at.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/shared/hfp_at.h | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+)
 create mode 100644 src/shared/hfp_at.c
 create mode 100644 src/shared/hfp_at.h

diff --git a/src/shared/hfp_at.c b/src/shared/hfp_at.c
new file mode 100644
index 0000000..bd1899b
--- /dev/null
+++ b/src/shared/hfp_at.c
@@ -0,0 +1,50 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library 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
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+#include <stdbool.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "src/shared/util.h"
+#include "src/shared/hfp_at.h"
+
+struct hfp_at {
+	const struct hfp_at_handler *cmd_handlers;
+};
+
+struct hfp_at *hfp_at_new(const struct hfp_at_handler *handlers)
+{
+	struct hfp_at *hfp_at;
+
+	hfp_at = new0(struct hfp_at, 1);
+	if (!hfp_at)
+		return NULL;
+
+	hfp_at->cmd_handlers = handlers;
+
+	return hfp_at;
+}
+
+void hfp_at_free(struct hfp_at *hfp_at)
+{
+	free(hfp_at);
+}
diff --git a/src/shared/hfp_at.h b/src/shared/hfp_at.h
new file mode 100644
index 0000000..fe074f2
--- /dev/null
+++ b/src/shared/hfp_at.h
@@ -0,0 +1,43 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library 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
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+struct hfp_at;
+
+enum hfp_cmd_type {
+	HFP_AT_READ,
+	HFP_AT_SET,
+	HFP_AT_TEST,
+	HFP_AT_COMMAND,
+	HFP_AT_UNKNOWN
+};
+
+typedef void (*hfp_at_cmd_cb)(struct hfp_at *hfp_at, enum hfp_cmd_type type,
+					const char *at, void *user_data);
+
+struct hfp_at_handler {
+	const char *prefix;
+	hfp_at_cmd_cb cb;
+};
+
+struct hfp_at *hfp_at_new(const struct hfp_at_handler *handlers);
+void hfp_at_free(struct hfp_at *hfp_at);
-- 
1.8.5.3


  reply	other threads:[~2014-02-25  9:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25  9:23 [PATCH 0/9] HFP AT parser skeleton Marcin Kraglak
2014-02-25  9:23 ` Marcin Kraglak [this message]
2014-02-25 18:46   ` [PATCH 1/9] shared: Add skeleton of hfp_at parser Marcel Holtmann
2014-02-25  9:23 ` [PATCH 2/9] unit: Add hfp_at tester Marcin Kraglak
2014-02-25  9:23 ` [PATCH 3/9] shared/hfp_at: Add skeleton of hfp_at_process_data Marcin Kraglak
2014-02-25 18:56   ` Marcel Holtmann
2014-02-25  9:23 ` [PATCH 4/9] unit/test_hfp_at: Add test cases for processing basic commands Marcin Kraglak
2014-02-25  9:23 ` [PATCH 5/9] shared/hfp_at: Add function for getting number Marcin Kraglak
2014-02-25  9:23 ` [PATCH 6/9] shared/hfp_at: Add function to open container Marcin Kraglak
2014-02-25  9:23 ` [PATCH 7/9] shared/hfp_at: Add function to close container Marcin Kraglak
2014-02-25  9:23 ` [PATCH 8/9] shared/hfp_at: Add function to get string Marcin Kraglak
2014-02-25  9:23 ` [PATCH 9/9] shared/hfp_at: Add function to get unquoted string Marcin Kraglak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393320227-10931-2-git-send-email-marcin.kraglak@tieto.com \
    --to=marcin.kraglak@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.