| #include <stdio.h> |
| #include <unistd.h> |
| #include <dlfcn.h> |
| #include <stdlib.h> |
| #include <stdint.h> |
| #include <string.h> |
| #include "lynq_sdk_ready.h" |
| |
| int (*sdk_ready_register)(const int uToken,const lynq_sdk_check_param_t* param,lynq_sdk_status_cb sdk_status_cb); |
| int (*get_sdk_ready_status)(int *status); |
| |
| |
| int demo_sdk_status_cb(const lynq_sdk_ready_t *sdk_ready, void *reserve) |
| { |
| printf("sdk_ready_status:%d,ref_action:%d\n",sdk_ready->sdk_ready_status,sdk_ready->ref_action); |
| return 0; |
| } |
| |
| void help() |
| { |
| printf("help:\n\ |
| argv[1]:isvalid(0/1)\n\ |
| argv[2]:boot\n\ |
| argv[3]:GNSS-MIN:60\n\ |
| argv[4]:MD-MIN:30\n\ |
| argv[5]:PTN-MIN:120\n\ |
| argv[6]:RIL-MIN:10\n\ |
| argv[7]:SYS-MIN:120\n\ |
| argv[8]:INTR\n\ |
| argv[9]:LOAD_AVG\n"); |
| return; |
| } |
| void print_binary(int num) { |
| int i; |
| for (i = sizeof(num) * 8 - 1; i >= 0; i--) { |
| printf("%d", (num >> i) & 1); |
| } |
| printf("\n"); |
| } |
| int main(int argc, char **argv) |
| { |
| printf("lynq-sdk-ready begin"); |
| lynq_sdk_check_param_t param; |
| void *dlHandle; |
| int bit_sdk_ready_status = 0; |
| memset(¶m,0,sizeof(lynq_sdk_check_param_t)); |
| const char *lynqLibPath = "/lib64/liblynq-sdk-ready.so"; |
| dlHandle = dlopen(lynqLibPath, RTLD_NOW); |
| if (dlHandle == NULL) |
| { |
| printf("dlopen dlHandle_call failed: %s", dlerror()); |
| exit(EXIT_FAILURE); |
| } |
| sdk_ready_register = (int(*)(const int uToken,const lynq_sdk_check_param_t* param,lynq_sdk_status_cb sdk_status_cb))dlsym(dlHandle, "lynq_sdk_ready_register"); |
| if (sdk_ready_register == NULL) { |
| printf("lynq_init_call not defined or exported in %s", lynqLibPath); |
| exit(EXIT_FAILURE); |
| } |
| get_sdk_ready_status = (int(*)(int *status))dlsym(dlHandle, "lynq_get_sdk_ready_status"); |
| if (get_sdk_ready_status == NULL) { |
| printf("lynq_init_call not defined or exported in %s", lynqLibPath); |
| exit(EXIT_FAILURE); |
| } |
| help(); |
| if(argc >= 2) |
| { |
| if(atoi(argv[1])==1 && argc >=10) |
| { |
| param.isvalid = atoi(argv[1]); |
| param.period.BOOT = atoi(argv[2]); |
| param.period.GNSS = atoi(argv[3]); |
| param.period.MD = atoi(argv[4]); |
| param.period.PTN = atoi(argv[5]); |
| param.period.RIL = atoi(argv[6]); |
| param.period.SYS = atoi(argv[7]); |
| param.threshold.interrupts = atoi(argv[8]); |
| param.threshold.load_average = atoi(argv[9]); |
| } |
| } |
| printf("You input param:\n\ |
| param.isvalid:%d\n\ |
| param.period.BOOT:%d\n\ |
| param.period.GNSS:%d\n\ |
| param.period.MD:%d\n\ |
| param.period.PTN:%d\n\ |
| param.period.RIL:%d\n\ |
| param.period.SYS:%d\n\ |
| param.threshold.interrupts:%llu\n\ |
| param.threshold.load_average:%d\n",param.isvalid, |
| param.period.BOOT, |
| param.period.GNSS, |
| param.period.MD, |
| param.period.PTN, |
| param.period.RIL, |
| param.period.SYS, |
| param.threshold.interrupts, |
| param.threshold.load_average); |
| sdk_ready_register(1024,¶m,demo_sdk_status_cb); |
| while (1) |
| { |
| sleep(30); |
| get_sdk_ready_status(&bit_sdk_ready_status);//需要的时候调用,不是必选项 |
| print_binary(bit_sdk_ready_status); |
| } |
| return 0; |
| } |