// Write C++ code here. // // Do not forget to dynamically load the C++ library into your application. // // For instance, // // In MainActivity.java: // static { // System.loadLibrary("mpmaster"); // } // // Or, in MainActivity.kt: // companion object { // init { // System.loadLibrary("mpmaster") // } // } #include #include #include #include #include #define IOT_PARAM_WRITE 0xAE #define IOT_PARAM_READ 0xAF #define MAX_STRING_LEN 32 typedef struct { int cmd; int value; int result; long value2; char str[MAX_STRING_LEN]; }IOT_PARAM; extern "C" JNIEXPORT jint JNICALL Java_com_xypower_mpmaster_MpMasterService_getInt(JNIEnv* env, jclass cls, jint cmd) { int fd = open("/dev/mtkgpioctrl", O_RDONLY); // LOGE("get_int fd=%d,cmd=%d\r\n",fd, cmd); if( fd > 0 ) { IOT_PARAM param; param.cmd = cmd; ioctl(fd, IOT_PARAM_READ, ¶m); #ifdef _DEBUG ALOGI("getInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result); #endif close(fd); return param.value; } return -1; }