Permalink
Browse files

[ofono][rilmodem] OemRaw interface and rilplugin implementation

Signed-off-by: Tommi Kenakkala <tommi.kenakkala@oss.tieto.com>
  • Loading branch information...
1 parent 91e9d02 commit d00df4db747135e55002d7336c47833d5238cf85 @tkenakka tkenakka committed Oct 9, 2013
View
@@ -21,7 +21,8 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
include/cdma-connman.h include/gnss.h \
include/private-network.h include/cdma-netreg.h \
include/cdma-provision.h include/handsfree.h \
- include/handsfree-audio.h include/sim-mnclength.h
+ include/handsfree-audio.h include/sim-mnclength.h \
+ include/oemraw.h
nodist_pkginclude_HEADERS = include/version.h
@@ -140,7 +141,8 @@ builtin_sources += drivers/rilmodem/rilmodem.h \
drivers/rilmodem/ussd.c \
drivers/rilmodem/call-settings.c \
drivers/rilmodem/call-forwarding.c \
- drivers/rilmodem/cbs.c
+ drivers/rilmodem/cbs.c \
+ drivers/rilmodem/oemraw-messages.c
endif
@@ -571,7 +573,7 @@ src_ofonod_SOURCES = $(builtin_sources) src/ofono.ver \
src/cdma-sms.c src/private-network.c src/cdma-netreg.c \
src/cdma-provision.c src/handsfree.c \
src/handsfree-audio.c src/bluetooth.h \
- src/hfp.h src/sim-mnclength.c
+ src/hfp.h src/sim-mnclength.c src/oemraw.c
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
@@ -616,6 +618,7 @@ doc_files = doc/overview.txt doc/ofono-paper.txt doc/release-faq.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
doc/calypso-modem.txt doc/message-api.txt \
doc/location-reporting-api.txt doc/smshistory-api.txt \
+ doc/oemraw-api.txt \
doc/certification.txt
View
@@ -0,0 +1,19 @@
+OemRaw hierarchy
+==============================
+
+Service org.ofono
+Interface org.ofono.OemRaw
+Object path [variable prefix]/{modem0,modem1,...}
+
+Methods array{byte} Send(array{byte} req)
+
+ Sends an array of bytes to modem and returns its
+ response.
+
+ One potential use is proprietary request handling.
+ Composing a properly formatted request is on the
+ responsibility of the client.
+ Multiple simultaneous requests are supported by ofono
+ core, but driver- or modem-specific restrictions may
+ exist.
+
@@ -0,0 +1,161 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2013 Jolla Ltd
+ *
+ * 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 <glib.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/oemraw.h>
+#include "common.h"
+#include "gril.h"
+#include "rilmodem.h"
+
+struct oem_raw_data {
+ GRil *ril;
+ unsigned int vendor;
+};
+
+static gboolean ril_oemraw_delayed_register(gpointer user_data)
+{
+ struct ofono_oem_raw *raw = user_data;
+
+ DBG("");
+
+ ofono_oem_raw_dbus_register(raw);
+ return FALSE; /* This makes the timeout a single-shot */
+}
+
+static int ril_oemraw_probe(struct ofono_oem_raw *raw, unsigned int vendor,
+ void *data)
+{
+ GRil *ril = data;
+ struct oem_raw_data *od;
+
+ DBG("");
+
+ od = g_new0(struct oem_raw_data, 1);
+
+ od->ril = g_ril_clone(ril);
+ od->vendor = vendor;
+ ofono_oem_raw_set_data(raw, od);
+
+ g_timeout_add_seconds(1, ril_oemraw_delayed_register, raw);
+
+ return 0;
+}
+
+static void ril_oemraw_remove(struct ofono_oem_raw *raw)
+{
+ struct oem_raw_data *od;
+
+ DBG("");
+
+ od = ofono_oem_raw_get_data(raw);
+
+ ofono_oem_raw_set_data(raw, NULL);
+
+ g_ril_unref(od->ril);
+ g_free(od);
+}
+
+static void ril_oemraw_request_cb(struct ril_msg *msg,
+ gpointer user_data)
+{
+ struct ofono_error error;
+ struct ofono_oem_raw_results result;
+ struct cb_data *cbd = user_data;
+ ofono_oem_raw_query_cb_t cb = cbd->cb;
+
+ if (msg && msg->error == RIL_E_SUCCESS) {
+ decode_ril_error(&error, "OK");
+ } else {
+ DBG("error:%d len:%d unsol:%d req:%d serial_no:%d",
+ msg->error, msg->buf_len, msg->unsolicited,
+ msg->req, msg->serial_no);
+ CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+ return;
+ }
+
+ result.data = msg->buf;
+ result.length = msg->buf_len;
+
+ cb(&error, &result, cbd->data);
+}
+
+static void ril_oemraw_request(struct ofono_oem_raw *raw,
+ const struct ofono_oem_raw_request *request,
+ ofono_oem_raw_query_cb_t cb, void *data)
+{
+ int ret;
+ int i;
+ struct cb_data *cbd;
+ struct oem_raw_data *od;
+ struct parcel parcel;
+
+ cbd = cb_data_new(cb, data);
+ od = ofono_oem_raw_get_data(raw);
+ parcel_init(&parcel);
+
+ for (i = 0; i < request->length; i++) {
+ /*DBG("Byte: 0x%x", request->data[i]); Enable for debugging*/
+ parcel_w_byte(&parcel, request->data[i]);
+ }
+
+ ret = g_ril_send(od->ril, RIL_REQUEST_OEM_HOOK_RAW, parcel.data,
+ parcel.size, ril_oemraw_request_cb, cbd,
+ g_free);
+
+ parcel_free(&parcel);
+
+ if (ret <= 0) {
+ g_free(cbd);
+ DBG("Failed to issue an OEM RAW request to RIL: result=%d ",
+ ret);
+ CALLBACK_WITH_FAILURE(cb, NULL, data);
+ }
+ return;
+}
+
+static struct ofono_oem_raw_driver driver = {
+ .name = "rilmodem",
+ .probe = ril_oemraw_probe,
+ .remove = ril_oemraw_remove,
+ .request = ril_oemraw_request,
+};
+
+void ril_oemraw_init(void)
+{
+ DBG("");
+ ofono_oem_raw_driver_register(&driver);
+}
+
+void ril_oemraw_exit(void)
+{
+ DBG("");
+ ofono_oem_raw_driver_unregister(&driver);
+}
@@ -4,6 +4,7 @@
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
* Copyright (C) 2012 Canonical, Ltd. All rights reserved.
+ * Copyright (C) 2013 Jolla Ltd.
*
* 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
@@ -53,6 +54,7 @@ static int rilmodem_init(void)
ril_call_settings_init();
ril_call_forwarding_init();
ril_cbs_init();
+ ril_oemraw_init();
return 0;
}
@@ -75,6 +77,7 @@ static void rilmodem_exit(void)
ril_call_settings_exit();
ril_call_forwarding_exit();
ril_cbs_exit();
+ ril_oemraw_exit();
}
OFONO_PLUGIN_DEFINE(rilmodem, "RIL modem driver", VERSION,
@@ -4,6 +4,7 @@
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
* Copyright (C) 2012 Canonical Ltd.
+ * Copyright (C) 2013 Jolla Ltd.
*
* 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
@@ -73,3 +74,5 @@ extern void ril_cbs_exit(void);
extern void ril_phonebook_init(void);
extern void ril_phonebook_exit(void);
+extern void ril_oemraw_init(void);
+extern void ril_oemraw_exit(void);
View
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2011 Joel Armstrong <jcarmst@sandia.gov>
* Copyright (C) 2012 Canonical Ltd.
+ * Copyright (C) 2013 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (`GPL') as published by
@@ -32,8 +33,6 @@
#include <glib.h>
-#include <ofono/log.h>
-
/* Parcel-handling code */
#include <sys/types.h>
#include <string.h>
@@ -96,6 +95,23 @@ int parcel_w_int32(struct parcel *p, int32_t val)
return 0;
}
+int parcel_w_byte(struct parcel *p, const char val)
+{
+ for (;;) {
+ if (p->offset + sizeof(char) < p->capacity) {
+ /* There's enough space */
+ *((char *) (p->data + p->offset)) = val;
+ p->offset += sizeof(char);
+ p->size += sizeof(char);
+ break;
+ } else {
+ /* Grow data and retry */
+ parcel_grow(p, sizeof(int32_t));
+ }
+ }
+ return 0;
+}
+
int parcel_w_string(struct parcel *p, char *str)
{
gunichar2 *gs16;
View
@@ -1,5 +1,6 @@
/*
* Copyright © 2011 Joel Armstrong <jcarmst@sandia.gov>
+ * Copyright © 2013 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (`GPL') as published by
@@ -36,6 +37,7 @@ void parcel_grow(struct parcel *p, size_t size);
void parcel_free(struct parcel *p);
int32_t parcel_r_int32(struct parcel *p);
int parcel_w_int32(struct parcel *p, int32_t val);
+int parcel_w_byte(struct parcel *p, const char val);
int parcel_w_string(struct parcel *p, char *str);
char *parcel_r_string(struct parcel *p);
size_t parcel_data_avail(struct parcel *p);
View
@@ -3,6 +3,7 @@
* oFono - Open Telephony stack for Linux
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2013 Jolla Ltd.
*
* 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
@@ -60,6 +61,7 @@ extern "C" {
#define OFONO_GNSS_POSR_AGENT_INTERFACE "org.ofono.PositioningRequestAgent"
#define OFONO_HANDSFREE_INTERFACE OFONO_SERVICE ".Handsfree"
#define OFONO_NETWORK_TIME_INTERFACE OFONO_SERVICE ".NetworkTime"
+#define OFONO_OEM_RAW_INTERFACE "org.ofono.OemRaw"
/* CDMA Interfaces */
#define OFONO_CDMA_VOICECALL_MANAGER_INTERFACE "org.ofono.cdma.VoiceCallManager"
Oops, something went wrong.

0 comments on commit d00df4d

Please sign in to comment.