I have made a patch to have gprs internet context available in gemalto
plugin. Reason behind this, is to have the same authentication
information available as with gprs, and could not wait for the rework
Giacinto is doing on gemalto plugin.


Maybe it is of some use, please feel free to comment on the code.


Looking forward to the work of Giacinto.


Please consider the environment before printing this email. This e-mail, and 
any files transmitted with it, is confidential and is intended solely for the 
use of the person or entity to whom it is addressed. If you have received this 
e-mail in error, please notify the sender and delete it from your records. On 
all our offers, sales and deliveries our General Terms of Delivery are 
applicable, excluding all other Terms and Conditions. Our terms have been 
deposited at the Chamber of commerce Eindhoven (The Netherlands), reference 
number 17065041, a copy of these terms is enclosed with all quotations, a 
hardcopy also can be send on your request. You can find our General Terms 
online at 
https://www.intemo.com/wp-content/uploads/2018/05/FHI-Algemene-Leveringsvoorwaarden-2014-ENGELS.pdf
 Op al onze aanbiedingen, verkopen en leveringen zijn, met uitsluiting van alle 
andere voorwaarden, onze algemene voorwaarden van toepassing. Deze zijn 
gedeponeerd bij de Kamer van Koophandel te Eindhoven onder nummer 17065041. Bij 
iedere offerte hoe ook verzonden zijn de algemene voorwaarden bijgevoegd, een 
kopie kan op aanvraag ook per post worden toegezonden. U kunt onze algemene 
voorwaarden online inzien op 
https://www.intemo.com/wp-content/uploads/2018/05/FHI-Algemene-Leveringsvoorwaarden-2014-NEDERLANDS.pdf
diff --git a/drivers/atmodem/lte.c b/drivers/atmodem/lte.c
index 8607286..efa4e5f 100644
--- a/drivers/atmodem/lte.c
+++ b/drivers/atmodem/lte.c
@@ -69,10 +69,10 @@ static void at_lte_set_default_attach_info(const struct ofono_lte *lte,
 	DBG("LTE config with APN: %s", info->apn);
 
 	if (strlen(info->apn) > 0)
-		snprintf(buf, sizeof(buf), "AT+CGDCONT=1,\"IP\",\"%s\"",
+		snprintf(buf, sizeof(buf), "AT+CGDCONT=0,\"IP\",\"%s\"",
 				info->apn);
 	else
-		snprintf(buf, sizeof(buf), "AT+CGDCONT=1,\"IP\"");
+		snprintf(buf, sizeof(buf), "AT+CGDCONT=0,\"IP\"");
 
 	/* We can't do much in case of failure so don't check response. */
 	if (g_at_chat_send(ldd->chat, buf, NULL,
diff --git a/include/lte.h b/include/lte.h
index 5837abe..ef84ab9 100644
--- a/include/lte.h
+++ b/include/lte.h
@@ -26,27 +26,14 @@
 extern "C" {
 #endif
 
-#define OFONO_LTE_MAX_APN_LENGTH 100
-#define OFONO_LTE_MAX_USERNAME_LENGTH 63
-#define OFONO_LTE_MAX_PASSWORD_LENGTH 255
-
 #include <ofono/types.h>
-#include <gdbus.h>
 
-enum ofono_lte_auth_method {
-	OFONO_LTE_AUTH_METHOD_CHAP = 0,
-	OFONO_LTE_AUTH_METHOD_PAP,
-};
+struct ofono_lte;
 
 struct ofono_lte_default_attach_info {
-	char apn[OFONO_LTE_MAX_APN_LENGTH + 1];
-	char username[OFONO_LTE_MAX_USERNAME_LENGTH + 1];
-	char password[OFONO_LTE_MAX_PASSWORD_LENGTH + 1];
-	enum ofono_lte_auth_method auth_method;
+	char apn[OFONO_GPRS_MAX_APN_LENGTH + 1];
 };
 
-struct ofono_lte;
-
 typedef void (*ofono_lte_cb_t)(const struct ofono_error *error, void *data);
 
 struct ofono_lte_driver {
@@ -74,8 +61,6 @@ void ofono_lte_set_data(struct ofono_lte *lte, void *data);
 
 void *ofono_lte_get_data(const struct ofono_lte *lte);
 
-struct ofono_lte_default_attach_info *ofono_lte_get_default_attach_info(struct ofono_lte *lte);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 1ffc9d6..b773412 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -26,7 +26,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <stdint.h>
-#include <stdio.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -47,7 +46,6 @@
 #include <ofono/sms.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
-#include <ofono/lte.h>
 #include <ofono/location-reporting.h>
 
 #include <drivers/atmodem/atutil.h>
@@ -64,8 +62,6 @@ static const char *none_prefix[] = { NULL };
 static const char *sctm_prefix[] = { "^SCTM:", NULL };
 static const char *sbv_prefix[] = { "^SBV:", NULL };
 
-struct ofono_lte *lte = NULL;
-
 struct gemalto_hardware_monitor {
 	DBusMessage *msg;
 	int32_t temperature;
@@ -500,21 +496,21 @@ static int gemalto_enable(struct ofono_modem *modem)
 	return -EINPROGRESS;
 }
 
-/* static void gemalto_smso_cb(gboolean ok, GAtResult *result, gpointer user_data) */
-/* { */
-/* 	struct ofono_modem *modem = user_data; */
-/* 	struct gemalto_data *data = ofono_modem_get_data(modem); */
+static void gemalto_smso_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct gemalto_data *data = ofono_modem_get_data(modem);
 
-/* 	DBG(""); */
+	DBG("");
 
-/* 	g_at_chat_unref(data->mdm); */
-/* 	data->mdm = NULL; */
-/* 	g_at_chat_unref(data->app); */
-/* 	data->app = NULL; */
+	g_at_chat_unref(data->mdm);
+	data->mdm = NULL;
+	g_at_chat_unref(data->app);
+	data->app = NULL;
 
-/* 	if (ok) */
-/* 		ofono_modem_set_powered(modem, FALSE); */
-/* } */
+	if (ok)
+		ofono_modem_set_powered(modem, FALSE);
+}
 
 static int gemalto_disable(struct ofono_modem *modem)
 {
@@ -532,11 +528,9 @@ static int gemalto_disable(struct ofono_modem *modem)
 		ofono_modem_remove_interface(modem,
 				HARDWARE_MONITOR_INTERFACE);
 
-	// On every ofono restart the modem needs a hard reset, disable this.
-
 	/* Shutdown the modem */
-	/* g_at_chat_send(data->app, "AT^SMSO", none_prefix, gemalto_smso_cb, */
-	/* 		modem, NULL); */
+	g_at_chat_send(data->app, "AT^SMSO", none_prefix, gemalto_smso_cb,
+			modem, NULL);
 
 	return -EINPROGRESS;
 }
@@ -557,28 +551,10 @@ static void gemalto_set_online(struct ofono_modem *modem, ofono_bool_t online,
 {
 	struct gemalto_data *data = ofono_modem_get_data(modem);
 	struct cb_data *cbd = cb_data_new(cb, user_data);
-	char command_auth[100];
-	int auth_method = 2;	// 1 = pap, 2 = chap
 	char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
 
 	DBG("modem %p %s", modem, online ? "online" : "offline");
 
-	if (online && lte) {
-		struct ofono_lte_default_attach_info *attach = ofono_lte_get_default_attach_info(lte);
-
-		switch (attach->auth_method) {
-			case OFONO_LTE_AUTH_METHOD_PAP:
-				auth_method = 1;
-				break;
-			case OFONO_LTE_AUTH_METHOD_CHAP:
-				auth_method = 2;
-				break;
-		}
-		snprintf(command_auth, sizeof(command_auth), "AT^SGAUTH=1,%d,\"%s\",\"%s\"",
-				auth_method, attach->username, attach->password);
-		g_at_chat_send(data->app, command_auth, NULL, NULL, NULL, NULL);
-	}
-
 	if (g_at_chat_send(data->app, command, NULL, set_online_cb, cbd, g_free))
 		return;
 
@@ -621,9 +597,9 @@ static void gemalto_post_sim(struct ofono_modem *modem)
 	if (gprs && gc)
 		ofono_gprs_add_context(gprs, gc);
 
-	if (!g_strcmp0(model, GEMALTO_MODEL_ALS3_PLS8x)) {
-		lte = ofono_lte_create(modem, OFONO_VENDOR_CINTERION, "atmodem", data->app);
-	}
+	if (!g_strcmp0(model, GEMALTO_MODEL_ALS3_PLS8x))
+		ofono_lte_create(modem, OFONO_VENDOR_CINTERION,
+						"atmodem", data->app);
 }
 
 static void gemalto_post_online(struct ofono_modem *modem)
diff --git a/src/lte.c b/src/lte.c
index a716451..a6d26b3 100644
--- a/src/lte.c
+++ b/src/lte.c
@@ -41,14 +41,6 @@
 #define SETTINGS_GROUP "Settings"
 #define DEFAULT_APN_KEY "DefaultAccessPointName"
 
-// Use GPRS settings to connect with lte
-#define SETTINGS_CTX_APN "AccessPointName"
-#define SETTINGS_CTX_USR_KEY "Username"
-#define SETTINGS_CTX_PASSW_KEY "Password"
-#define SETTINGS_CTX_AUTH_KEY "AuthenticationMethod"
-
-static GSList *g_drivers = NULL;
-
 struct ofono_lte {
 	const struct ofono_lte_driver *driver;
 	void *driver_data;
@@ -60,22 +52,11 @@ struct ofono_lte {
 	struct ofono_lte_default_attach_info info;
 };
 
-struct ofono_lte_default_attach_info *ofono_lte_get_default_attach_info(struct ofono_lte *lte)
-{
-	//ofono_lte_default_attach_info *tmp = lte->info;
-	return &(lte->info);
-}
+static GSList *g_drivers = NULL;
 
 static void lte_load_settings(struct ofono_lte *lte)
 {
-	GKeyFile *gprs_settings;
-	char **config_file_groups;
-	int group_index;
-	gboolean found = FALSE;
 	char *apn;
-	char *user;
-	char *passw;
-	char *auth;
 
 	if (lte->imsi == NULL)
 		return;
@@ -94,74 +75,6 @@ static void lte_load_settings(struct ofono_lte *lte)
 		strcpy(lte->info.apn, apn);
 		g_free(apn);
 	}
-
-	// Context settings are stored in 'gprs' settings file
-	// ---------------------------------------------------
-	gprs_settings = storage_open(lte->imsi, "gprs");
-
-	if (gprs_settings == NULL) {
-		ofono_error("LTE: Can't open gprs setting file for internet context");
-		return;
-	}
-
-	// Find group with internet context
-	config_file_groups = g_key_file_get_groups(gprs_settings, NULL);
-	for (group_index = 0; config_file_groups[group_index]; group_index++) {
-		if (g_str_has_prefix(config_file_groups[group_index], "context")) {
-			char* type = g_key_file_get_string(gprs_settings,
-					config_file_groups[group_index], "Type",NULL);
-			if (type) {
-				if (strcmp(type, "internet") == 0) {
-					found = TRUE;
-					g_free(type);
-					break;
-				}
-				g_free(type);
-			}
-		}
-	}
-	if (!found)
-		goto exit;
-
-	// LTE has not apn, Lets load the one from GPRS context
-	if (!apn) {
-		apn = g_key_file_get_string(gprs_settings,
-				config_file_groups[group_index], SETTINGS_CTX_APN, NULL);
-		if (apn) {
-			strcpy(lte->info.apn, apn);
-			g_free(apn);
-		}
-	}
-
-	user = g_key_file_get_string(gprs_settings,
-			config_file_groups[group_index], SETTINGS_CTX_USR_KEY, NULL);
-	if (user) {
-		strcpy(lte->info.username, user);
-		g_free(user);
-	}
-
-	passw = g_key_file_get_string(gprs_settings,
-			config_file_groups[group_index], SETTINGS_CTX_PASSW_KEY, NULL);
-	if (passw) {
-		strcpy(lte->info.password, passw);
-		g_free(passw);
-	}
-
-	auth = g_key_file_get_string(gprs_settings,
-			config_file_groups[group_index], SETTINGS_CTX_AUTH_KEY, NULL);
-	if (auth) {
-		if (strcmp(auth, "pap") == 0) {
-			lte->info.auth_method = OFONO_LTE_AUTH_METHOD_PAP;
-		}
-		if (strcmp(auth, "chap") == 0) {
-			lte->info.auth_method = OFONO_LTE_AUTH_METHOD_CHAP;
-		}
-		g_free(auth);
-	}
-
-
-exit:
-	storage_close(lte->imsi, "gprs", gprs_settings, FALSE);
 }
 
 static DBusMessage *lte_get_properties(DBusConnection *conn,
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to