From 7742ad238cad10d76c3d3b21d243c0824d44c69d Mon Sep 17 00:00:00 2001 From: Arun Muthusamy <arun.muthusamy@inteno.se> Date: Fri, 8 Jun 2018 12:41:47 +0200 Subject: [PATCH] Add Network enable/disable call --- libmobile_hilink.c | 40 ++++++++++++++++++++++++++++++++++++++++ libmobile_hilink.h | 4 ++++ 2 files changed, 44 insertions(+) diff --git a/libmobile_hilink.c b/libmobile_hilink.c index 2ed6efc..85cc645 100644 --- a/libmobile_hilink.c +++ b/libmobile_hilink.c @@ -950,3 +950,43 @@ fail_converter: fail_result: return NULL; } + +struct json_object *network_action(int action) +{ + char *api_url = "http://192.168.8.1/api/dialup/dial"; + char post_query[128]; + struct write_result *result; + struct json_object *result_json; + + snprintf(post_query, 128, "<request><Action>%d</Action></request>", action); + + result = post_request(sess_tok_url, api_url, post_query); + if (!result) + goto fail_result; + + result_json = xml_to_json_converter(result); + if(!result_json) + goto fail_converter; + + if (result) + free(result); + + return result_json; + +fail_converter: + free(result); +fail_result: + return NULL; +} + + +struct json_object *mobile_connect_network_hilink() +{ + return network_action(ENABLE); +} + + +struct json_object *mobile_disconnect_network_hilink() +{ + return network_action(DISABLE); +} diff --git a/libmobile_hilink.h b/libmobile_hilink.h index ae330f3..13d882c 100644 --- a/libmobile_hilink.h +++ b/libmobile_hilink.h @@ -100,6 +100,10 @@ struct json_object *mobile_pin_set_hilink(char *current_pin, char *new_pin); struct json_object *mobile_set_language_hilink(char *language_name); +struct json_object *mobile_connect_network_hilink(); + +struct json_object *mobile_disconnect_network_hilink(); + #endif -- GitLab