+ event void DisseminationValue.changed()
+ {
+ const DelugeCmd *cmd = call DisseminationValue.get();
+// printf("cmd: %d uidhash: 0x%lx imgNum: %d size: %u\n", cmd->type, cmd->uidhash, cmd->imgNum, cmd->size);
+ switch (cmd->type) {
+ case DELUGE_CMD_STOP:
+ call stop();
+ break;
+ case DELUGE_CMD_ONLY_DISSEMINATE:
+ case DELUGE_CMD_DISSEMINATE_AND_REPROGRAM:
+ if (state == S_RECV) {
+ if (cmd->uidhash == lastCmd.uidhash) {
+ if (cmd->imgNum == lastCmd.imgNum) {
+ // Same uidhash, same imgNum, only cmd should be
+ // different. That will be properly updated by the last
+ // statement from this function.
+ break;
+ }
+ }
+ call stop();
+ }
+ if (cmd->uidhash != IDENT_UIDHASH) {
+ call DelugeMetadata.read(cmd->imgNum);
+ } else {
+ state = S_PUB;
+ request();
+ }
+ break;
+ }
+ lastCmd = *cmd;
+// printf("lastCmd: %d uidhash: 0x%lx\n", lastCmd.type, lastCmd.uidhash);
+ }
+