diff --git a/libmobile_hilink.c b/libmobile_hilink.c index 2ed6efcb8ab3bb4c1507ad2af016812f61cf2fb7..85cc645484fd4d2a7f1b7315128a3e3f6002290a 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 ae330f3c30fca448abbd04d38b8b12e7ec03b048..13d882c1a70058a80babc0f4b2dd0a5eb3119254 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