diff --git a/common.h b/common.h index 9f9a49b34077173fcde2348b0e2424cc6ddc2423..94e15db93ba7d82b1abbf869141c56b4dc2d7a5e 100644 --- a/common.h +++ b/common.h @@ -23,8 +23,7 @@ #include <libxml/xpath.h> #include <libxml/xpathInternals.h> -//#include "libmobile_hilink.h" -#include "libmobile_zte.h" +#include "libmobile_wrapper.h" extern int debug; extern char *global_ip_addr; diff --git a/dongle.h b/dongle.h index 2dbbc90ececb3982b49da311f2edb651874a8d13..0e9416cb7770ed8c4bba6812c40c648d48b14e42 100644 --- a/dongle.h +++ b/dongle.h @@ -1,7 +1,7 @@ #ifndef DONGLE_H #define DONGLE_H #include "stack_operations.h" - +/* struct USB { char *product; char *product_id; @@ -18,7 +18,7 @@ struct device { int missing; //counter bool present; }; - +*/ void uloop_add_get_devices(struct uloop_timeout *t); int get_devices(void); int devices_status(struct uloop_timeout *t); diff --git a/libmobile_wrapper.c b/libmobile_wrapper.c index ed432dae402b63aac30c1a6aaa3ccb14f0a5da17..a1cf901563b52996c7e7abdcd967d7161a37dc3c 100644 --- a/libmobile_wrapper.c +++ b/libmobile_wrapper.c @@ -1,34 +1,52 @@ -#include <stdio.h> +#include "libmobile_hilink.h" +#include "libmobile_zte.h" -typedef struct write_result *(*func_ptr)(char *, char *); - -//Example... -struct write_result *mobile_pin_set_zte(char *current_pin, char *new_pin) +struct json_object *mobile_set_pin(struct device *dev, char *current_pin, char *new_pin) { - return pin_action("03", current_pin, new_pin, ""); -} - + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_set_pin_zte(dev->usb.ip, current_pin, new_pin); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + return mobile_set_pin_hilink(); -struct write_result *mobile_pin_set_hilink(char *current_pin, char *new_pin) -{ - return pin_action("03", current_pin, new_pin, ""); + return NULL; } +struct json_object *mobile_disable_pin(struct device *dev, char *pin) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_disable_pin_zte(dev->usb.ip, pin); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + return mobile_disable_pin_hilink(dev->usb.ip, pin); + return NULL; +} - -struct write_result *mobile_pin_set(char *dongle, char *current_pin, char *new_pin) +struct json_object *mobile_verify_pin(struct device *dev, char *pin) { - func_ptr mobile_pin_set_impl = NULL; + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_verify_pin_zte(dev->usb.ip, pin); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + return mobile_verify_pin_hilink(dev->usb.ip, pin); - if (strcmp(dongle, "zte") == 0) - mobile_pin_set_impl = mobile_pin_set_zte; + return NULL; +} - if (strcmp(dongle, "hilink") == 0) - mobile_pin_set_impl = mobile_pin_set_hilink; +struct json_object *mobile_enable_pin(struct device *dev, char *pin) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_enable_pin_zte(dev->usb.ip, pin); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + return mobile_enable_pin_hilink(dev->usb.ip, pin); - if (mobile_pin_set_impl) - mobile_pin_set_impl(current_pin, new_pin); + return NULL; } +struct json_object *mobile_get_remaining_tries(struct device *dev) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_get_remaining_tries_zte(dev->usb.ip); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + return mobile_get_remaining_tries_hilink(dev->usb.ip); + return NULL; +} diff --git a/libmobile_wrapper.h b/libmobile_wrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..612c9713fc7608aabf9ca0fbaa01bcbedd7b64c3 --- /dev/null +++ b/libmobile_wrapper.h @@ -0,0 +1,19 @@ +#include <libubox/list.h> + +/* ORIGINALLY FROM DONGLE.H - WHERE DOES IT BELONG? */ +struct USB { + char *product; + char *product_id; + char *vendor_id; + char *if_name; +}; + +struct device { + struct list_head list; + struct ubus_object *ubus_obj; + + struct USB usb; + char *ip; + int missing; //counter + bool present; +}; \ No newline at end of file