From 26ff735cbd5776e7ed5f7d7781b4a687fd78177d Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakobols@kth.se>
Date: Mon, 14 May 2018 09:40:57 +0200
Subject: [PATCH] work in progress, parser for APN profiles
---
libmobile.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/libmobile.c b/libmobile.c
index 85aa720..b46ef15 100644
--- a/libmobile.c
+++ b/libmobile.c
@@ -1,3 +1,12 @@
+/**
+ * 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"
struct string {
@@ -123,13 +132,48 @@ free_response:
free(response);
fail:
return -1;
-
success:
json_object_put(parsed_response);
free(response);
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 query[1024] = {0};
@@ -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");
}
+
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");
@@ -279,7 +324,6 @@ fail:
return NULL;
}
-
char *mobile_enable_pin(char *pin)
{
char query[1024] = {0};
--
GitLab