Bluetooth control signals (DTR, DSR, RTS, CTS) on Android

好久不见. 提交于 2019-12-23 15:13:04

问题


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?


回答1:


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.




回答2:


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);


来源:https://stackoverflow.com/questions/4241998/bluetooth-control-signals-dtr-dsr-rts-cts-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!