diff --git a/dongle.h b/dongle.h index 0e9416cb7770ed8c4bba6812c40c648d48b14e42..ce39be696a2da7c01adbcc4611bf21c6ec983744 100644 --- a/dongle.h +++ b/dongle.h @@ -1,5 +1,7 @@ #ifndef DONGLE_H #define DONGLE_H +#include "common.h" +#include "dongle_infrastructure.h" #include "stack_operations.h" /* struct USB { diff --git a/dongle_infrastructure.c b/dongle_infrastructure.c index 0fe8115124726db838fac6275155ed071576ff4a..1b4e024370795380644b17c12b89e327c1fffef9 100644 --- a/dongle_infrastructure.c +++ b/dongle_infrastructure.c @@ -303,7 +303,7 @@ int unlock_sim(struct ubus_context *ctx, struct ubus_object *obj, if (rv < 0) goto fail_input; printf("survived puk format\n"); - response = mobile_unlock_sim_zte(global_dev->ip, puk, pin); + response = mobile_unlock_sim(global_dev->ip, pin, puk); if (!response) goto fail_unknown; printf("did not survive the library\n"); @@ -320,7 +320,7 @@ int list_apn_profiles(struct ubus_context *ctx, struct ubus_object *obj, { struct json_object *response; - response = mobile_get_apn_profiles_zte(global_dev->ip); + response = mobile_get_apn_profiles(global_dev); if (!response) goto fail_unknown; @@ -351,7 +351,7 @@ int delete_apn_profile(struct ubus_context *ctx, struct ubus_object *obj, goto fail_argument; } - response = mobile_delete_apn_zte(global_dev->ip, name); + response = mobile_delete_apn_profile(global_dev, name); if (!response) goto fail_unknown; @@ -384,7 +384,7 @@ int set_apn_profile(struct ubus_context *ctx, struct ubus_object *obj, goto fail_argument; } - response = mobile_set_apn_profile_zte(global_dev->ip, name); + response = mobile_set_apn_profile(global_dev, name); if (!response) goto fail_unknown; @@ -575,11 +575,11 @@ struct ubus_method dynamic_object_methods[] = { UBUS_METHOD("verify_pin", verify_pin, pin_policy), UBUS_METHOD_NOARG("remaining_tries", remaining_tries), UBUS_METHOD("unlock_sim", unlock_sim, unlock_policy), - UBUS_METHOD_NOARG("list", list_apn_profiles), //apn - UBUS_METHOD("create", create_apn_profile, create_apn_policy), - UBUS_METHOD("delete", delete_apn_profile, apn_policy), - UBUS_METHOD("set_profile", set_apn_profile, apn_policy), - UBUS_METHOD_NOARG("current", show_current_apn), + UBUS_METHOD_NOARG("list_apn_profiles", list_apn_profiles), //apn + UBUS_METHOD("create_apn_profiles", create_apn_profile, create_apn_policy), + UBUS_METHOD("delete_apn_profile", delete_apn_profile, apn_policy), + UBUS_METHOD("set_apn_profile", set_apn_profile, apn_policy), + UBUS_METHOD_NOARG("current_apn_profile", show_current_apn), UBUS_METHOD_NOARG("signal_strength", get_signal_strength), //network.. UBUS_METHOD_NOARG("connect", connect_network), UBUS_METHOD_NOARG("disconnect", disconnect), diff --git a/libmobile_wrapper.c b/libmobile_wrapper.c index 7cfeec19a74834303a7d096b5ad94fdd16085e27..436b733cbc120ce2d9ec7ebfa21c75e98a981b6e 100644 --- a/libmobile_wrapper.c +++ b/libmobile_wrapper.c @@ -49,3 +49,43 @@ struct json_object *mobile_get_remaining_tries(struct device *dev) return NULL; } + +struct json_object *mobile_unlock_sim(struct device *dev, char *pin, char *puk) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_unlock_sim_zte(dev->ip, pin, puk); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + //return mobile_unlock_sim_hilink(dev->ip, pin, puk); + + return NULL; +} + +struct json_object *mobile_get_apn_profiles(struct device *dev) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_get_apn_profiles_zte(dev->ip); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + //return mobile_get_apn_profiles_hilink(dev->ip); + + return NULL; +} + +struct json_object *mobile_delete_apn_profile(struct device *dev, char *name) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_delete_apn_profile_zte(dev->ip, name); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + //return mobile_delete_apn_profile_hilink(dev->ip, name); + + return NULL; +} + +struct json_object *mobile_set_apn_profile(struct device *dev, char *name) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_set_apn_profile_zte(dev->ip, name); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + //return mobile_set_apn_profile_hilink(dev->ip, name); + + return NULL; +} \ No newline at end of file diff --git a/libmobile_wrapper.h b/libmobile_wrapper.h index 3c24490db2dbc76f804b74be0d27e2cd47caa368..58d772154b9d662cbef6fa66f8ac16b14958ea0f 100644 --- a/libmobile_wrapper.h +++ b/libmobile_wrapper.h @@ -27,4 +27,7 @@ struct json_object *mobile_disable_pin(struct device *dev, char *pin); struct json_object *mobile_verify_pin(struct device *dev, char *pin); struct json_object *mobile_enable_pin(struct device *dev, char *pin); struct json_object *mobile_get_remaining_tries(struct device *dev); +struct json_object *mobile_get_apn_profiles(struct device *dev); +struct json_object *mobile_delete_apn_profile(struct device *dev, char *name); +struct json_object *mobile_set_apn_profile(struct device *dev, char *name); #endif \ No newline at end of file diff --git a/libmobile_zte.c b/libmobile_zte.c index 42719e741ff15ccf96990a8285a95c013f5853ec..645eeb4145e1e34724407781db02bbf1b8bd8edf 100644 --- a/libmobile_zte.c +++ b/libmobile_zte.c @@ -387,7 +387,7 @@ struct json_object *mobile_disconnect_network_zte(char *ip_addr) return prepare_request(ip_addr, "isTest=false¬Callback=true&goformId=DISCONNECT_NETWORK", POST); } -struct json_object *mobile_delete_apn_zte(char *ip_addr, char *name) +struct json_object *mobile_delete_apn_profile_zte(char *ip_addr, char *name) { struct json_object *apn_profiles = mobile_get_apn_profiles_zte(ip_addr); char query[1024] = {0}; diff --git a/libmobile_zte.h b/libmobile_zte.h index da88ced3275f40417226717954d7afbf0166478c..089d4eefd06a432e506741d5121c2ee71b323aee 100644 --- a/libmobile_zte.h +++ b/libmobile_zte.h @@ -90,7 +90,7 @@ struct json_object *mobile_disconnect_network_zte(char *ip_addr); * A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -struct json_object *mobile_delete_apn_zte(char *ip_addr, char *name); +struct json_object *mobile_delete_apn_profile_zte(char *ip_addr, char *name); /** * Function: mobile_enable_roaming