From: Dmitriy Paliy <dmitriy.paliy@nokia.com>
To: linux-bluetooth@vger.kernel.org
Cc: Dmitriy Paliy <dmitriy.paliy@nokia.com>
Subject: [PATCH] Fix signal strength for HFP in maemo6 telephony due to changed API in libcsnet.
Date: Fri, 9 Jul 2010 17:44:17 +0300 [thread overview]
Message-ID: <1278686657-6997-1-git-send-email-dmitriy.paliy@nokia.com> (raw)
Signed-off-by: Dmitriy Paliy <dmitriy.paliy@nokia.com>
---
audio/telephony-maemo6.c | 50 +++++++++++++++++++++------------------------
1 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
index 31704c3..da3c19a 100644
--- a/audio/telephony-maemo6.c
+++ b/audio/telephony-maemo6.c
@@ -134,11 +134,12 @@ struct csd_call {
static struct {
char *operator_name;
uint8_t status;
- int32_t signals_bar;
+ int32_t signal_bars;
} net = {
.operator_name = NULL,
.status = NETWORK_REG_STATUS_UNKOWN,
- .signals_bar = 0,
+ .signal_bars = 0, /* Init as 0 meaning inactive mode. In modem power off state it can */
+ /* be -1, but we treat all values as 0s regardless inactive or power off. */
};
static int get_property(const char *iface, const char *prop);
@@ -181,7 +182,7 @@ static guint create_request_timer = 0;
static struct indicator maemo_indicators[] =
{
{ "battchg", "0-5", 5, TRUE },
- { "signal", "0-5", 0, TRUE },
+ { "signal", "0-5", 0, TRUE }, /* signal strength in terms of bars */
{ "service", "0,1", 0, TRUE },
{ "call", "0,1", 0, TRUE },
{ "callsetup", "0-3", 0, TRUE },
@@ -1227,43 +1228,38 @@ static void handle_registration_changed(DBusMessage *msg)
update_registration_status(status);
}
-static void update_signal_strength(int32_t signals_bar)
+static void update_signal_strength(int32_t signal_strength_bars)
{
- int signal;
-
- if (signals_bar < 0)
- signals_bar = 0;
- else if (signals_bar > 100) {
- DBG("signals_bar greater than expected: %u", signals_bar);
- signals_bar = 100;
+ if (signal_strength_bars < 0) {
+ DBG("signal strength bars smaller than expected: %d", signal_strength_bars);
+ signal_strength_bars = 0;
+ } else if (signal_strength_bars > 5) {
+ DBG("signal strength bars greater than expected: %d", signal_strength_bars);
+ signal_strength_bars = 5;
}
- if (net.signals_bar == signals_bar)
+ if (net.signal_bars == signal_strength_bars)
return;
- /* A simple conversion from 0-100 to 0-5 (used by HFP) */
- signal = (signals_bar + 20) / 21;
-
- telephony_update_indicator(maemo_indicators, "signal", signal);
+ telephony_update_indicator(maemo_indicators, "signal", signal_strength_bars);
- net.signals_bar = signals_bar;
+ net.signal_bars = signal_strength_bars;
- DBG("telephony-maemo6: signal strength updated: %u/100, %d/5", signals_bar, signal);
+ DBG("telephony-maemo6: signal strength bars updated: %d/5", signal_strength_bars);
}
-static void handle_signal_strength_changed(DBusMessage *msg)
+static void handle_signal_bars_changed(DBusMessage *msg)
{
- int32_t signals_bar, rssi_in_dbm;
+ int32_t signal_bars;
if (!dbus_message_get_args(msg, NULL,
- DBUS_TYPE_INT32, &signals_bar,
- DBUS_TYPE_INT32, &rssi_in_dbm,
+ DBUS_TYPE_INT32, &signal_bars,
DBUS_TYPE_INVALID)) {
- error("Unexpected parameters in SignalStrengthChanged");
+ error("Unexpected parameters in SignalBarsChanged");
return;
}
- update_signal_strength(signals_bar);
+ update_signal_strength(signal_bars);
}
static gboolean iter_get_basic_args(DBusMessageIter *iter,
@@ -1530,7 +1526,7 @@ static void get_property_reply(DBusPendingCall *call, void *user_data)
dbus_message_iter_get_basic(&sub, &name);
update_operator_name(name);
} else if (g_strcmp0(prop, "SignalBars") == 0) {
- uint32_t signal_bars;
+ int32_t signal_bars;
dbus_message_iter_get_basic(&sub, &signal_bars);
update_signal_strength(signal_bars);
@@ -1899,8 +1895,8 @@ static DBusHandlerResult signal_filter(DBusConnection *conn,
"OperatorNameChanged"))
handle_operator_name_changed(msg);
else if (dbus_message_is_signal(msg, CSD_CSNET_SIGNAL,
- "SignalStrengthChanged"))
- handle_signal_strength_changed(msg);
+ "SignalBarsChanged"))
+ handle_signal_bars_changed(msg);
else if (dbus_message_is_signal(msg, "org.freedesktop.Hal.Device",
"PropertyModified"))
handle_hal_property_modified(msg);
--
1.7.0.4
next reply other threads:[~2010-07-09 14:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-09 14:44 Dmitriy Paliy [this message]
2010-07-09 16:39 ` [PATCH] Fix signal strength for HFP in maemo6 telephony due to changed API in libcsnet Hedberg Johan (Nokia-D/Helsinki)
2010-07-09 16:45 ` Gustavo F. Padovan
2010-07-11 21:17 ` [PATCH 1/2] Fix signal strength for HFP in maemo6 telephony Dmitriy Paliy
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=1278686657-6997-1-git-send-email-dmitriy.paliy@nokia.com \
--to=dmitriy.paliy@nokia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).