summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/plcd
diff options
context:
space:
mode:
authorOlivier Dufour2013-03-05 10:20:03 +0100
committerOlivier Dufour2013-03-06 13:06:25 +0100
commit096e941a63734f3a908a769cc0b78e96e1440551 (patch)
tree2006b128b6d3679110865d8fd32b7649a19e1545 /cleopatre/devkit/plcd
parent71fb0e3e8cd6883b76935a13063938bcbc4fbddc (diff)
cleo/devkit/plcd: update image index on assocation, refs #3815
Diffstat (limited to 'cleopatre/devkit/plcd')
-rw-r--r--cleopatre/devkit/plcd/inc/plcd.h1
-rw-r--r--cleopatre/devkit/plcd/src/plcd_autoswitch.c33
-rw-r--r--cleopatre/devkit/plcd/src/plcd_process.c4
3 files changed, 38 insertions, 0 deletions
diff --git a/cleopatre/devkit/plcd/inc/plcd.h b/cleopatre/devkit/plcd/inc/plcd.h
index 6d75009fa8..c6b2773edf 100644
--- a/cleopatre/devkit/plcd/inc/plcd.h
+++ b/cleopatre/devkit/plcd/inc/plcd.h
@@ -170,6 +170,7 @@ extern int autoswitch_timer_alive;
#define PLCD_AUTOSWITCH_TIMEOUT_SEC 60
void plcd_autoswitch_timer_init (void);
+void plcd_autoswitch_image_update (void);
int plcd_send_recv_drv_mme (const plcd_ctx_t *ctx, const mme_ctx_t *request_ctx,
mme_ctx_t *confirm_ctx, mme_ctx_t *indication_ctx);
diff --git a/cleopatre/devkit/plcd/src/plcd_autoswitch.c b/cleopatre/devkit/plcd/src/plcd_autoswitch.c
index ce1dab7e89..7ad40f7bf4 100644
--- a/cleopatre/devkit/plcd/src/plcd_autoswitch.c
+++ b/cleopatre/devkit/plcd/src/plcd_autoswitch.c
@@ -96,3 +96,36 @@ plcd_autoswitch_timer_init (void)
fclose (fp);
}
}
+
+void plcd_autoswitch_image_update (void)
+{
+ spidcom_image_desc_t img_desc[2];
+ char mtd_name[32] = {0};
+
+ if (libspid_image_get_desc (LIBSPID_IMAGE_DESC_TYPE_ALTERNATE,
+ &img_desc[1], mtd_name) != LIBSPID_SUCCESS)
+ {
+ syslog (LOG_WARNING, "%s: unable to retrieve alternate image desc", __FUNCTION__);
+ return;
+ }
+ if (libspid_image_get_desc (LIBSPID_IMAGE_DESC_TYPE_CURRENT,
+ &img_desc[0], mtd_name) != LIBSPID_SUCCESS)
+ {
+ syslog (LOG_WARNING, "%s: unable to retrieve current image desc", __FUNCTION__);
+ return;
+ }
+
+ /* First check if we really need to update the index:
+ * - is it greater than the alternate
+ * - is the alternate OK_ORIGIN
+ * - is the alternate valid */
+ if ((img_desc[0].index > img_desc[1].index)
+ || (img_desc[1].index == SPIDCOM_IMG_DESC_ORIGIN_INDEX)
+ || !img_desc[1].is_valid)
+ {
+ syslog (LOG_INFO, "%s: current image index update not required for autoswitch", __FUNCTION__);
+ return;
+ }
+
+ libspid_image_update_current_index (img_desc[1].index + 1, mtd_name);
+}
diff --git a/cleopatre/devkit/plcd/src/plcd_process.c b/cleopatre/devkit/plcd/src/plcd_process.c
index abca5eed9e..f832ce0b3a 100644
--- a/cleopatre/devkit/plcd/src/plcd_process.c
+++ b/cleopatre/devkit/plcd/src/plcd_process.c
@@ -159,6 +159,10 @@ plcd_stack_event_status (plcd_ctx_t *ctx, mme_ctx_t *indication_ctx)
its.it_interval.tv_nsec = 0;
timer_settime (autoswitch_timer, 0, &its, NULL);
autoswitch_timer_alive = 0;
+
+ /* Mark the image as working if necessary */
+ plcd_autoswitch_image_update ();
+
}
/* Check if we need to rearm the autoswitch timer. */
if (autoswitch_en