|
|
|
@ -17,6 +17,8 @@
|
|
|
|
|
// }
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <thread>
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
@ -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);
|
|
|
|
|
std::thread t([]()
|
|
|
|
|
{
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
|
|
|
|
for (int idx = 0; idx < 3; idx++) {
|
|
|
|
|
if (Java_com_xypower_mpmaster_MpMasterService_setInt(env, cls, 202, 1) == 0) {
|
|
|
|
|
if (setGpioInt(202, 1) == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
t.detach();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jintArray JNICALL
|
|
|
|
|