generic module FlashVolumeManagerP()
{
#ifdef DELUGE
- provides interface Notify<uint8_t>;
+ provides {
+ interface Notify<uint8_t> as DissNotify;
+ interface Notify<uint8_t> as ReprogNotify;
+ }
#endif
uses {
interface BlockRead[uint8_t img_num];
S_READ,
S_CRC,
S_REPROG,
+ S_SYNC,
};
message_t serialMsg;
event void BlockWrite.syncDone[uint8_t img_num](error_t error)
{
- if (state == S_ERASE) {
+ if (state == S_ERASE || state == S_SYNC) {
state = S_IDLE;
sendReply(error, sizeof(SerialReplyPacket));
}
error = call BlockRead.computeCrc[img_num](srpkt->offset,
srpkt->len, 0);
break;
+ case SERIALMSG_SYNC: // === Sync the flash ===
+ state = S_SYNC;
+ error = call BlockWrite.sync[img_num]();
+ break;
#ifdef DELUGE
case SERIALMSG_ADDR: // === Gets the physical starting address of a volume ===
*(nx_uint32_t*)(&serialMsg_payload->data) =
(uint32_t)call DelugeStorage.getPhysicalAddress[img_num](0);
sendReply(SUCCESS, sizeof(SerialReplyPacket) + 4);
break;
- case SERIALMSG_REPROG: // === Reboots and reprograms ===
+ case SERIALMSG_REPROG_BS: // === Reprograms only the base station ===
state = S_REPROG;
sendReply(SUCCESS, sizeof(SerialReplyPacket));
img_num_reboot = img_num;
call Timer.startOneShot(1024);
break;
case SERIALMSG_DISS: // === Starts disseminating a volume ===
- signal Notify.notify(img_num); // Notifies Deluge to start disseminate
+ signal DissNotify.notify(img_num); // Notifies Deluge to start disseminate
+ sendReply(SUCCESS, sizeof(SerialReplyPacket));
+ break;
+ case SERIALMSG_REPROG: // === Reprograms the network (except the base station) ===
+ signal ReprogNotify.notify(img_num);
sendReply(SUCCESS, sizeof(SerialReplyPacket));
break;
#endif
call NetProg.programImgAndReboot(img_num_reboot);
}
- command error_t Notify.enable() { return SUCCESS; }
- command error_t Notify.disable() { return SUCCESS; }
+ command error_t DissNotify.enable() { return SUCCESS; }
+ command error_t DissNotify.disable() { return SUCCESS; }
+ command error_t ReprogNotify.enable() { return SUCCESS; }
+ command error_t ReprogNotify.disable() { return SUCCESS; }
default command storage_addr_t DelugeStorage.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0; }
#endif