diff mbox series

[v2,18/18] lte: Write provisioned info to disk

Message ID 20240202225405.993792-18-denkenz@gmail.com (mailing list archive)
State Accepted
Commit 53c13ead095cb4c47421f335a26cdd7bf407008b
Headers show
Series [v2,01/18] umlrunner: Also mount /var/lib as tmpfs | expand

Commit Message

Denis Kenzior Feb. 2, 2024, 10:53 p.m. UTC
If provisioning succeeded, then save the information to disk.  Next time
the modem is powered, the saved information will be used instead of
being obtained via provisioning.
---
 src/lte.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/lte.c b/src/lte.c
index 706d596b59b2..05491c3a1391 100644
--- a/src/lte.c
+++ b/src/lte.c
@@ -450,11 +450,37 @@  static void spn_read_cb(const char *spn, const char *dc, void *data)
 	struct ofono_lte *lte = data;
 	struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom);
 	struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
+	bool r;
 
 	ofono_sim_remove_spn_watch(sim, &lte->spn_watch);
 
-	provision_default_attach_info(lte, ofono_sim_get_mcc(sim),
-					ofono_sim_get_mnc(sim), spn);
+	r = provision_default_attach_info(lte, ofono_sim_get_mcc(sim),
+						ofono_sim_get_mnc(sim), spn);
+	if (r) {
+		const char *str;
+
+		if (lte->info.apn[0])
+			l_settings_set_string(lte->settings, SETTINGS_GROUP,
+						LTE_APN, lte->info.apn);
+
+		if (lte->info.username[0])
+			l_settings_set_string(lte->settings, SETTINGS_GROUP,
+					LTE_USERNAME, lte->info.username);
+
+		if (lte->info.password[0])
+			l_settings_set_string(lte->settings, SETTINGS_GROUP,
+					LTE_PASSWORD, lte->info.password);
+
+		str = gprs_proto_to_string(lte->info.proto);
+		l_settings_set_string(lte->settings, SETTINGS_GROUP,
+					LTE_PROTO, str);
+
+		str = gprs_auth_method_to_string(lte->info.auth_method);
+		l_settings_set_string(lte->settings, SETTINGS_GROUP,
+					LTE_AUTH_METHOD, str);
+
+		lte_save_settings(lte);
+	}
 
 	if (lte->driver->set_default_attach_info) {
 		lte->driver->set_default_attach_info(lte, &lte->info,