summaryrefslogtreecommitdiffstats
path: root/gisi
diff options
context:
space:
mode:
authorPekka Pessi <Pekka.Pessi@nokia.com>2010-08-24 13:46:08 +0200
committerAki Niemi <aki.niemi@nokia.com>2010-08-30 17:55:15 +0300
commit3b95fe1d10aa72c9619116d6a2c17d6874de6cb1 (patch)
tree3c7cc30a99a79c9cf89c5e2c7a37bb632542431e /gisi
parentd21c660ae2d3b2d5a0629e6770bca10578f6fb20 (diff)
downloadofono-3b95fe1d10aa72c9619116d6a2c17d6874de6cb1.tar.bz2
gisi: Retry version query in g_isi_verify()
For some mysterious reason, not all COMMON_MESSAGEs get sent to modem. This patch adds a retry counter that tries to make sure an answer is always received.
Diffstat (limited to 'gisi')
-rw-r--r--gisi/verify.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/gisi/verify.c b/gisi/verify.c
index 7ba0cdc5..fae9d131 100644
--- a/gisi/verify.c
+++ b/gisi/verify.c
@@ -31,6 +31,7 @@
#include "client.h"
#define VERSION_TIMEOUT 5
+#define VERSION_RETRIES 2
#define COMMON_MESSAGE 0xF0
#define COMM_ISI_VERSION_GET_REQ 0x12
@@ -40,8 +41,22 @@
struct verify_data {
GIsiVerifyFunc func;
void *data;
+ guint count;
};
+static GIsiRequest *send_version_query(GIsiClient *client, GIsiResponseFunc cb,
+ void *opaque)
+{
+ uint8_t msg[] = {
+ COMMON_MESSAGE,
+ COMM_ISI_VERSION_GET_REQ,
+ 0x00 /* Filler */
+ };
+
+ return g_isi_request_make(client, msg, sizeof(msg), VERSION_TIMEOUT,
+ cb, opaque);
+}
+
static gboolean verify_cb(GIsiClient *client, const void *restrict data,
size_t len, uint16_t object, void *opaque)
{
@@ -51,8 +66,20 @@ static gboolean verify_cb(GIsiClient *client, const void *restrict data,
gboolean alive = FALSE;
- if (!msg)
+ if (!msg) {
+
+ if (++vd->count < VERSION_RETRIES) {
+
+ g_warning("Retry COMM_ISI_VERSION_GET_REQ");
+
+ if (send_version_query(client, verify_cb, opaque))
+ return TRUE;
+ }
+
+ g_warning("Timeout COMM_ISI_VERSION_GET_REQ");
+
goto out;
+ }
if (len < 2 || msg[0] != COMMON_MESSAGE)
goto out;
@@ -69,6 +96,7 @@ static gboolean verify_cb(GIsiClient *client, const void *restrict data,
out:
if (func)
func(client, alive, object, vd->data);
+
g_free(vd);
return TRUE;
}
@@ -87,17 +115,11 @@ GIsiRequest *g_isi_verify(GIsiClient *client, GIsiVerifyFunc func,
{
struct verify_data *data = g_try_new0(struct verify_data, 1);
GIsiRequest *req = NULL;
- uint8_t msg[] = {
- COMMON_MESSAGE,
- COMM_ISI_VERSION_GET_REQ,
- 0x00 /* Filler */
- };
data->func = func;
data->data = opaque;
- req = g_isi_request_make(client, msg, sizeof(msg), VERSION_TIMEOUT,
- verify_cb, data);
+ req = send_version_query(client, verify_cb, data);
if (!req)
g_free(data);