From 79b11a57e1c490a241cb71e087f98a1b812eadde Mon Sep 17 00:00:00 2001 From: Jakob Olsson <jakobols@kth.se> Date: Fri, 8 Jun 2018 12:48:49 +0200 Subject: [PATCH] some more features added to wrapper --- dongle_infrastructure.c | 11 ++++------- libmobile_hilink.h | 2 +- libmobile_wrapper.c | 30 ++++++++++++++++++++++++++++++ libmobile_wrapper.h | 4 ++++ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/dongle_infrastructure.c b/dongle_infrastructure.c index 1b4e024..7749049 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(global_dev->ip, pin, puk); + response = mobile_unlock_sim(global_dev, pin, puk); if (!response) goto fail_unknown; printf("did not survive the library\n"); @@ -421,7 +421,7 @@ int create_apn_profile(struct ubus_context *ctx, struct ubus_object *obj, goto fail_argument; } - response = mobile_create_apn_profile_zte(global_dev->ip, profile_name, wan_apn, pdp_type); + response = mobile_create_apn_profile(global_dev, profile_name, wan_apn, pdp_type); if (!response) goto fail_unknown; @@ -438,7 +438,7 @@ int show_current_apn(struct ubus_context *ctx, struct ubus_object *obj, { struct json_object *response; - response = mobile_get_current_apn_zte(global_dev->ip); + response = mobile_get_current_apn(global_dev); if (!response) goto fail_unknown; @@ -449,16 +449,13 @@ fail_unknown: } //dongle_network.. - -char *dongle_ip; - int get_signal_strength(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { struct json_object *response; - response = mobile_get_rssi_zte(global_dev->ip); + response = mobile_get_rssi(global_dev); if (!response) goto fail_unknown; diff --git a/libmobile_hilink.h b/libmobile_hilink.h index 343c97c..ae330f3 100644 --- a/libmobile_hilink.h +++ b/libmobile_hilink.h @@ -65,7 +65,7 @@ struct json_object *mobile_get_notification_hilink(); struct json_object *mobile_get_sms_count_hilink(); struct json_object *mobile_get_language_hilink(); -struct json_object *mobile_create_apn_profile(char *name, char *apn_name, char *username, char *password); +struct json_object *mobile_create_apn_profile_hilink(char *name, char *apn_name, char *username, char *password); struct json_object *mobile_set_apn_profile_default_hilink(char *name, char *apn_name, char *username, char *password); diff --git a/libmobile_wrapper.c b/libmobile_wrapper.c index 436b733..f619e43 100644 --- a/libmobile_wrapper.c +++ b/libmobile_wrapper.c @@ -88,4 +88,34 @@ struct json_object *mobile_set_apn_profile(struct device *dev, char *name) //return mobile_set_apn_profile_hilink(dev->ip, name); return NULL; +} + +struct json_object *mobile_create_apn_profile(struct device *dev, char *profile_name, char *wan_apn, char *pdp_type) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_create_apn_profile_zte(dev->ip, profile_name, wan_apn, pdp_type); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + //return mobile_create_apn_profile_hilink(dev->ip, profile_name, wan_apn, pdp_type); + + return NULL; +} + +struct json_object *mobile_get_current_apn(struct device *dev) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_get_current_apn_zte(dev->ip); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + //return mobile_get_current_apn_hilink(dev->ip); + + return NULL; +} + +struct json_object *mobile_get_rssi(struct device *dev) +{ + if (strcmp(dev->usb.if_name, "usb0") == 0) + return mobile_get_rssi_zte(dev->ip); + else if (strcmp(dev->usb.if_name, "eth5") == 0) + //return mobile_get_rssi_hilink(dev->ip); + + return NULL; } \ No newline at end of file diff --git a/libmobile_wrapper.h b/libmobile_wrapper.h index 58d7721..d3dec3a 100644 --- a/libmobile_wrapper.h +++ b/libmobile_wrapper.h @@ -27,7 +27,11 @@ 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_unlock_sim(struct device *dev, char *pin, char *puk); 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); +struct json_object *mobile_create_apn_profile(struct device *dev, char *profile_name, char *wan_apn, char *pdp_type); +struct json_object *mobile_get_current_apn(struct device *dev); +struct json_object *mobile_mobile_get_rssi(struct device *dev); #endif \ No newline at end of file -- GitLab