Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mdmngr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IOPSYS
mdmngr
Commits
26ff735c
Commit
26ff735c
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
work in progress, parser for APN profiles
parent
9a740800
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libmobile.c
+46
-2
46 additions, 2 deletions
libmobile.c
with
46 additions
and
2 deletions
libmobile.c
+
46
−
2
View file @
26ff735c
/**
* 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
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment