summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDenis Kenzior <denis.kenzior@intel.com>2009-09-03 23:05:18 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-09-03 23:20:22 -0500
commit23484524df596aca1e930b55d61d0cbc12408b70 (patch)
tree9edce2dd2f9861f6b79b386808bc49fb7a388247 /drivers
parent1a1f7d34d2301ebac972e11bb08834be57660dd8 (diff)
downloadofono-23484524df596aca1e930b55d61d0cbc12408b70.tar.bz2
Add quirk for network-registration for calypso
Support calypso-specific AT%CSQ notifications
Diffstat (limited to 'drivers')
-rw-r--r--drivers/atmodem/network-registration.c47
-rw-r--r--drivers/atmodem/vendor.h3
2 files changed, 43 insertions, 7 deletions
diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index bfad315d..aa2fe98e 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -38,6 +38,7 @@
#include "gatresult.h"
#include "at.h"
+#include "vendor.h"
static const char *none_prefix[] = { NULL };
static const char *creg_prefix[] = { "+CREG:", NULL };
@@ -48,6 +49,7 @@ struct netreg_data {
GAtChat *chat;
char mcc[OFONO_MAX_MCC_LENGTH + 1];
char mnc[OFONO_MAX_MNC_LENGTH + 1];
+ unsigned int vendor;
};
static void extract_mcc_mnc(const char *str, char *mcc, char *mnc)
@@ -495,6 +497,19 @@ error:
}
}
+static inline void report_signal_strength(struct ofono_netreg *netreg,
+ int strength)
+{
+ ofono_debug("csq_notify: %d", strength);
+
+ if (strength == 99)
+ strength = -1;
+ else
+ strength = strength * 100 / 31;
+
+ ofono_netreg_strength_notify(netreg, strength);
+}
+
static void csq_notify(GAtResult *result, gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
@@ -511,14 +526,26 @@ static void csq_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(&iter, &strength))
return;
- ofono_debug("csq_notify: %d", strength);
+ report_signal_strength(netreg, strength);
+}
- if (strength == 99)
- strength = -1;
- else
- strength = strength * 100 / 31;
+static void calypso_csq_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_netreg *netreg = user_data;
+ int strength;
+ GAtResultIter iter;
- ofono_netreg_strength_notify(netreg, strength);
+ dump_response("calypso_csq_notify", TRUE, result);
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "%CSQ:"))
+ return;
+
+ if (!g_at_result_iter_next_number(&iter, &strength))
+ return;
+
+ report_signal_strength(netreg, strength);
}
static void csq_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -633,6 +660,10 @@ static void at_network_registration_initialized(gboolean ok, GAtResult *result,
g_at_chat_register(nd->chat, "+CSQ:",
csq_notify, FALSE, netreg, NULL);
+ if (nd->vendor == OFONO_VENDOR_CALYPSO)
+ g_at_chat_register(nd->chat, "%CSQ:", calypso_csq_notify,
+ FALSE, netreg, NULL);
+
ofono_netreg_register(netreg);
}
@@ -645,8 +676,12 @@ static int at_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
nd = g_new0(struct netreg_data, 1);
nd->chat = chat;
+ nd->vendor = vendor;
ofono_netreg_set_data(netreg, nd);
+ if (nd->vendor == OFONO_VENDOR_CALYPSO)
+ g_at_chat_send(chat, "AT%CSQ=1", NULL, NULL, NULL, NULL);
+
g_at_chat_send(chat, "AT+CREG=2", NULL,
at_network_registration_initialized,
netreg, NULL);
diff --git a/drivers/atmodem/vendor.h b/drivers/atmodem/vendor.h
index 9551a108..d88444f4 100644
--- a/drivers/atmodem/vendor.h
+++ b/drivers/atmodem/vendor.h
@@ -21,5 +21,6 @@
enum ofono_vendor {
OFONO_VENDOR_GENERIC = 0,
- OFONO_VENDOR_HTC_G1 = 1,
+ OFONO_VENDOR_HTC_G1,
+ OFONO_VENDOR_CALYPSO,
};