I'd like to upload ready HEX file to Arduino board. How can i do that in java code?
Should i implement stk500 protocol in java? Are there any working solutions or examples in java? Thank a lot!
You can call avrdude from java. Why do you need to circumvent avrdude? You need native code anyways (for accessing the serial interface), so why don't you wanna use avrdude?
The idea was to upload Arduino sketch right from Android device via USB, Ethernet or Bluetooth.
I can use native code using NDK but it should be not console app and it's not good to use arch-dependent code in java app in general.
I tend to write stk500 implementation as it seems to be pretty simple protocol.
But i agree that it's better to use smth ready and bugs-free instead of reinventing the wheel.
So what do you think about it?
PS. Serial interface is available in java code too
PS. Serial interface is available in java code too
Interfaces: yes, but you don't have support for it in the JVM, you need an external native library (like RXTXcomm or javax.com, but javax.com is available only on Unix platforms). To be a little picky: Dalvik (the vm for running code on Android) is not Java.
I guess, to emulate avrdude on Android and update Arduinos over Ethernet or Bluetooth, stk500 is not your biggest challenge.
Okay, let's say i already know how to pass bytes array to bootloader (via Serial, Bluetooth, Ethernet, etc, etc). Serial at least for sure.
Uploading via Bluetooth example:
The problem is how to interact with it in optimal way..
No, it's just a proof of concerns that compiled sketch can be uploaded via Bluetooth too. Let's leave the question about transport: usb, serial, bluetooth, ethernet - anyway.
The goal is to "talk with bootloader". So the question is "is there smth useful that can be used in java (Android to be exact) to help to do it".
One idea suggested was to use avrdude and it has few drawbacks like arch-dependency. And it's pretty difficult to integrate it into java app as Process.exec() is not supported in Android.
So it will be necessary to change avrdude code to use streams instead of file input and serial output. Does anyone want to do it?
Another idea is to implement stk500 in pure java code by myself.
Keep in mind that Arduino is using something similar to stk500 but it's not identical. If you implement it yourself take a look at the C implementation in avrdude.
Also keep in mind that not all Arduinos are using that protocol. For example the Leonardo or the Mega2560 are using another protocol for the upload. If you stay with UNOs and compatible you're fine with a slightly adapted stk500.