summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2019-05-31 11:18:32 -0500
committerDenis Kenzior <denkenz@gmail.com>2019-05-31 11:58:39 -0500
commitad007eb9abe66a0dd5cf0a4a7854b48636553605 (patch)
tree8b4880b4a4f1941a2a78f4689429f51cbc9f8b3a /plugins
parent630e48465cf8becca9307f098817d5da3d13a6a2 (diff)
downloadofono-ad007eb9abe66a0dd5cf0a4a7854b48636553605.tar.gz
wavecom: Use at_util_open_device
Diffstat (limited to 'plugins')
-rw-r--r--plugins/wavecom.c48
1 files changed, 8 insertions, 40 deletions
diff --git a/plugins/wavecom.c b/plugins/wavecom.c
index 7f24eae9..03830bf5 100644
--- a/plugins/wavecom.c
+++ b/plugins/wavecom.c
@@ -48,6 +48,7 @@
#include <ofono/ussd.h>
#include <ofono/voicecall.h>
+#include <drivers/atmodem/atutil.h>
#include <drivers/atmodem/vendor.h>
@@ -70,52 +71,19 @@ static void wavecom_debug(const char *str, void *user_data)
static int wavecom_enable(struct ofono_modem *modem)
{
GAtChat *chat;
- GIOChannel *channel;
- GAtSyntax *syntax;
- const char *device;
- GHashTable *options;
DBG("%p", modem);
- device = ofono_modem_get_string(modem, "Device");
- if (device == NULL)
+ chat = at_util_open_device(modem, "Device", wavecom_debug, "",
+ "Baud", "115200",
+ "Parity", "none",
+ "StopBits", "1",
+ "DataBits", "8",
+ NULL);
+ if (!chat)
return -EINVAL;
- options = g_hash_table_new(g_str_hash, g_str_equal);
-
- if (options == NULL)
- return -ENOMEM;
-
- g_hash_table_insert(options, "Baud", "115200");
- g_hash_table_insert(options, "Parity", "none");
- g_hash_table_insert(options, "StopBits", "1");
- g_hash_table_insert(options, "DataBits", "8");
-
- channel = g_at_tty_open(device, options);
-
- g_hash_table_destroy(options);
-
- if (channel == NULL)
- return -EIO;
-
- /*
- * Could not figure out whether it is fully compliant or not, use
- * permissive for now
- * */
- 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 -ENOMEM;
-
g_at_chat_add_terminator(chat, "+CPIN:", 6, TRUE);
-
- if (getenv("OFONO_AT_DEBUG"))
- g_at_chat_set_debug(chat, wavecom_debug, "");
-
ofono_modem_set_data(modem, chat);
return 0;