I would like to remotely reprogram my Arduino via Android over Bluetooth SPP. The first step is to reset the ATMEGA microcontroller. This is accomplished on the Arduino by toggling the DTR line. Is there any API to control the Bluetooth SPP control lines from the Android environment?
2 Answers
Also it is supported by SPP in general to send or receive the control signals (DTR, DSR, RTS, CTS) I do not know any API or library for android right know, but as you just want to reset your controller...
If it is o.k. for you to change your firmware you can also create your own reset-command that can be received on your UART (over SPP).
If you receive that command you could call something like
asm("jmp 0x3800");
where you have to modify the jmp
-address to point to your bootloader.
You also might want to change your interrupt vector to point to your bootloader.
Or enable your watchdog and call
while(1);
This will also automatically change the interrupt vector to the bootloader's interrupt vector and reset all SFRs. - But it is a little bit slower and the bootloader's interrupt vector must be choosen in the Fuse Bits.

- 190
- 3
- 7
-
Such an approach can work, but suffers from the issue that if a sketch fails to implement it, or crashes in a way that breaks this implementation (without triggering a watchdog reset), then there may be no way over this interface to enter the bootloader in order to fix it. – Chris Stratton Apr 09 '14 at 15:09
I realise that this is not what you wanted, but you could always flash a new bootloader with a longer timeout and manually press the reset button before starting programming.
The new Arduino bootloader (optiboot) fits in 512B (versus the 2K of the old one) so you have extra space available to your projects; has smart boot detection, so it only enters the bootloader when the reset button is pressed; and you can extend the timeout by editing the watchdog timeout value in the source (around line 267 in optiboot.c).
// Set up watchdog to trigger after 500ms (changed to 2s!)
watchdogConfig(WATCHDOG_2S);

- 19,086
- 7
- 60
- 64
-
Interesting... Would it be possible to customize my program to recognize a special command and manually enter the bootloader? For example once the bootloader has timed out waiting and started running a user program is it possible to reenter the bootloader? I guess it is certainly possible to manually fire a reset via an output pin wired to reset which would achieve the desired affect. – Troy Collinsworth Dec 08 '10 at 04:14
-
Should work, but you'd have to include that reset code in all of your sketches. The RESET pin is active low, so I'd just leave that pin configured as an input and then output 0 to reset. – Peter Gibson Dec 08 '10 at 07:06