Hi all,
This patch is RFC for Infenion modem API to support agps implementation of
ofono.
Thank you for your comments in advance.
Cheers,
-- r.
From 2544eed707725e813c4673aa0577c095a0a3c2a5 Mon Sep 17 00:00:00 2001
From: Robertino Benis robertino.be...@intel.com
Date: Tue, 2 Nov 2010 17:16:35 -0700
Subject: [CHANGE 2/2] [RFC] ifxmodem: adding modem API to support agps
Organization: Intel
Cc: robertino.be...@intel.com
---
drivers/ifxmodem/agps.c | 438 +++
include/agps.h | 157 +
2 files changed, 595 insertions(+), 0 deletions(-)
create mode 100644 drivers/ifxmodem/agps.c
create mode 100644 include/agps.h
diff --git a/drivers/ifxmodem/agps.c b/drivers/ifxmodem/agps.c
new file mode 100644
index 000..9b68b7e
--- /dev/null
+++ b/drivers/ifxmodem/agps.c
@@ -0,0 +1,438 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#define _GNU_SOURCE
+#include string.h
+#include stdlib.h
+#include stdio.h
+#include errno.h
+
+#include glib.h
+
+#include gatchat.h
+#include gatresult.h
+
+#include ofono/log.h
+#include ofono/modem.h
+#include ofono/agps.h
+
+#include util.h
+#include ifxmodem.h
+
+struct agps_data {
+ GAtChat *chat;
+ unsigned int vendor;
+ enum ofono_access_technology rad_acc_tech;
+};
+
+struct ofono_agps;
+static enum ofono_access_technology rad_acc_tech;
+static const char *none_prefix[] = { NULL };
+
+#define FRAME_LEN 128
+
+static void pos_request_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_agps *agps = user_data;
+ int framelen;
+ int frametype;
+ GAtResultIter iter;
+ struct ofono_lcs_frame lcsframe;
+ const char *messageframe;
+ unsigned char frame[FRAME_LEN];
+ long hexframelen;
+
+ /* Assuming Pos Req format: %XPOSR: frametype,framelen,frame */
+
+ g_at_result_iter_init(iter, result);
+
+ if (!g_at_result_iter_next(iter, %%XPOSR:))
+ return;
+
+ if (!g_at_result_iter_next_number(iter, frametype))
+ return;
+
+ if (!g_at_result_iter_next_number(iter, framelen))
+ return;
+
+ if (framelen FRAME_LEN) {
+ ofono_error(Got POS request msg more than max buffer size!);
+ return;
+ }
+
+ messageframe = g_at_result_pdu(result);
+
+ if (strlen(messageframe) sizeof(frame) * 2) { /*Hex, 2 chars/byte*/
+ ofono_error(Message frame too long!);
+ return;
+ }
+
+ if (decode_hex_own_buf(messageframe, -1, hexframelen, 0,
+ frame) == NULL) {
+ ofono_error(Unable to hex-decode the AGPS frame);
+ return;
+ }
+
+ DBG(Got POS request data: %s, %ld, frame, hexframelen);
+
+ if (hexframelen != framelen) {
+ ofono_error(hexframelen not equal to reported framelen);
+ return;
+ }
+
+ lcsframe.lcs_frame_type = frametype;
+ lcsframe.frame_length = framelen;
+ lcsframe.raw_frame = (unsigned char *)frame;
+
+ ofono_agps_lcs_frame_notify(agps, lcsframe);
+}
+
+static void inj_time_notify(GAtResult *result, gpointer user_data)
+{
+
+ struct cb_data *cbd = user_data;
+ struct agps_data *agd = cbd-user;
+ ofono_agps_inject_time_cb_t cb = cbd-cb;
+ struct ofono_lcs_radio_fn rf;
+ struct ofono_error error = { .type = OFONO_ERROR_TYPE_NO_ERROR };
+ GAtResultIter iter;
+
+ g_at_result_iter_init(iter, result);
+
+ if (!g_at_result_iter_next(iter, %%XFTI:))
+ return;
+
+ if (RADIO_ACCESS_TECHNOLOGY_GSM == rad_acc_tech) {
+
+ int fn; /* range 0 - 2715647 (2048*26*51) */
+ int ts; /* range 0 - 7 */
+ int tsb;/* range 0 - 156 */
+ int ta; /* range 0 - 63 */
+ int ba; /* range 0 - 1023 */
+ int bc; /* range 0 - 64 */
+
+ /* %XFTI:frameNum,TimeSlot,TimeSlotBit,TimeAdv,
+ * ChannelNum,ChannelId
+ */
+ if (!g_at_result_iter_next_number(iter, fn