Android application for updating an external motherboard

Background:

We created an Android app that currently interacts with an external motherboard via a Bluetooth connection. The board in the queue issues commands to start one or several engines (engines) at different speeds. (This application was created for a specific task in the marine industry)

Our goal is to improve the application so that users of Android mobile phones (in the future) can update the firmware of the motherboard by issuing a command in the application connected via Bluetooth.

The motherboard uses the old standard YMODEM communication protocol. http://en.wikipedia.org/wiki/YMODEM The motherboard supports this function, and now we can process the firmware update using a hyperlink on the Windows platform.

My question is :

Can I use the YMODEM protocol in an Android app to re-flash?

If so, how? Any help would be appreciated! Thanks for watching this!

+2
source share
1 answer

Apologies for the late reply, but it may be helpful ... Yes, it is definitely possible. I did just that with the nexus 7 and an external device with an ARM processor. Nexus 7 must be implemented with USB debugging enabled. I used the wugfresh nexus root toolkit - it was very simple.

Next (hold it in place), you must write your application to use the YModem protocol. One option is to use the Android NDK (Native Development Kit) to compile the YModem protocol written in C / C ++ (Try Tixy's ). You will need cygwin or mingw before installing NDK if you are running Windows.

So, let's say you use windows and you have NDK installed in c:\android-ndk-r8b-windows\android-ndk-r8b . You can use Eclipse with the adt plugin installed and let your new project workspace be c: \ android-workspace. You can use the batch file to execute NDK make from your project ( c:\android-workspace\batch.bat ):

 C:\android-ndk-r8b-windows\android-ndk-r8b\ndk-build.cmd PAUSE 

Just make sure you export the C / C ++ functions so that they can be used by your JAVA android application.

Interface.cpp:

 #include <string.h> #include <jni.h> #include <dirent.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include "ymodem_tx.h" #include "ymodem_main.h" extern "C" { JNIEXPORT int JNICALL Java_com_example_ymupload_MainActivity_ymodemSent( JNIEnv* env, jobject obj, int portNumber, jstring fileName) { int status = 0; if (portNumber >= 0) { const char* input = env->GetStringUTFChars(fileName, 0); status = ymodem_sentFile(portNumber, input); env->ReleaseStringUTFChars(fileName, input); } else { status = 0xFF; } return status; } JNIEXPORT int JNICALL Java_com_example_ymupload_MainActivity_YmodemGetTotalSize( JNIEnv* env, jobject obj) { return ymodem_getTotalSize(); } JNIEXPORT int JNICALL Java_com_example_ymupload_MainActivity_YmodemGetTransferredSize( JNIEnv* env, jobject obj) { return ymodem_getTransferredSize(); } JNIEXPORT bool JNICALL Java_com_example_ymupload_MainActivity_YmodemIsSending( JNIEnv* env, jobject obj) { return ymodem_bIsSending(); } JNIEXPORT int JNICALL Java_com_example_ymupload_MainActivity_YmodemGetStatus( JNIEnv* env, jobject obj) { return ymodem_uGetStatus(); } JNIEXPORT jstring JNICALL Java_com_example_ymupload_MainActivity_YmodemGetFileName( JNIEnv* env, jobject obj) { return env->NewStringUTF(ymodem_pGetFileName()); } } 

Also make sure you put this file and other .c , .cpp , .h jni in the jni folder in the project folder, for example. c:\android-workspace\prog-name\jni , along with the Android.mk file (there are many other questions about the stack about Android.mk files).

You can put the binary files that you want to put in the folder on /sdcard/ . Download a file browser to see them.

+7
source

Source: https://habr.com/ru/post/951289/


All Articles