build: move plugins directory to src/plugins
We are going to allow including the plugin sources built within the ModemManager daemon binary; moving the sources within the daemon sources directory makes it easier.
This commit is contained in:
committed by
Aleksander Morgado
parent
072d7ac906
commit
e14b904cbd
@@ -0,0 +1,59 @@
|
||||
# do not edit this file, it will be overwritten on update
|
||||
|
||||
# Simtech makes modules that other companies rebrand, like:
|
||||
#
|
||||
# A-LINK 3GU
|
||||
# SCT UM300
|
||||
#
|
||||
# Most of these values were scraped from various SimTech-based Windows
|
||||
# driver .inf files. *mdm.inf lists the main command ports, while
|
||||
# *ser.inf lists the aux ports that may be used for PPP.
|
||||
|
||||
|
||||
ACTION!="add|change|move|bind", GOTO="mm_simtech_port_types_end"
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1e0e", GOTO="mm_simtech_port_types"
|
||||
GOTO="mm_simtech_port_types_end"
|
||||
|
||||
LABEL="mm_simtech_port_types"
|
||||
SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{bInterfaceNumber}"
|
||||
|
||||
# A-LINK 3GU
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="cefe", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="cefe", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="cefe", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
|
||||
# Prolink PH-300
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9100", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9100", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
|
||||
# SCT UM300
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9200", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9200", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
|
||||
# SIM7000, SIM7100, SIM7600...
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", ENV{.MM_USBIFNUM}=="04", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AUDIO}="1"
|
||||
|
||||
# SIM7070, SIM7080, SIM7090 (default layout)...
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9205", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9205", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9205", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9205", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PPP}="1"
|
||||
# Disable CPOL based features
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9205", ENV{ID_MM_PREFERRED_NETWORKS_CPOL_DISABLED}="1"
|
||||
|
||||
|
||||
# SIM7070, SIM7080, SIM7090 (secondary layout)...
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9206", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9206", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9206", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9206", ENV{.MM_USBIFNUM}=="03", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9206", ENV{.MM_USBIFNUM}=="04", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9206", ENV{.MM_USBIFNUM}=="05", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PPP}="1"
|
||||
# Disable CPOL based features
|
||||
ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9206", ENV{ID_MM_PREFERRED_NETWORKS_CPOL_DISABLED}="1"
|
||||
|
||||
LABEL="mm_simtech_port_types_end"
|
||||
@@ -0,0 +1,127 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2019 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ModemManager.h"
|
||||
#include "mm-errors-types.h"
|
||||
#include "mm-iface-modem-location.h"
|
||||
#include "mm-iface-modem-voice.h"
|
||||
#include "mm-broadband-modem-qmi-simtech.h"
|
||||
#include "mm-shared-simtech.h"
|
||||
|
||||
static void iface_modem_location_init (MMIfaceModemLocation *iface);
|
||||
static void iface_modem_voice_init (MMIfaceModemVoice *iface);
|
||||
static void shared_simtech_init (MMSharedSimtech *iface);
|
||||
|
||||
static MMIfaceModemLocation *iface_modem_location_parent;
|
||||
static MMIfaceModemVoice *iface_modem_voice_parent;
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQmiSimtech, mm_broadband_modem_qmi_simtech, MM_TYPE_BROADBAND_MODEM_QMI, 0,
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_VOICE, iface_modem_voice_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_SIMTECH, shared_simtech_init))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBroadbandModemQmiSimtech *
|
||||
mm_broadband_modem_qmi_simtech_new (const gchar *device,
|
||||
const gchar **drivers,
|
||||
const gchar *plugin,
|
||||
guint16 vendor_id,
|
||||
guint16 product_id)
|
||||
{
|
||||
return g_object_new (MM_TYPE_BROADBAND_MODEM_QMI_SIMTECH,
|
||||
MM_BASE_MODEM_DEVICE, device,
|
||||
MM_BASE_MODEM_DRIVERS, drivers,
|
||||
MM_BASE_MODEM_PLUGIN, plugin,
|
||||
MM_BASE_MODEM_VENDOR_ID, vendor_id,
|
||||
MM_BASE_MODEM_PRODUCT_ID, product_id,
|
||||
/* QMI modem supports NET only */
|
||||
MM_BASE_MODEM_DATA_NET_SUPPORTED, TRUE,
|
||||
MM_BASE_MODEM_DATA_TTY_SUPPORTED, FALSE,
|
||||
MM_BROADBAND_MODEM_INDICATORS_DISABLED, TRUE,
|
||||
MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_modem_qmi_simtech_init (MMBroadbandModemQmiSimtech *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_location_init (MMIfaceModemLocation *iface)
|
||||
{
|
||||
iface_modem_location_parent = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->load_capabilities = mm_shared_simtech_location_load_capabilities;
|
||||
iface->load_capabilities_finish = mm_shared_simtech_location_load_capabilities_finish;
|
||||
iface->enable_location_gathering = mm_shared_simtech_enable_location_gathering;
|
||||
iface->enable_location_gathering_finish = mm_shared_simtech_enable_location_gathering_finish;
|
||||
iface->disable_location_gathering = mm_shared_simtech_disable_location_gathering;
|
||||
iface->disable_location_gathering_finish = mm_shared_simtech_disable_location_gathering_finish;
|
||||
}
|
||||
|
||||
static MMIfaceModemLocation *
|
||||
peek_parent_location_interface (MMSharedSimtech *self)
|
||||
{
|
||||
return iface_modem_location_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_voice_init (MMIfaceModemVoice *iface)
|
||||
{
|
||||
iface_modem_voice_parent = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->check_support = mm_shared_simtech_voice_check_support;
|
||||
iface->check_support_finish = mm_shared_simtech_voice_check_support_finish;
|
||||
iface->enable_unsolicited_events = mm_shared_simtech_voice_enable_unsolicited_events;
|
||||
iface->enable_unsolicited_events_finish = mm_shared_simtech_voice_enable_unsolicited_events_finish;
|
||||
iface->disable_unsolicited_events = mm_shared_simtech_voice_disable_unsolicited_events;
|
||||
iface->disable_unsolicited_events_finish = mm_shared_simtech_voice_disable_unsolicited_events_finish;
|
||||
iface->setup_unsolicited_events = mm_shared_simtech_voice_setup_unsolicited_events;
|
||||
iface->setup_unsolicited_events_finish = mm_shared_simtech_voice_setup_unsolicited_events_finish;
|
||||
iface->cleanup_unsolicited_events = mm_shared_simtech_voice_cleanup_unsolicited_events;
|
||||
iface->cleanup_unsolicited_events_finish = mm_shared_simtech_voice_cleanup_unsolicited_events_finish;
|
||||
iface->setup_in_call_audio_channel = mm_shared_simtech_voice_setup_in_call_audio_channel;
|
||||
iface->setup_in_call_audio_channel_finish = mm_shared_simtech_voice_setup_in_call_audio_channel_finish;
|
||||
iface->cleanup_in_call_audio_channel = mm_shared_simtech_voice_cleanup_in_call_audio_channel;
|
||||
iface->cleanup_in_call_audio_channel_finish = mm_shared_simtech_voice_cleanup_in_call_audio_channel_finish;
|
||||
}
|
||||
|
||||
static MMIfaceModemVoice *
|
||||
peek_parent_voice_interface (MMSharedSimtech *self)
|
||||
{
|
||||
return iface_modem_voice_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
shared_simtech_init (MMSharedSimtech *iface)
|
||||
{
|
||||
iface->peek_parent_location_interface = peek_parent_location_interface;
|
||||
iface->peek_parent_voice_interface = peek_parent_voice_interface;
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_modem_qmi_simtech_class_init (MMBroadbandModemQmiSimtechClass *klass)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2019 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#ifndef MM_BROADBAND_MODEM_QMI_SIMTECH_QMI_H
|
||||
#define MM_BROADBAND_MODEM_QMI_SIMTECH_QMI_H
|
||||
|
||||
#include "mm-broadband-modem-qmi.h"
|
||||
|
||||
#define MM_TYPE_BROADBAND_MODEM_QMI_SIMTECH (mm_broadband_modem_qmi_simtech_get_type ())
|
||||
#define MM_BROADBAND_MODEM_QMI_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_QMI_SIMTECH, MMBroadbandModemQmiSimtech))
|
||||
#define MM_BROADBAND_MODEM_QMI_SIMTECH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_QMI_SIMTECH, MMBroadbandModemQmiSimtechClass))
|
||||
#define MM_IS_BROADBAND_MODEM_QMI_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_QMI_SIMTECH))
|
||||
#define MM_IS_BROADBAND_MODEM_QMI_SIMTECH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_QMI_SIMTECH))
|
||||
#define MM_BROADBAND_MODEM_QMI_SIMTECH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_QMI_SIMTECH, MMBroadbandModemQmiSimtechClass))
|
||||
|
||||
typedef struct _MMBroadbandModemQmiSimtech MMBroadbandModemQmiSimtech;
|
||||
typedef struct _MMBroadbandModemQmiSimtechClass MMBroadbandModemQmiSimtechClass;
|
||||
|
||||
struct _MMBroadbandModemQmiSimtech {
|
||||
MMBroadbandModemQmi parent;
|
||||
};
|
||||
|
||||
struct _MMBroadbandModemQmiSimtechClass{
|
||||
MMBroadbandModemQmiClass parent;
|
||||
};
|
||||
|
||||
GType mm_broadband_modem_qmi_simtech_get_type (void);
|
||||
|
||||
MMBroadbandModemQmiSimtech *mm_broadband_modem_qmi_simtech_new (const gchar *device,
|
||||
const gchar **drivers,
|
||||
const gchar *plugin,
|
||||
guint16 vendor_id,
|
||||
guint16 product_id);
|
||||
|
||||
#endif /* MM_BROADBAND_MODEM_QMI_SIMTECH_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 - 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
|
||||
*/
|
||||
|
||||
#ifndef MM_BROADBAND_MODEM_SIMTECH_H
|
||||
#define MM_BROADBAND_MODEM_SIMTECH_H
|
||||
|
||||
#include "mm-broadband-modem.h"
|
||||
|
||||
#define MM_TYPE_BROADBAND_MODEM_SIMTECH (mm_broadband_modem_simtech_get_type ())
|
||||
#define MM_BROADBAND_MODEM_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_SIMTECH, MMBroadbandModemSimtech))
|
||||
#define MM_BROADBAND_MODEM_SIMTECH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_SIMTECH, MMBroadbandModemSimtechClass))
|
||||
#define MM_IS_BROADBAND_MODEM_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_SIMTECH))
|
||||
#define MM_IS_BROADBAND_MODEM_SIMTECH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_SIMTECH))
|
||||
#define MM_BROADBAND_MODEM_SIMTECH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_SIMTECH, MMBroadbandModemSimtechClass))
|
||||
|
||||
typedef struct _MMBroadbandModemSimtech MMBroadbandModemSimtech;
|
||||
typedef struct _MMBroadbandModemSimtechClass MMBroadbandModemSimtechClass;
|
||||
typedef struct _MMBroadbandModemSimtechPrivate MMBroadbandModemSimtechPrivate;
|
||||
|
||||
struct _MMBroadbandModemSimtech {
|
||||
MMBroadbandModem parent;
|
||||
MMBroadbandModemSimtechPrivate *priv;
|
||||
};
|
||||
|
||||
struct _MMBroadbandModemSimtechClass{
|
||||
MMBroadbandModemClass parent;
|
||||
};
|
||||
|
||||
GType mm_broadband_modem_simtech_get_type (void);
|
||||
|
||||
MMBroadbandModemSimtech *mm_broadband_modem_simtech_new (const gchar *device,
|
||||
const gchar **drivers,
|
||||
const gchar *plugin,
|
||||
guint16 vendor_id,
|
||||
guint16 product_id);
|
||||
|
||||
#endif /* MM_BROADBAND_MODEM_SIMTECH_H */
|
||||
@@ -0,0 +1,209 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2019 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ModemManager.h"
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
#include "mm-errors-types.h"
|
||||
#include "mm-modem-helpers-simtech.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* +CLCC test parser
|
||||
*
|
||||
* Example (SIM7600E):
|
||||
* AT+CLCC=?
|
||||
* +CLCC: (0-1)
|
||||
*/
|
||||
|
||||
gboolean
|
||||
mm_simtech_parse_clcc_test (const gchar *response,
|
||||
gboolean *clcc_urcs_supported,
|
||||
GError **error)
|
||||
{
|
||||
g_assert (response);
|
||||
|
||||
response = mm_strip_tag (response, "+CLCC:");
|
||||
|
||||
/* 3GPP specifies that the output of AT+CLCC=? should be just OK, so support
|
||||
* that */
|
||||
if (!response[0]) {
|
||||
*clcc_urcs_supported = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* As per 3GPP TS 27.007, the AT+CLCC command doesn't expect any argument,
|
||||
* as it only is designed to report the current call list, nothing else.
|
||||
* In the case of the Simtech plugin, though, we are going to support +CLCC
|
||||
* URCs that can be enabled/disabled via AT+CLCC=1/0. We therefore need to
|
||||
* detect whether this URC management is possible or not, for now with a
|
||||
* simple check looking for the specific "(0-1)" string.
|
||||
*/
|
||||
if (!strncmp (response, "(0-1)", 5)) {
|
||||
*clcc_urcs_supported = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"unexpected +CLCC test response: '%s'", response);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
GRegex *
|
||||
mm_simtech_get_clcc_urc_regex (void)
|
||||
{
|
||||
return g_regex_new ("\\r\\n(\\+CLCC: .*\\r\\n)+",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_simtech_parse_clcc_list (const gchar *str,
|
||||
gpointer log_object,
|
||||
GList **out_list,
|
||||
GError **error)
|
||||
{
|
||||
/* Parse the URC contents as a plain +CLCC response, but make sure to skip first
|
||||
* EOL in the string because the plain +CLCC response would never have that.
|
||||
*/
|
||||
return mm_3gpp_parse_clcc_response (mm_strip_tag (str, "\r\n"), log_object, out_list, error);
|
||||
}
|
||||
|
||||
void
|
||||
mm_simtech_call_info_list_free (GList *call_info_list)
|
||||
{
|
||||
mm_3gpp_call_info_list_free (call_info_list);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* <CR><LF>VOICE CALL: BEGIN<CR><LF>
|
||||
* <CR><LF>VOICE CALL: END: 000041<CR><LF>
|
||||
*/
|
||||
GRegex *
|
||||
mm_simtech_get_voice_call_urc_regex (void)
|
||||
{
|
||||
return g_regex_new ("\\r\\nVOICE CALL:\\s*([A-Z]+)(?::\\s*(\\d+))?\\r\\n",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_simtech_parse_voice_call_urc (GMatchInfo *match_info,
|
||||
gboolean *start_or_stop,
|
||||
guint *duration,
|
||||
GError **error)
|
||||
{
|
||||
GError *inner_error = NULL;
|
||||
gchar *str;
|
||||
|
||||
str = mm_get_string_unquoted_from_match_info (match_info, 1);
|
||||
if (!str) {
|
||||
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Couldn't read voice call URC action");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (str, "BEGIN") == 0) {
|
||||
*start_or_stop = TRUE;
|
||||
*duration = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (str, "END") == 0) {
|
||||
*start_or_stop = FALSE;
|
||||
if (!mm_get_uint_from_match_info (match_info, 2, duration))
|
||||
*duration = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Unknown voice call URC action: %s", str);
|
||||
|
||||
out:
|
||||
g_free (str);
|
||||
if (inner_error) {
|
||||
g_propagate_error (error, inner_error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* <CR><LF>MISSED_CALL: 11:01AM 07712345678<CR><LF>
|
||||
*/
|
||||
GRegex *
|
||||
mm_simtech_get_missed_call_urc_regex (void)
|
||||
{
|
||||
return g_regex_new ("\\r\\nMISSED_CALL:\\s*(.+)\\r\\n",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_simtech_parse_missed_call_urc (GMatchInfo *match_info,
|
||||
gchar **details,
|
||||
GError **error)
|
||||
{
|
||||
gchar *str;
|
||||
|
||||
str = mm_get_string_unquoted_from_match_info (match_info, 1);
|
||||
if (!str) {
|
||||
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Couldn't read missed call URC details");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*details = str;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* Using TWO <CR> instead of one...
|
||||
* <CR><CR><LF>+CRING: VOICE<CR><CR><LF>
|
||||
*/
|
||||
GRegex *
|
||||
mm_simtech_get_cring_urc_regex (void)
|
||||
{
|
||||
return g_regex_new ("(?:\\r)+\\n\\+CRING:\\s*(\\S+)(?:\\r)+\\n",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* <CR><CR><LF>+RXDTMF: 8<CR><CR><LF>
|
||||
* <CR><CR><LF>+RXDTMF: *<CR><CR><LF>
|
||||
* <CR><CR><LF>+RXDTMF: 7<CR><CR><LF>
|
||||
*
|
||||
* Note! using TWO <CR> instead of one...
|
||||
*/
|
||||
GRegex *
|
||||
mm_simtech_get_rxdtmf_urc_regex (void)
|
||||
{
|
||||
return g_regex_new ("(?:\\r)+\\n\\+RXDTMF:\\s*([0-9A-D\\*\\#])(?:\\r)+\\n",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2019 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#ifndef MM_MODEM_HELPERS_SIMTECH_H
|
||||
#define MM_MODEM_HELPERS_SIMTECH_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ModemManager.h>
|
||||
#include <mm-base-bearer.h>
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* +CLCC URC helpers */
|
||||
|
||||
gboolean mm_simtech_parse_clcc_test (const gchar *response,
|
||||
gboolean *clcc_urcs_supported,
|
||||
GError **error);
|
||||
|
||||
GRegex *mm_simtech_get_clcc_urc_regex (void);
|
||||
gboolean mm_simtech_parse_clcc_list (const gchar *str,
|
||||
gpointer log_object,
|
||||
GList **out_list,
|
||||
GError **error);
|
||||
void mm_simtech_call_info_list_free (GList *call_info_list);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* VOICE CALL URC helpers */
|
||||
|
||||
GRegex *mm_simtech_get_voice_call_urc_regex (void);
|
||||
gboolean mm_simtech_parse_voice_call_urc (GMatchInfo *match_info,
|
||||
gboolean *start_or_stop,
|
||||
guint *duration,
|
||||
GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* MISSED_CALL URC helpers */
|
||||
|
||||
GRegex *mm_simtech_get_missed_call_urc_regex (void);
|
||||
gboolean mm_simtech_parse_missed_call_urc (GMatchInfo *match_info,
|
||||
gchar **details,
|
||||
GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Non-standard CRING URC helpers */
|
||||
|
||||
GRegex *mm_simtech_get_cring_urc_regex (void);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* +RXDTMF URC helpers */
|
||||
|
||||
GRegex *mm_simtech_get_rxdtmf_urc_regex (void);
|
||||
|
||||
#endif /* MM_MODEM_HELPERS_SIMTECH_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 - 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include "mm-log-object.h"
|
||||
#include "mm-plugin-simtech.h"
|
||||
#include "mm-broadband-modem-simtech.h"
|
||||
|
||||
#if defined WITH_QMI
|
||||
#include "mm-broadband-modem-qmi-simtech.h"
|
||||
#endif
|
||||
|
||||
G_DEFINE_TYPE (MMPluginSimtech, mm_plugin_simtech, MM_TYPE_PLUGIN)
|
||||
|
||||
MM_PLUGIN_DEFINE_MAJOR_VERSION
|
||||
MM_PLUGIN_DEFINE_MINOR_VERSION
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static MMBaseModem *
|
||||
create_modem (MMPlugin *self,
|
||||
const gchar *uid,
|
||||
const gchar **drivers,
|
||||
guint16 vendor,
|
||||
guint16 product,
|
||||
guint16 subsystem_vendor,
|
||||
GList *probes,
|
||||
GError **error)
|
||||
{
|
||||
#if defined WITH_QMI
|
||||
if (mm_port_probe_list_has_qmi_port (probes)) {
|
||||
mm_obj_dbg (self, "QMI-powered SimTech modem found...");
|
||||
return MM_BASE_MODEM (mm_broadband_modem_qmi_simtech_new (uid,
|
||||
drivers,
|
||||
mm_plugin_get_name (self),
|
||||
vendor,
|
||||
product));
|
||||
}
|
||||
#endif
|
||||
|
||||
return MM_BASE_MODEM (mm_broadband_modem_simtech_new (uid,
|
||||
drivers,
|
||||
mm_plugin_get_name (self),
|
||||
vendor,
|
||||
product));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
G_MODULE_EXPORT MMPlugin *
|
||||
mm_plugin_create (void)
|
||||
{
|
||||
static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
|
||||
static const guint16 vendor_ids[] = { 0x1e0e, /* A-Link (for now) */
|
||||
0 };
|
||||
|
||||
return MM_PLUGIN (
|
||||
g_object_new (MM_TYPE_PLUGIN_SIMTECH,
|
||||
MM_PLUGIN_NAME, MM_MODULE_NAME,
|
||||
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
|
||||
MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
|
||||
MM_PLUGIN_ALLOWED_AT, TRUE,
|
||||
MM_PLUGIN_ALLOWED_QCDM, TRUE,
|
||||
MM_PLUGIN_ALLOWED_QMI, TRUE,
|
||||
NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
mm_plugin_simtech_init (MMPluginSimtech *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
mm_plugin_simtech_class_init (MMPluginSimtechClass *klass)
|
||||
{
|
||||
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
|
||||
|
||||
plugin_class->create_modem = create_modem;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 - 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
|
||||
*/
|
||||
|
||||
#ifndef MM_PLUGIN_SIMTECH_H
|
||||
#define MM_PLUGIN_SIMTECH_H
|
||||
|
||||
#include "mm-plugin.h"
|
||||
|
||||
#define MM_TYPE_PLUGIN_SIMTECH (mm_plugin_simtech_get_type ())
|
||||
#define MM_PLUGIN_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_SIMTECH, MMPluginSimtech))
|
||||
#define MM_PLUGIN_SIMTECH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_SIMTECH, MMPluginSimtechClass))
|
||||
#define MM_IS_PLUGIN_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_SIMTECH))
|
||||
#define MM_IS_PLUGIN_SIMTECH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_SIMTECH))
|
||||
#define MM_PLUGIN_SIMTECH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_SIMTECH, MMPluginSimtechClass))
|
||||
|
||||
typedef struct {
|
||||
MMPlugin parent;
|
||||
} MMPluginSimtech;
|
||||
|
||||
typedef struct {
|
||||
MMPluginClass parent;
|
||||
} MMPluginSimtechClass;
|
||||
|
||||
GType mm_plugin_simtech_get_type (void);
|
||||
|
||||
G_MODULE_EXPORT MMPlugin *mm_plugin_create (void);
|
||||
|
||||
#endif /* MM_PLUGIN_SIMTECH_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,129 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2019 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#ifndef MM_SHARED_SIMTECH_H
|
||||
#define MM_SHARED_SIMTECH_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include "mm-broadband-modem.h"
|
||||
#include "mm-iface-modem.h"
|
||||
#include "mm-iface-modem-location.h"
|
||||
#include "mm-iface-modem-voice.h"
|
||||
|
||||
#define MM_TYPE_SHARED_SIMTECH (mm_shared_simtech_get_type ())
|
||||
#define MM_SHARED_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SHARED_SIMTECH, MMSharedSimtech))
|
||||
#define MM_IS_SHARED_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SHARED_SIMTECH))
|
||||
#define MM_SHARED_SIMTECH_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_SHARED_SIMTECH, MMSharedSimtech))
|
||||
|
||||
typedef struct _MMSharedSimtech MMSharedSimtech;
|
||||
|
||||
struct _MMSharedSimtech {
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Peek location interface of the parent class of the object */
|
||||
MMIfaceModemLocation * (* peek_parent_location_interface) (MMSharedSimtech *self);
|
||||
|
||||
/* Peek voice interface of the parent class of the object */
|
||||
MMIfaceModemVoice * (* peek_parent_voice_interface) (MMSharedSimtech *self);
|
||||
};
|
||||
|
||||
GType mm_shared_simtech_get_type (void);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Location interface */
|
||||
|
||||
void mm_shared_simtech_location_load_capabilities (MMIfaceModemLocation *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
MMModemLocationSource mm_shared_simtech_location_load_capabilities_finish (MMIfaceModemLocation *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
void mm_shared_simtech_enable_location_gathering (MMIfaceModemLocation *self,
|
||||
MMModemLocationSource source,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_enable_location_gathering_finish (MMIfaceModemLocation *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
void mm_shared_simtech_disable_location_gathering (MMIfaceModemLocation *self,
|
||||
MMModemLocationSource source,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_disable_location_gathering_finish (MMIfaceModemLocation *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Voice interface */
|
||||
|
||||
void mm_shared_simtech_voice_check_support (MMIfaceModemVoice *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_voice_check_support_finish (MMIfaceModemVoice *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
void mm_shared_simtech_voice_setup_unsolicited_events (MMIfaceModemVoice *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_voice_setup_unsolicited_events_finish (MMIfaceModemVoice *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
void mm_shared_simtech_voice_cleanup_unsolicited_events (MMIfaceModemVoice *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_voice_cleanup_unsolicited_events_finish (MMIfaceModemVoice *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
void mm_shared_simtech_voice_enable_unsolicited_events (MMIfaceModemVoice *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_voice_enable_unsolicited_events_finish (MMIfaceModemVoice *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
void mm_shared_simtech_voice_disable_unsolicited_events (MMIfaceModemVoice *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_voice_disable_unsolicited_events_finish (MMIfaceModemVoice *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
void mm_shared_simtech_voice_setup_in_call_audio_channel (MMIfaceModemVoice *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_voice_setup_in_call_audio_channel_finish (MMIfaceModemVoice *self,
|
||||
GAsyncResult *res,
|
||||
MMPort **audio_port, /* optional */
|
||||
MMCallAudioFormat **audio_format, /* optional */
|
||||
GError **error);
|
||||
void mm_shared_simtech_voice_cleanup_in_call_audio_channel (MMIfaceModemVoice *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_simtech_voice_cleanup_in_call_audio_channel_finish (MMIfaceModemVoice *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
#endif /* MM_SHARED_SIMTECH_H */
|
||||
@@ -0,0 +1,324 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2019 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include <ModemManager.h>
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include "mm-log-test.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
#include "mm-modem-helpers-simtech.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Test +CLCC URCs */
|
||||
|
||||
static void
|
||||
common_test_clcc_urc (const gchar *urc,
|
||||
const MMCallInfo *expected_call_info_list,
|
||||
guint expected_call_info_list_size)
|
||||
{
|
||||
g_autoptr(GRegex) clcc_regex = NULL;
|
||||
g_autoptr(GMatchInfo) match_info = NULL;
|
||||
g_autofree gchar *str = NULL;
|
||||
GError *error = NULL;
|
||||
GList *call_info_list = NULL;
|
||||
GList *l;
|
||||
gboolean result;
|
||||
|
||||
clcc_regex = mm_simtech_get_clcc_urc_regex ();
|
||||
|
||||
/* Same matching logic as done in MMSerialPortAt when processing URCs! */
|
||||
result = g_regex_match_full (clcc_regex, urc, -1, 0, 0, &match_info, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (result);
|
||||
|
||||
/* read full matched content */
|
||||
str = g_match_info_fetch (match_info, 0);
|
||||
g_assert (str);
|
||||
|
||||
result = mm_simtech_parse_clcc_list (str, NULL, &call_info_list, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (result);
|
||||
|
||||
g_debug ("found %u calls", g_list_length (call_info_list));
|
||||
|
||||
if (expected_call_info_list) {
|
||||
g_assert (call_info_list);
|
||||
g_assert_cmpuint (g_list_length (call_info_list), ==, expected_call_info_list_size);
|
||||
} else
|
||||
g_assert (!call_info_list);
|
||||
|
||||
for (l = call_info_list; l; l = g_list_next (l)) {
|
||||
const MMCallInfo *call_info = (const MMCallInfo *)(l->data);
|
||||
gboolean found = FALSE;
|
||||
guint i;
|
||||
|
||||
g_debug ("call at index %u: direction %s, state %s, number %s",
|
||||
call_info->index,
|
||||
mm_call_direction_get_string (call_info->direction),
|
||||
mm_call_state_get_string (call_info->state),
|
||||
call_info->number ? call_info->number : "n/a");
|
||||
|
||||
for (i = 0; !found && i < expected_call_info_list_size; i++)
|
||||
found = ((call_info->index == expected_call_info_list[i].index) &&
|
||||
(call_info->direction == expected_call_info_list[i].direction) &&
|
||||
(call_info->state == expected_call_info_list[i].state) &&
|
||||
(g_strcmp0 (call_info->number, expected_call_info_list[i].number) == 0));
|
||||
|
||||
g_assert (found);
|
||||
}
|
||||
|
||||
mm_simtech_call_info_list_free (call_info_list);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clcc_urc_single (void)
|
||||
{
|
||||
static const MMCallInfo expected_call_info_list[] = {
|
||||
{ 1, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_ACTIVE, (gchar *) "123456789" }
|
||||
};
|
||||
|
||||
const gchar *urc =
|
||||
"\r\n+CLCC: 1,1,0,0,0,\"123456789\",161"
|
||||
"\r\n";
|
||||
|
||||
common_test_clcc_urc (urc, expected_call_info_list, G_N_ELEMENTS (expected_call_info_list));
|
||||
}
|
||||
|
||||
static void
|
||||
test_clcc_urc_multiple (void)
|
||||
{
|
||||
static const MMCallInfo expected_call_info_list[] = {
|
||||
{ 1, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_ACTIVE, NULL },
|
||||
{ 2, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_ACTIVE, (gchar *) "123456789" },
|
||||
{ 3, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_ACTIVE, (gchar *) "987654321" },
|
||||
};
|
||||
|
||||
const gchar *urc =
|
||||
"\r\n+CLCC: 1,1,0,0,0" /* number unknown */
|
||||
"\r\n+CLCC: 2,1,0,0,0,\"123456789\",161"
|
||||
"\r\n+CLCC: 3,1,0,0,0,\"987654321\",161,\"Alice\""
|
||||
"\r\n";
|
||||
|
||||
common_test_clcc_urc (urc, expected_call_info_list, G_N_ELEMENTS (expected_call_info_list));
|
||||
}
|
||||
|
||||
static void
|
||||
test_clcc_urc_complex (void)
|
||||
{
|
||||
static const MMCallInfo expected_call_info_list[] = {
|
||||
{ 1, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_ACTIVE, (gchar *) "123456789" },
|
||||
{ 2, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_WAITING, (gchar *) "987654321" },
|
||||
};
|
||||
|
||||
const gchar *urc =
|
||||
"\r\n^CIEV: 1,0" /* some different URC before our match */
|
||||
"\r\n+CLCC: 1,1,0,0,0,\"123456789\",161"
|
||||
"\r\n+CLCC: 2,1,5,0,0,\"987654321\",161"
|
||||
"\r\n^CIEV: 1,0" /* some different URC after our match */
|
||||
"\r\n";
|
||||
|
||||
common_test_clcc_urc (urc, expected_call_info_list, G_N_ELEMENTS (expected_call_info_list));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
common_test_voice_call_urc (const gchar *urc,
|
||||
gboolean expected_start_or_stop,
|
||||
guint expected_duration)
|
||||
{
|
||||
g_autoptr(GRegex) voice_call_regex = NULL;
|
||||
g_autoptr(GMatchInfo) match_info = NULL;
|
||||
GError *error = NULL;
|
||||
gboolean start_or_stop = FALSE; /* start = TRUE, stop = FALSE */
|
||||
guint duration = 0;
|
||||
gboolean result;
|
||||
|
||||
voice_call_regex = mm_simtech_get_voice_call_urc_regex ();
|
||||
|
||||
/* Same matching logic as done in MMSerialPortAt when processing URCs! */
|
||||
result = g_regex_match_full (voice_call_regex, urc, -1, 0, 0, &match_info, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (result);
|
||||
|
||||
result = mm_simtech_parse_voice_call_urc (match_info, &start_or_stop, &duration, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (result);
|
||||
|
||||
g_assert_cmpuint (expected_start_or_stop, ==, start_or_stop);
|
||||
g_assert_cmpuint (expected_duration, ==, duration);
|
||||
}
|
||||
|
||||
static void
|
||||
test_voice_call_begin_urc (void)
|
||||
{
|
||||
common_test_voice_call_urc ("\r\nVOICE CALL: BEGIN\r\n", TRUE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_voice_call_end_urc (void)
|
||||
{
|
||||
common_test_voice_call_urc ("\r\nVOICE CALL: END\r\n", FALSE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_voice_call_end_duration_urc (void)
|
||||
{
|
||||
common_test_voice_call_urc ("\r\nVOICE CALL: END: 000041\r\n", FALSE, 41);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
common_test_missed_call_urc (const gchar *urc,
|
||||
const gchar *expected_details)
|
||||
{
|
||||
g_autoptr(GRegex) missed_call_regex = NULL;
|
||||
g_autoptr(GMatchInfo) match_info = NULL;
|
||||
g_autofree gchar *details = NULL;
|
||||
GError *error = NULL;
|
||||
gboolean result;
|
||||
|
||||
missed_call_regex = mm_simtech_get_missed_call_urc_regex ();
|
||||
|
||||
/* Same matching logic as done in MMSerialPortAt when processing URCs! */
|
||||
result = g_regex_match_full (missed_call_regex, urc, -1, 0, 0, &match_info, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (result);
|
||||
|
||||
result = mm_simtech_parse_missed_call_urc (match_info, &details, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (result);
|
||||
|
||||
g_assert_cmpstr (expected_details, ==, details);
|
||||
}
|
||||
|
||||
static void
|
||||
test_missed_call_urc (void)
|
||||
{
|
||||
common_test_missed_call_urc ("\r\nMISSED_CALL: 11:01AM 07712345678\r\n", "11:01AM 07712345678");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
common_test_cring_urc (const gchar *urc,
|
||||
const gchar *expected_type)
|
||||
{
|
||||
g_autoptr(GRegex) cring_regex = NULL;
|
||||
g_autoptr(GMatchInfo) match_info = NULL;
|
||||
g_autofree gchar *type = NULL;
|
||||
GError *error = NULL;
|
||||
gboolean result;
|
||||
|
||||
cring_regex = mm_simtech_get_cring_urc_regex ();
|
||||
|
||||
/* Same matching logic as done in MMSerialPortAt when processing URCs! */
|
||||
result = g_regex_match_full (cring_regex, urc, -1, 0, 0, &match_info, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (result);
|
||||
|
||||
type = g_match_info_fetch (match_info, 1);
|
||||
g_assert (type);
|
||||
|
||||
g_assert_cmpstr (type, ==, expected_type);
|
||||
}
|
||||
|
||||
static void
|
||||
test_cring_urc_two_crs (void)
|
||||
{
|
||||
common_test_cring_urc ("\r\r\n+CRING: VOICE\r\r\n", "VOICE");
|
||||
}
|
||||
|
||||
static void
|
||||
test_cring_urc_one_cr (void)
|
||||
{
|
||||
common_test_cring_urc ("\r\n+CRING: VOICE\r\n", "VOICE");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
common_test_rxdtmf_urc (const gchar *urc,
|
||||
const gchar *expected_str)
|
||||
{
|
||||
g_autoptr(GRegex) rxdtmf_regex = NULL;
|
||||
g_autoptr(GMatchInfo) match_info = NULL;
|
||||
g_autofree gchar *type = NULL;
|
||||
GError *error = NULL;
|
||||
gboolean result;
|
||||
|
||||
rxdtmf_regex = mm_simtech_get_rxdtmf_urc_regex ();
|
||||
|
||||
/* Same matching logic as done in MMSerialPortAt when processing URCs! */
|
||||
result = g_regex_match_full (rxdtmf_regex, urc, -1, 0, 0, &match_info, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (result);
|
||||
|
||||
type = g_match_info_fetch (match_info, 1);
|
||||
g_assert (type);
|
||||
|
||||
g_assert_cmpstr (type, ==, expected_str);
|
||||
}
|
||||
|
||||
static void
|
||||
test_rxdtmf_urc_two_crs (void)
|
||||
{
|
||||
common_test_rxdtmf_urc ("\r\r\n+RXDTMF: 8\r\r\n", "8");
|
||||
common_test_rxdtmf_urc ("\r\r\n+RXDTMF: *\r\r\n", "*");
|
||||
common_test_rxdtmf_urc ("\r\r\n+RXDTMF: #\r\r\n", "#");
|
||||
common_test_rxdtmf_urc ("\r\r\n+RXDTMF: A\r\r\n", "A");
|
||||
}
|
||||
|
||||
static void
|
||||
test_rxdtmf_urc_one_cr (void)
|
||||
{
|
||||
common_test_rxdtmf_urc ("\r\n+RXDTMF: 8\r\n", "8");
|
||||
common_test_rxdtmf_urc ("\r\n+RXDTMF: *\r\n", "*");
|
||||
common_test_rxdtmf_urc ("\r\n+RXDTMF: #\r\n", "#");
|
||||
common_test_rxdtmf_urc ("\r\n+RXDTMF: A\r\n", "A");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/MM/simtech/clcc/urc/single", test_clcc_urc_single);
|
||||
g_test_add_func ("/MM/simtech/clcc/urc/multiple", test_clcc_urc_multiple);
|
||||
g_test_add_func ("/MM/simtech/clcc/urc/complex", test_clcc_urc_complex);
|
||||
|
||||
g_test_add_func ("/MM/simtech/voicecall/urc/begin", test_voice_call_begin_urc);
|
||||
g_test_add_func ("/MM/simtech/voicecall/urc/end", test_voice_call_end_urc);
|
||||
g_test_add_func ("/MM/simtech/voicecall/urc/end-duration", test_voice_call_end_duration_urc);
|
||||
|
||||
g_test_add_func ("/MM/simtech/missedcall/urc", test_missed_call_urc);
|
||||
|
||||
g_test_add_func ("/MM/simtech/cring/urc/two-crs", test_cring_urc_two_crs);
|
||||
g_test_add_func ("/MM/simtech/cring/urc/one-cr", test_cring_urc_one_cr);
|
||||
|
||||
g_test_add_func ("/MM/simtech/rxdtmf/urc/two-crs", test_rxdtmf_urc_two_crs);
|
||||
g_test_add_func ("/MM/simtech/rxdtmf/urc/one-cr", test_rxdtmf_urc_one_cr);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
Reference in New Issue
Block a user