From 2dd6923dfa756e4f8fa08df61656470cd8a37c7e Mon Sep 17 00:00:00 2001 From: Pekka Pessi Date: Tue, 13 Apr 2010 15:07:20 +0300 Subject: [PATCH] Add infoserver to isimodem The info server provides information from the mobile station to the ISI modem. Currently it returns the Software Version Number (SVN) that is used in mobile identification. --- Makefile.am | 2 + drivers/isimodem/debug.c | 1 + drivers/isimodem/info.h | 2 + drivers/isimodem/infoserver.c | 126 ++++++++++++++++++++++++++++++++++ drivers/isimodem/infoserver.h | 40 +++++++++++ 5 files changed, 171 insertions(+) create mode 100644 drivers/isimodem/infoserver.c create mode 100644 drivers/isimodem/infoserver.h diff --git a/Makefile.am b/Makefile.am index 50b7d629..b6a47b05 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,6 +97,8 @@ builtin_sources += $(gisi_sources) \ drivers/isimodem/info.h \ drivers/isimodem/network-registration.c \ drivers/isimodem/network.h \ + drivers/isimodem/infoserver.h \ + drivers/isimodem/infoserver.c \ drivers/isimodem/voicecall.c \ drivers/isimodem/call.h \ drivers/isimodem/sms.c \ diff --git a/drivers/isimodem/debug.c b/drivers/isimodem/debug.c index b1e2ef1c..a2c2ef60 100644 --- a/drivers/isimodem/debug.c +++ b/drivers/isimodem/debug.c @@ -401,6 +401,7 @@ const char *info_subblock_name(enum info_subblock value) _(INFO_SB_PRODUCT_INFO_NAME); _(INFO_SB_PRODUCT_INFO_MANUFACTURER); _(INFO_SB_SN_IMEI_PLAIN); + _(INFO_SB_SN_IMEI_SV_TO_NET); _(INFO_SB_MCUSW_VERSION); } return "INFO_"; diff --git a/drivers/isimodem/info.h b/drivers/isimodem/info.h index 759721c9..837b96b3 100644 --- a/drivers/isimodem/info.h +++ b/drivers/isimodem/info.h @@ -27,6 +27,7 @@ extern "C" { #endif #define PN_PHONE_INFO 0x1B +#define PN_EPOC_INFO 98 #define INFO_TIMEOUT 5 enum info_isi_cause { @@ -50,6 +51,7 @@ enum info_subblock { INFO_SB_PRODUCT_INFO_NAME = 0x01, INFO_SB_PRODUCT_INFO_MANUFACTURER = 0x07, INFO_SB_SN_IMEI_PLAIN = 0x41, + INFO_SB_SN_IMEI_SV_TO_NET = 0x43, INFO_SB_MCUSW_VERSION = 0x48 }; diff --git a/drivers/isimodem/infoserver.c b/drivers/isimodem/infoserver.c new file mode 100644 index 00000000..d9f946ad --- /dev/null +++ b/drivers/isimodem/infoserver.c @@ -0,0 +1,126 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * 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 +#endif + +#include +#include +#include +#include + +#include +#include + +#define OFONO_API_SUBJECT_TO_CHANGE +#include +#include + +#include "info.h" +#include "infoserver.h" + +struct isi_infoserver +{ + GIsiServer *server; + unsigned sv; /* Software version in 0..98 */ +}; + +static bool serial_number_read_req(GIsiServer *server, void const *data, + size_t len, GIsiIncoming *irq, + void *opaque) +{ + struct isi_infoserver *self = opaque; + struct { + uint8_t mid; + uint8_t target; + } const *req = data; + + /* IMEISV defined in 3GPP TS 23.003 section 6.2.2 */ + + if (req->target == INFO_SB_SN_IMEI_SV_TO_NET) { + const uint8_t response[] = { + INFO_SERIAL_NUMBER_READ_RESP, INFO_OK, 1, + INFO_SB_SN_IMEI_SV_TO_NET, 16, + /* Mobile Identity IE, TS 24.008 section 10.5.1.4 */ + 0, 9, + /* F in place of IMEI digits and filler */ + 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x0f | ((self->sv / 10) << 4), + 0xf0 | ((self->sv % 10) & 0x0f), + + /* Subblock filler */ + 0, 0, 0 + }; + + DBG("Sending IMEI SV code %02u to modem", self->sv); + g_isi_respond(server, response, sizeof response, irq); + + } else { + const uint8_t error[] = { + INFO_SERIAL_NUMBER_READ_RESP, + INFO_NOT_SUPPORTED, + 0 + }; + + DBG("Unknown target 0x%02X", req->target); + g_isi_respond(server, error, sizeof error, irq); + } + + return TRUE; +} + +struct isi_infoserver *isi_infoserver_create(struct ofono_modem *modem, + void *data) +{ + struct isi_infoserver *self; + + self = g_new0(struct isi_infoserver, 1); + if (!self) + return NULL; + + self->server = g_isi_server_create(data, PN_EPOC_INFO, 0, 0); + if (!self->server) { + g_free(self); + return NULL; + } + + g_isi_server_add_name(self->server); + + g_isi_server_handle(self->server, + INFO_SERIAL_NUMBER_READ_REQ, + serial_number_read_req, + self); + + DBG("created %p", self); + + return self; +} + +void isi_infoserver_destroy(struct isi_infoserver *self) +{ + DBG("destroy %p", self); + + if (self) { + g_isi_server_destroy(self->server); + g_free(self); + } +} diff --git a/drivers/isimodem/infoserver.h b/drivers/isimodem/infoserver.h new file mode 100644 index 00000000..313ff2ee --- /dev/null +++ b/drivers/isimodem/infoserver.h @@ -0,0 +1,40 @@ +/* + * oFono - Open Telephony stack for Linux + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * 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 + */ + +#ifndef __OFONO_ISI_INFOSERVER_H +#define __OFONO_ISI_INFOSERVER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct isi_infoserver; + +struct isi_infoserver *isi_infoserver_create(struct ofono_modem *modem, + void *data); + +void isi_infoserver_destroy(struct isi_infoserver *self); + +#ifdef __cplusplus +} +#endif + +#endif /* __OFONO_ISI_INFOSERVER_H */