优化运维功能
parent
8c4f7faee1
commit
e57843cdb0
@ -0,0 +1,49 @@
|
||||
|
||||
# For more information about using CMake with Android Studio, read the
|
||||
# documentation: https://d.android.com/studio/projects/add-native-code.html
|
||||
|
||||
# Sets the minimum version of CMake required to build the native library.
|
||||
|
||||
cmake_minimum_required(VERSION 3.18.1)
|
||||
|
||||
# Declares and names the project.
|
||||
|
||||
project("mpmaster")
|
||||
|
||||
# Creates and names a library, sets it as either STATIC
|
||||
# or SHARED, and provides the relative paths to its source code.
|
||||
# You can define multiple libraries, and CMake builds them for you.
|
||||
# Gradle automatically packages shared libraries with your APK.
|
||||
|
||||
add_library( # Sets the name of the library.
|
||||
mpmaster
|
||||
|
||||
# Sets the library as a shared library.
|
||||
SHARED
|
||||
|
||||
# Provides a relative path to your source file(s).
|
||||
mpmaster.cpp )
|
||||
|
||||
# Searches for a specified prebuilt library and stores the path as a
|
||||
# variable. Because CMake includes system libraries in the search path by
|
||||
# default, you only need to specify the name of the public NDK library
|
||||
# you want to add. CMake verifies that the library exists before
|
||||
# completing its build.
|
||||
|
||||
find_library( # Sets the name of the path variable.
|
||||
log-lib
|
||||
|
||||
# Specifies the name of the NDK library that
|
||||
# you want CMake to locate.
|
||||
log )
|
||||
|
||||
# Specifies libraries CMake should link to your target library. You
|
||||
# can link multiple libraries, such as libraries you define in this
|
||||
# build script, prebuilt third-party libraries, or system libraries.
|
||||
|
||||
target_link_libraries( # Specifies the target library.
|
||||
mpmaster
|
||||
|
||||
# Links the target library to the log library
|
||||
# included in the NDK.
|
||||
${log-lib} )
|
@ -0,0 +1,54 @@
|
||||
// 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 <jni.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue