Good SPOT Programming Practice
Thursday Jan 08, 2009
Since I've just been bitten by this one, I thought I would post a quick note on what I consider a good practice in SPOT Programming: Adding a bootloader listener thread. It's extremely easy to do, and (trust me on this one) it can save you a lot of time. The line you want is:
new BootloaderListener().start(); // monitor the USB (if connected) and recognize commands from host
Add that as the first line in your MIDlet's StartApp() method. Now, why would you want/need to do such a thing? And how can it save your bacon? Well, (as I have just experienced) some things -- in my case I2C -- can get into a tight loop. Such a tight loop that it can be difficult to reset the SPOT with a button press. I spent quite a bit of time trying to time the plugging-in of the SPOT with an upgrade command to get past this tight loop I was in.The bootloader listener thread running will 'hear' the bootloader command request when it is sent (at least after a small delay) and respond, automatically resetting the SPOT and dropping into the bootloader so that you can upgrade your SPOT, re-depoly an application, etc. Or just fix whatever got you into that tight loop in the first place. It's a life-saver when you need it, and takes very little overhead when you don't so it is definitely worth it.
[ Food for thought is no substitute for the real thing.
-- Walt Kelly, "Putluck Pogo" ]












Great post David, very nice, that help me to debug...