Skip to content
Snippets Groups Projects
Commit 26ff735c authored by Jakob Olsson's avatar Jakob Olsson
Browse files

work in progress, parser for APN profiles

parent 9a740800
No related branches found
No related tags found
No related merge requests found
/**
* TODO:
* 1. Add parsing for displaying APN profiles available to make sense of them
* 2. Add more input options when creating APN profile
* 3. Seperate "set default" and "apply" APN profiles (what is the difference anyway?)
* 4. Make the APN parsed fields more dynamic
*/
#include "libmobile.h" #include "libmobile.h"
struct string { struct string {
...@@ -123,13 +132,48 @@ free_response: ...@@ -123,13 +132,48 @@ free_response:
free(response); free(response);
fail: fail:
return -1; return -1;
success: success:
json_object_put(parsed_response); json_object_put(parsed_response);
free(response); free(response);
return len; return len;
} }
struct json_object *parse_apn_profiles(char *apn_profiles)
{
if (strlen(apn_profiles) <= 0) {
DEBUG("No APN profiles provided!\n");
goto fail;
}
struct json_object *apn_profiles_json = json_tokener_parse(apn_profiles);
if (!apn_profiles_json) {
DEBUG("Not valid json!\n");
goto fail;
}
struct json_object *parsed_profiles = json_object_new_object();
json_object_object_foreach(apn_profiles_json, key, val) {
char *apn = json_object_get_string(val);
if (strlen(apn) <= 0)
goto finished;
char fields[13] = {"profile_name", "apn_name", "mode", "dunno", "authentication", "username?", "password?", "IPdunno", "ddnunno?", "dno", "DNS_mode", "IPv_username", "IPv_password"};
int field_counter = 0;
}
free_object:
json_object_put(apn_profiles);
json_object_put(parsed_profiles);
fail:
return NULL;
finished:
return parsed_profiles;
}
char *mobile_connect_network(void) char *mobile_connect_network(void)
{ {
char query[1024] = {0}; char query[1024] = {0};
...@@ -222,6 +266,7 @@ char *mobile_get_modem_state(void) ...@@ -222,6 +266,7 @@ char *mobile_get_modem_state(void)
{ {
return mobile_get_request("&sms_received_flag_flag=0&sts_received_flag_flag=0&cmd=modem_main_state%2Cpin_status%2Cloginfo%2Cnew_version_state%2Ccurrent_upgrade_state%2Cis_mandatory%2Csms_received_flag%2Csts_received_flag%2Csignalbar%2Cnetwork_type%2Cnetwork_provider%2Cppp_status%2CEX_SSID1%2Cex_wifi_status%2CEX_wifi_profile%2Cm_ssid_enable%2Csms_unread_num%2CRadioOff%2Csimcard_roam%2Clan_ipaddr%2Cstation_mac%2Cbattery_charging%2Cbattery_vol_percent%2Cbattery_pers%2Cspn_display_flag%2Cplmn_display_flag%2Cspn_name_data%2Cspn_b1_flag%2Cspn_b2_flag%2Crealtime_tx_bytes%2Crealtime_rx_bytes%2Crealtime_time%2Crealtime_tx_thrpt%2Crealtime_rx_thrpt%2Cmonthly_rx_bytes%2Cmonthly_tx_bytes%2Cmonthly_time%2Cdate_month%2Cdata_volume_limit_switch%2Cdata_volume_limit_size%2Cdata_volume_alert_percent%2Cdata_volume_limit_unit%2Croam_setting_option%2Cupg_roam_switch%2Chplmn"); return mobile_get_request("&sms_received_flag_flag=0&sts_received_flag_flag=0&cmd=modem_main_state%2Cpin_status%2Cloginfo%2Cnew_version_state%2Ccurrent_upgrade_state%2Cis_mandatory%2Csms_received_flag%2Csts_received_flag%2Csignalbar%2Cnetwork_type%2Cnetwork_provider%2Cppp_status%2CEX_SSID1%2Cex_wifi_status%2CEX_wifi_profile%2Cm_ssid_enable%2Csms_unread_num%2CRadioOff%2Csimcard_roam%2Clan_ipaddr%2Cstation_mac%2Cbattery_charging%2Cbattery_vol_percent%2Cbattery_pers%2Cspn_display_flag%2Cplmn_display_flag%2Cspn_name_data%2Cspn_b1_flag%2Cspn_b2_flag%2Crealtime_tx_bytes%2Crealtime_rx_bytes%2Crealtime_time%2Crealtime_tx_thrpt%2Crealtime_rx_thrpt%2Cmonthly_rx_bytes%2Cmonthly_tx_bytes%2Cmonthly_time%2Cdate_month%2Cdata_volume_limit_switch%2Cdata_volume_limit_size%2Cdata_volume_alert_percent%2Cdata_volume_limit_unit%2Croam_setting_option%2Cupg_roam_switch%2Chplmn");
} }
char *mobile_get_apn_profiles(void) char *mobile_get_apn_profiles(void)
{ {
return mobile_get_request("APN_config0,APN_config1,APN_config2,APN_config3,APN_config4,APN_config5,APN_config6,APN_config7,APN_config8,APN_config9,APN_config10,APN_config11,APN_config12,APN_config13,APN_config14,APN_config15,APN_config16,APN_config17,APN_config18,APN_config19"); return mobile_get_request("APN_config0,APN_config1,APN_config2,APN_config3,APN_config4,APN_config5,APN_config6,APN_config7,APN_config8,APN_config9,APN_config10,APN_config11,APN_config12,APN_config13,APN_config14,APN_config15,APN_config16,APN_config17,APN_config18,APN_config19");
...@@ -279,7 +324,6 @@ fail: ...@@ -279,7 +324,6 @@ fail:
return NULL; return NULL;
} }
char *mobile_enable_pin(char *pin) char *mobile_enable_pin(char *pin)
{ {
char query[1024] = {0}; char query[1024] = {0};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment