diff --git a/mpmaster/src/main/cpp/mpmaster.cpp b/mpmaster/src/main/cpp/mpmaster.cpp index e4cb8591..0c461972 100644 --- a/mpmaster/src/main/cpp/mpmaster.cpp +++ b/mpmaster/src/main/cpp/mpmaster.cpp @@ -17,6 +17,8 @@ // } #include #include +#include +#include #include #include #include @@ -57,8 +59,8 @@ Java_com_xypower_mpmaster_MpMasterService_getInt(JNIEnv* env, jclass cls, jint c return -1; } -extern "C" JNIEXPORT jint JNICALL -Java_com_xypower_mpmaster_MpMasterService_setInt(JNIEnv* env, jclass cls, jint cmd, jint val) { +int setGpioInt(int cmd, int val) +{ int fd = open("/dev/mtkgpioctrl", O_RDONLY); // LOGE("set_int fd=%d,cmd=%d,value=%d\r\n",fd, cmd, value); if( fd > 0 ) @@ -74,15 +76,25 @@ Java_com_xypower_mpmaster_MpMasterService_setInt(JNIEnv* env, jclass cls, jint c return -1; } +extern "C" JNIEXPORT jint JNICALL +Java_com_xypower_mpmaster_MpMasterService_setInt(JNIEnv* env, jclass cls, jint cmd, jint val) { + + return setGpioInt(cmd, val); +} + extern "C" JNIEXPORT void JNICALL Java_com_xypower_mpmaster_MpMasterService_rebootDevice(JNIEnv* env, jclass cls) { // setInt(CMD_SET_SYSTEM_RESET, 1); - for (int idx = 0; idx < 3; idx++) { - if (Java_com_xypower_mpmaster_MpMasterService_setInt(env, cls, 202, 1) == 0) { - break; - } - } - + std::thread t([]() + { + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + for (int idx = 0; idx < 3; idx++) { + if (setGpioInt(202, 1) == 0) { + break; + } + } + }); + t.detach(); } extern "C" JNIEXPORT jintArray JNICALL