Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 01/10] sim7100: simplify serial device opening
@ 2024-04-30 11:52 Martin Hundebøll
  2024-04-30 11:52 ` [PATCH 02/10] sim7100: wait for modem to start while enabling Martin Hundebøll
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Martin Hundebøll @ 2024-04-30 11:52 UTC (permalink / raw)
  To: ofono; +Cc: Martin Hundebøll, MaxLyubimov

Replace the g_at_{tty,syntax,chat} dance with a single call to
g_at_util_open_device().
---
 plugins/sim7100.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/plugins/sim7100.c b/plugins/sim7100.c
index c461cc32..4a1ac782 100644
--- a/plugins/sim7100.c
+++ b/plugins/sim7100.c
@@ -57,6 +57,7 @@
 #include <ofono/gprs-context.h>
 
 #include <drivers/atmodem/vendor.h>
+#include <drivers/atmodem/atutil.h>
 
 struct sim7100_data {
 	GAtChat *at;
@@ -67,7 +68,7 @@ static void sim7100_debug(const char *str, void *user_data)
 {
 	const char *prefix = user_data;
 
-	ofono_info("%s%s", prefix, str);
+	ofono_info("%s: %s", prefix, str);
 }
 
 /* Detect hardware, and initialize if found */
@@ -115,36 +116,14 @@ static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data)
 		ofono_modem_set_powered(modem, TRUE);
 }
 
-static int open_device(struct ofono_modem *modem, const char *devkey,
-			GAtChat **chatp)
+static int open_device(struct ofono_modem *modem, char *devkey, GAtChat **chat)
 {
-	GIOChannel *channel;
-	GAtSyntax *syntax;
-	GAtChat *chat;
-	const char *device;
-
 	DBG("devkey=%s", devkey);
 
-	device = ofono_modem_get_string(modem, devkey);
-	if (device == NULL)
-		return -EINVAL;
-
-	channel = g_at_tty_open(device, NULL);
-	if (channel == NULL)
+	*chat = at_util_open_device(modem, devkey, sim7100_debug, devkey, NULL);
+	if (*chat == NULL)
 		return -EIO;
 
-	syntax = g_at_syntax_new_gsm_permissive();
-	chat = g_at_chat_new(channel, syntax);
-	g_at_syntax_unref(syntax);
-	g_io_channel_unref(channel);
-
-	if (chat == NULL)
-		return -EIO;
-
-	if (getenv("OFONO_AT_DEBUG"))
-		g_at_chat_set_debug(chat, sim7100_debug, "");
-
-	*chatp = chat;
 	return 0;
 }
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-05-23 13:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 11:52 [PATCH 01/10] sim7100: simplify serial device opening Martin Hundebøll
2024-04-30 11:52 ` [PATCH 02/10] sim7100: wait for modem to start while enabling Martin Hundebøll
2024-04-30 11:52 ` [PATCH 03/10] sim7100: query device model during enable Martin Hundebøll
2024-05-02 14:04   ` Denis Kenzior
2024-04-30 11:52 ` [PATCH 04/10] sim7100: implement set_online() Martin Hundebøll
2024-04-30 11:52 ` [PATCH 05/10] sim7100: fix going offline for A76XX modems Martin Hundebøll
2024-04-30 11:52 ` [PATCH 06/10] atmodem: introduce SIMCom A76XX vendor quirks Martin Hundebøll
2024-04-30 11:52 ` [PATCH 07/10] sim7100: enable A76XX simcom vendor quirks for relevant atoms Martin Hundebøll
2024-04-30 11:52 ` [PATCH 08/10] udevng: register support for SIMCom A76XX USB serial modem Martin Hundebøll
2024-05-22  7:48   ` Martin Hundebøll
2024-05-23 13:26     ` Martin Hundebøll
2024-04-30 11:52 ` [PATCH 09/10] Makefile: enable build of simcommodem radiosettings Martin Hundebøll
2024-04-30 11:52 ` [PATCH 10/10] sim7100: create radio-settings atom for A76XX modems Martin Hundebøll
2024-05-02 14:00 ` [PATCH 01/10] sim7100: simplify serial device opening patchwork-bot+ofono

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox