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:
Aleksander Morgado
2023-01-03 13:56:25 +00:00
committed by Aleksander Morgado
parent 072d7ac906
commit e14b904cbd
318 changed files with 5 additions and 3 deletions
@@ -0,0 +1,104 @@
# do not edit this file, it will be overwritten on update
ACTION!="add|change|move|bind", GOTO="mm_quectel_end"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c7c", GOTO="mm_quectel_usb"
SUBSYSTEMS=="pci", ATTRS{vendor}=="0x1eac", GOTO="mm_quectel_pci"
GOTO="mm_quectel_end"
LABEL="mm_quectel_usb"
SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{bInterfaceNumber}"
# Quectel EG06
# ttyUSB0 (if #0): QCDM/DIAG port
# ttyUSB1 (if #1): GPS data port
# ttyUSB2 (if #2): AT primary port
# ttyUSB3 (if #3): AT secondary port
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0306", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0306", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0306", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0306", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
# Quectel EG91
# ttyUSB0 (if #0): QCDM/DIAG port
# ttyUSB1 (if #1): GPS data port
# ttyUSB2 (if #2): AT primary port
# ttyUSB3 (if #3): AT secondary port
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0191", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0191", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0191", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0191", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
# Quectel EG95
# ttyUSB0 (if #0): QCDM/DIAG port
# ttyUSB1 (if #1): GPS data port
# ttyUSB2 (if #2): AT primary port
# ttyUSB3 (if #3): AT secondary port
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0195", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0195", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0195", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0195", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
# Quectel BG96
# ttyUSB0 (if #0): QCDM/DIAG port
# ttyUSB1 (if #1): GPS data port
# ttyUSB2 (if #2): AT primary port
# ttyUSB3 (if #3): AT secondary port
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0296", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0296", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0296", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0296", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
# Quectel EC25/EG25
# ttyUSB0 (if #0): QCDM/DIAG port
# ttyUSB1 (if #1): GPS data port
# ttyUSB2 (if #2): AT primary port
# ttyUSB3 (if #3): AT secondary port
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
# Quectel RM500
# ttyUSB0 (if #0): QCDM/DIAG port
# ttyUSB1 (if #1): GPS data port
# ttyUSB2 (if #2): AT primary port
# ttyUSB3 (if #3): AT secondary port
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0800", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0800", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_GPS}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0800", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0800", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
# Quectel EM05-G variants with Sahara-Firehose support:
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="030a", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="030a", ENV{ID_MM_QUECTEL_SAHARA}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="030c", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="030c", ENV{ID_MM_QUECTEL_SAHARA}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0311", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0311", ENV{ID_MM_QUECTEL_SAHARA}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0313", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0313", ENV{ID_MM_QUECTEL_SAHARA}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0314", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0314", ENV{ID_MM_QUECTEL_SAHARA}="1"
# Quectel EM05-CN variants with Sahara-Firehose support
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0310", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0310", ENV{ID_MM_QUECTEL_SAHARA}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0312", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0312", ENV{ID_MM_QUECTEL_SAHARA}="1"
# Quectel EM05-CE with Sahara-Firehose support
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0127", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0127", ENV{ID_MM_QUECTEL_SAHARA}="1"
GOTO="mm_quectel_end"
LABEL="mm_quectel_pci"
# Quectel EM120 and EM160 with firehose support
ATTRS{vendor}=="0x1eac", ATTRS{device}=="0x1001", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
ATTRS{vendor}=="0x1eac", ATTRS{device}=="0x1002", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
# Quectel RM520 with firehose support
ATTRS{vendor}=="0x1eac", ATTRS{device}=="0x1004", ENV{ID_MM_QUECTEL_FIREHOSE}="1"
LABEL="mm_quectel_end"
@@ -0,0 +1,88 @@
/* -*- 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) 2020 Aleksander Morgado <aleksander@aleksander.es>
* Copyright (C) 2021 Ivan Mikhanchuk <ivan.mikhanchuk@quectel.com>
*/
#include <config.h>
#include "mm-base-modem-at.h"
#include "mm-log-object.h"
#include "mm-iface-modem.h"
#include "mm-iface-modem-firmware.h"
#include "mm-iface-modem-time.h"
#include "mm-shared-quectel.h"
#include "mm-modem-helpers-quectel.h"
#include "mm-broadband-modem-mbim-quectel.h"
static void iface_modem_firmware_init (MMIfaceModemFirmware *iface);
static void iface_modem_time_init (MMIfaceModemTime *iface);
static void shared_quectel_init (MMSharedQuectel *iface);
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimQuectel, mm_broadband_modem_mbim_quectel, MM_TYPE_BROADBAND_MODEM_MBIM, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME, iface_modem_time_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_QUECTEL, shared_quectel_init))
/*****************************************************************************/
MMBroadbandModemMbimQuectel *
mm_broadband_modem_mbim_quectel_new (const gchar *device,
const gchar **drivers,
const gchar *plugin,
guint16 vendor_id,
guint16 product_id)
{
return g_object_new (MM_TYPE_BROADBAND_MODEM_MBIM_QUECTEL,
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,
/* include carrier information */
MM_IFACE_MODEM_FIRMWARE_IGNORE_CARRIER, FALSE,
/* MBIM bearer supports NET only */
MM_BASE_MODEM_DATA_NET_SUPPORTED, TRUE,
MM_BASE_MODEM_DATA_TTY_SUPPORTED, FALSE,
MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, TRUE,
NULL);
}
static void
mm_broadband_modem_mbim_quectel_init (MMBroadbandModemMbimQuectel *self)
{
}
static void
iface_modem_firmware_init (MMIfaceModemFirmware *iface)
{
iface->load_update_settings = mm_shared_quectel_firmware_load_update_settings;
iface->load_update_settings_finish = mm_shared_quectel_firmware_load_update_settings_finish;
}
static void
iface_modem_time_init (MMIfaceModemTime *iface)
{
iface->check_support = mm_shared_quectel_time_check_support;
iface->check_support_finish = mm_shared_quectel_time_check_support_finish;
}
static void
shared_quectel_init (MMSharedQuectel *iface)
{
}
static void
mm_broadband_modem_mbim_quectel_class_init (MMBroadbandModemMbimQuectelClass *klass)
{
}
@@ -0,0 +1,48 @@
/* -*- 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) 2020 Aleksander Morgado <aleksander@aleksander.es>
* Copyright (C) 2021 Ivan Mikhanchuk <ivan.mikhanchuk@quectel.com>
*/
#ifndef MM_BROADBAND_MODEM_MBIM_QUECTEL_H
#define MM_BROADBAND_MODEM_MBIM_QUECTEL_H
#include "mm-broadband-modem-mbim.h"
#define MM_TYPE_BROADBAND_MODEM_MBIM_QUECTEL (mm_broadband_modem_mbim_quectel_get_type ())
#define MM_BROADBAND_MODEM_MBIM_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_QUECTEL, MMBroadbandModemMbimQuectel))
#define MM_BROADBAND_MODEM_MBIM_QUECTEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_MBIM_QUECTEL, MMBroadbandModemMbimQuectelClass))
#define MM_IS_BROADBAND_MODEM_MBIM_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_QUECTEL))
#define MM_IS_BROADBAND_MODEM_MBIM_QUECTEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_MBIM_QUECTEL))
#define MM_BROADBAND_MODEM_MBIM_QUECTEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_QUECTEL, MMBroadbandModemMbimQuectelClass))
typedef struct _MMBroadbandModemMbimQuectel MMBroadbandModemMbimQuectel;
typedef struct _MMBroadbandModemMbimQuectelClass MMBroadbandModemMbimQuectelClass;
struct _MMBroadbandModemMbimQuectel {
MMBroadbandModemMbim parent;
};
struct _MMBroadbandModemMbimQuectelClass{
MMBroadbandModemMbimClass parent;
};
GType mm_broadband_modem_mbim_quectel_get_type (void);
MMBroadbandModemMbimQuectel *mm_broadband_modem_mbim_quectel_new (const gchar *device,
const gchar **drivers,
const gchar *plugin,
guint16 vendor_id,
guint16 product_id);
#endif /* MM_BROADBAND_MODEM_MBIM_QUECTEL_H */
@@ -0,0 +1,138 @@
/* -*- 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) 2018-2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <config.h>
#include "mm-broadband-modem-qmi-quectel.h"
#include "mm-iface-modem-firmware.h"
#include "mm-iface-modem-location.h"
#include "mm-iface-modem-time.h"
#include "mm-shared-quectel.h"
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmware *iface);
static void iface_modem_location_init (MMIfaceModemLocation *iface);
static void iface_modem_time_init (MMIfaceModemTime *iface);
static void shared_quectel_init (MMSharedQuectel *iface);
static MMIfaceModem *iface_modem_parent;
static MMIfaceModemLocation *iface_modem_location_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQmiQuectel, mm_broadband_modem_qmi_quectel, MM_TYPE_BROADBAND_MODEM_QMI, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME, iface_modem_time_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_QUECTEL, shared_quectel_init))
/*****************************************************************************/
MMBroadbandModemQmiQuectel *
mm_broadband_modem_qmi_quectel_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_QUECTEL,
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,
/* exclude carrier information */
MM_IFACE_MODEM_FIRMWARE_IGNORE_CARRIER, TRUE,
/* QMI bearer supports NET only */
MM_BASE_MODEM_DATA_NET_SUPPORTED, TRUE,
MM_BASE_MODEM_DATA_TTY_SUPPORTED, FALSE,
MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, TRUE,
NULL);
}
static void
mm_broadband_modem_qmi_quectel_init (MMBroadbandModemQmiQuectel *self)
{
}
static void
iface_modem_init (MMIfaceModem *iface)
{
iface_modem_parent = g_type_interface_peek_parent (iface);
iface->setup_sim_hot_swap = mm_shared_quectel_setup_sim_hot_swap;
iface->setup_sim_hot_swap_finish = mm_shared_quectel_setup_sim_hot_swap_finish;
iface->cleanup_sim_hot_swap = mm_shared_quectel_cleanup_sim_hot_swap;
}
static MMIfaceModem *
peek_parent_modem_interface (MMSharedQuectel *self)
{
return iface_modem_parent;
}
static MMBroadbandModemClass *
peek_parent_broadband_modem_class (MMSharedQuectel *self)
{
return MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_qmi_quectel_parent_class);
}
static void
iface_modem_firmware_init (MMIfaceModemFirmware *iface)
{
iface->load_update_settings = mm_shared_quectel_firmware_load_update_settings;
iface->load_update_settings_finish = mm_shared_quectel_firmware_load_update_settings_finish;
}
static void
iface_modem_location_init (MMIfaceModemLocation *iface)
{
iface_modem_location_parent = g_type_interface_peek_parent (iface);
iface->load_capabilities = mm_shared_quectel_location_load_capabilities;
iface->load_capabilities_finish = mm_shared_quectel_location_load_capabilities_finish;
iface->enable_location_gathering = mm_shared_quectel_enable_location_gathering;
iface->enable_location_gathering_finish = mm_shared_quectel_enable_location_gathering_finish;
iface->disable_location_gathering = mm_shared_quectel_disable_location_gathering;
iface->disable_location_gathering_finish = mm_shared_quectel_disable_location_gathering_finish;
}
static MMIfaceModemLocation *
peek_parent_modem_location_interface (MMSharedQuectel *self)
{
return iface_modem_location_parent;
}
static void
iface_modem_time_init (MMIfaceModemTime *iface)
{
iface->check_support = mm_shared_quectel_time_check_support;
iface->check_support_finish = mm_shared_quectel_time_check_support_finish;
}
static void
shared_quectel_init (MMSharedQuectel *iface)
{
iface->peek_parent_modem_interface = peek_parent_modem_interface;
iface->peek_parent_modem_location_interface = peek_parent_modem_location_interface;
iface->peek_parent_broadband_modem_class = peek_parent_broadband_modem_class;
}
static void
mm_broadband_modem_qmi_quectel_class_init (MMBroadbandModemQmiQuectelClass *klass)
{
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
broadband_modem_class->setup_ports = mm_shared_quectel_setup_ports;
}
@@ -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) 2018 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_BROADBAND_MODEM_QMI_QUECTEL_H
#define MM_BROADBAND_MODEM_QMI_QUECTEL_H
#include "mm-broadband-modem-qmi.h"
#define MM_TYPE_BROADBAND_MODEM_QMI_QUECTEL (mm_broadband_modem_qmi_quectel_get_type ())
#define MM_BROADBAND_MODEM_QMI_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_QMI_QUECTEL, MMBroadbandModemQmiQuectel))
#define MM_BROADBAND_MODEM_QMI_QUECTEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_QMI_QUECTEL, MMBroadbandModemQmiQuectelClass))
#define MM_IS_BROADBAND_MODEM_QMI_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_QMI_QUECTEL))
#define MM_IS_BROADBAND_MODEM_QMI_QUECTEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_QMI_QUECTEL))
#define MM_BROADBAND_MODEM_QMI_QUECTEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_QMI_QUECTEL, MMBroadbandModemQmiQuectelClass))
typedef struct _MMBroadbandModemQmiQuectel MMBroadbandModemQmiQuectel;
typedef struct _MMBroadbandModemQmiQuectelClass MMBroadbandModemQmiQuectelClass;
struct _MMBroadbandModemQmiQuectel {
MMBroadbandModemQmi parent;
};
struct _MMBroadbandModemQmiQuectelClass{
MMBroadbandModemQmiClass parent;
};
GType mm_broadband_modem_qmi_quectel_get_type (void);
MMBroadbandModemQmiQuectel *mm_broadband_modem_qmi_quectel_new (const gchar *device,
const gchar **drivers,
const gchar *plugin,
guint16 vendor_id,
guint16 product_id);
#endif /* MM_BROADBAND_MODEM_QMI_QUECTEL_H */
@@ -0,0 +1,136 @@
/* -*- 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) 2018-2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <config.h>
#include "mm-broadband-modem-quectel.h"
#include "mm-iface-modem-firmware.h"
#include "mm-iface-modem-location.h"
#include "mm-iface-modem-time.h"
#include "mm-shared-quectel.h"
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmware *iface);
static void iface_modem_location_init (MMIfaceModemLocation *iface);
static void iface_modem_time_init (MMIfaceModemTime *iface);
static void shared_quectel_init (MMSharedQuectel *iface);
static MMIfaceModem *iface_modem_parent;
static MMIfaceModemLocation *iface_modem_location_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQuectel, mm_broadband_modem_quectel, MM_TYPE_BROADBAND_MODEM, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME, iface_modem_time_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_QUECTEL, shared_quectel_init))
/*****************************************************************************/
MMBroadbandModemQuectel *
mm_broadband_modem_quectel_new (const gchar *device,
const gchar **drivers,
const gchar *plugin,
guint16 vendor_id,
guint16 product_id)
{
return g_object_new (MM_TYPE_BROADBAND_MODEM_QUECTEL,
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,
/* Generic bearer supports TTY only */
MM_BASE_MODEM_DATA_NET_SUPPORTED, FALSE,
MM_BASE_MODEM_DATA_TTY_SUPPORTED, TRUE,
MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, TRUE,
NULL);
}
static void
mm_broadband_modem_quectel_init (MMBroadbandModemQuectel *self)
{
}
static void
iface_modem_init (MMIfaceModem *iface)
{
iface_modem_parent = g_type_interface_peek_parent (iface);
iface->setup_sim_hot_swap = mm_shared_quectel_setup_sim_hot_swap;
iface->setup_sim_hot_swap_finish = mm_shared_quectel_setup_sim_hot_swap_finish;
iface->cleanup_sim_hot_swap = mm_shared_quectel_cleanup_sim_hot_swap;
}
static MMIfaceModem *
peek_parent_modem_interface (MMSharedQuectel *self)
{
return iface_modem_parent;
}
static MMBroadbandModemClass *
peek_parent_broadband_modem_class (MMSharedQuectel *self)
{
return MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_quectel_parent_class);
}
static void
iface_modem_firmware_init (MMIfaceModemFirmware *iface)
{
iface->load_update_settings = mm_shared_quectel_firmware_load_update_settings;
iface->load_update_settings_finish = mm_shared_quectel_firmware_load_update_settings_finish;
}
static void
iface_modem_location_init (MMIfaceModemLocation *iface)
{
iface_modem_location_parent = g_type_interface_peek_parent (iface);
iface->load_capabilities = mm_shared_quectel_location_load_capabilities;
iface->load_capabilities_finish = mm_shared_quectel_location_load_capabilities_finish;
iface->enable_location_gathering = mm_shared_quectel_enable_location_gathering;
iface->enable_location_gathering_finish = mm_shared_quectel_enable_location_gathering_finish;
iface->disable_location_gathering = mm_shared_quectel_disable_location_gathering;
iface->disable_location_gathering_finish = mm_shared_quectel_disable_location_gathering_finish;
}
static MMIfaceModemLocation *
peek_parent_modem_location_interface (MMSharedQuectel *self)
{
return iface_modem_location_parent;
}
static void
iface_modem_time_init (MMIfaceModemTime *iface)
{
iface->check_support = mm_shared_quectel_time_check_support;
iface->check_support_finish = mm_shared_quectel_time_check_support_finish;
}
static void
shared_quectel_init (MMSharedQuectel *iface)
{
iface->peek_parent_modem_interface = peek_parent_modem_interface;
iface->peek_parent_modem_location_interface = peek_parent_modem_location_interface;
iface->peek_parent_broadband_modem_class = peek_parent_broadband_modem_class;
}
static void
mm_broadband_modem_quectel_class_init (MMBroadbandModemQuectelClass *klass)
{
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
broadband_modem_class->setup_ports = mm_shared_quectel_setup_ports;
}
@@ -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) 2018 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_BROADBAND_MODEM_QUECTEL_H
#define MM_BROADBAND_MODEM_QUECTEL_H
#include "mm-broadband-modem.h"
#define MM_TYPE_BROADBAND_MODEM_QUECTEL (mm_broadband_modem_quectel_get_type ())
#define MM_BROADBAND_MODEM_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_QUECTEL, MMBroadbandModemQuectel))
#define MM_BROADBAND_MODEM_QUECTEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_QUECTEL, MMBroadbandModemQuectelClass))
#define MM_IS_BROADBAND_MODEM_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_QUECTEL))
#define MM_IS_BROADBAND_MODEM_QUECTEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_QUECTEL))
#define MM_BROADBAND_MODEM_QUECTEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_QUECTEL, MMBroadbandModemQuectelClass))
typedef struct _MMBroadbandModemQuectel MMBroadbandModemQuectel;
typedef struct _MMBroadbandModemQuectelClass MMBroadbandModemQuectelClass;
struct _MMBroadbandModemQuectel {
MMBroadbandModem parent;
};
struct _MMBroadbandModemQuectelClass{
MMBroadbandModemClass parent;
};
GType mm_broadband_modem_quectel_get_type (void);
MMBroadbandModemQuectel *mm_broadband_modem_quectel_new (const gchar *device,
const gchar **drivers,
const gchar *plugin,
guint16 vendor_id,
guint16 product_id);
#endif /* MM_BROADBAND_MODEM_QUECTEL_H */
@@ -0,0 +1,91 @@
/* -*- 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) 2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <glib.h>
#include <ModemManager.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-log.h"
#include "mm-modem-helpers.h"
#include "mm-modem-helpers-quectel.h"
gboolean
mm_quectel_parse_ctzu_test_response (const gchar *response,
gpointer log_object,
gboolean *supports_disable,
gboolean *supports_enable,
gboolean *supports_enable_update_rtc,
GError **error)
{
g_auto(GStrv) split = NULL;
g_autoptr(GArray) modes = NULL;
guint i;
/*
* Response may be:
* - +CTZU: (0,1)
* - +CTZU: (0,1,3)
*/
#define N_EXPECTED_GROUPS 1
split = mm_split_string_groups (mm_strip_tag (response, "+CTZU:"));
if (!split) {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't split the +CTZU test response in groups");
return FALSE;
}
if (g_strv_length (split) != N_EXPECTED_GROUPS) {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Cannot parse +CTZU test response: invalid number of groups (%u != %u)",
g_strv_length (split), N_EXPECTED_GROUPS);
return FALSE;
}
modes = mm_parse_uint_list (split[0], error);
if (!modes) {
g_prefix_error (error, "Failed to parse integer list in +CTZU test response: ");
return FALSE;
}
*supports_disable = FALSE;
*supports_enable = FALSE;
*supports_enable_update_rtc = FALSE;
for (i = 0; i < modes->len; i++) {
guint mode;
mode = g_array_index (modes, guint, i);
switch (mode) {
case 0:
*supports_disable = TRUE;
break;
case 1:
*supports_enable = TRUE;
break;
case 3:
*supports_enable_update_rtc = TRUE;
break;
default:
mm_obj_dbg (log_object, "unknown +CTZU mode: %u", mode);
break;
}
}
return TRUE;
}
@@ -0,0 +1,32 @@
/* -*- 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) 2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_MODEM_HELPERS_QUECTEL_H
#define MM_MODEM_HELPERS_QUECTEL_H
#include <glib.h>
#include <ModemManager.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
gboolean mm_quectel_parse_ctzu_test_response (const gchar *response,
gpointer log_object,
gboolean *supports_disable,
gboolean *supports_enable,
gboolean *supports_enable_update_rtc,
GError **error);
#endif /* MM_MODEM_HELPERS_QUECTEL_H */
+117
View File
@@ -0,0 +1,117 @@
/* -*- 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) 2017-2018 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <stdlib.h>
#include <gmodule.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-log-object.h"
#include "mm-plugin-quectel.h"
#include "mm-broadband-modem-quectel.h"
#if defined WITH_QMI
#include "mm-broadband-modem-qmi-quectel.h"
#endif
#if defined WITH_MBIM
#include "mm-broadband-modem-mbim.h"
#include "mm-broadband-modem-mbim-quectel.h"
#endif
G_DEFINE_TYPE (MMPluginQuectel, mm_plugin_quectel, 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 Quectel modem found...");
return MM_BASE_MODEM (mm_broadband_modem_qmi_quectel_new (uid,
drivers,
mm_plugin_get_name (self),
vendor,
product));
}
#endif
#if defined WITH_MBIM
if (mm_port_probe_list_has_mbim_port (probes)) {
mm_obj_dbg (self, "MBIM-powered Quectel modem found...");
return MM_BASE_MODEM (mm_broadband_modem_mbim_quectel_new (uid,
drivers,
mm_plugin_get_name (self),
vendor,
product));
}
#endif
return MM_BASE_MODEM (mm_broadband_modem_quectel_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", "wwan", NULL };
static const gchar *vendor_strings[] = { "quectel", NULL };
static const guint16 vendor_ids[] = {
0x2c7c, /* usb vid */
0x1eac, /* pci vid */
0 };
return MM_PLUGIN (
g_object_new (MM_TYPE_PLUGIN_QUECTEL,
MM_PLUGIN_NAME, MM_MODULE_NAME,
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
MM_PLUGIN_ALLOWED_VENDOR_STRINGS, vendor_strings,
MM_PLUGIN_ALLOWED_AT, TRUE,
MM_PLUGIN_REQUIRED_QCDM, TRUE,
MM_PLUGIN_ALLOWED_QMI, TRUE,
MM_PLUGIN_ALLOWED_MBIM, TRUE,
NULL));
}
static void
mm_plugin_quectel_init (MMPluginQuectel *self)
{
}
static void
mm_plugin_quectel_class_init (MMPluginQuectelClass *klass)
{
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
}
+40
View File
@@ -0,0 +1,40 @@
/* -*- 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) 2017 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_PLUGIN_QUECTEL_H
#define MM_PLUGIN_QUECTEL_H
#include "mm-plugin.h"
#define MM_TYPE_PLUGIN_QUECTEL (mm_plugin_quectel_get_type ())
#define MM_PLUGIN_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_QUECTEL, MMPluginQuectel))
#define MM_PLUGIN_QUECTEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_QUECTEL, MMPluginQuectelClass))
#define MM_IS_PLUGIN_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_QUECTEL))
#define MM_IS_PLUGIN_QUECTEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_QUECTEL))
#define MM_PLUGIN_QUECTEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_QUECTEL, MMPluginQuectelClass))
typedef struct {
MMPlugin parent;
} MMPluginQuectel;
typedef struct {
MMPluginClass parent;
} MMPluginQuectelClass;
GType mm_plugin_quectel_get_type (void);
G_MODULE_EXPORT MMPlugin *mm_plugin_create (void);
#endif /* MM_PLUGIN_QUECTEL_H */
File diff suppressed because it is too large Load Diff
+93
View File
@@ -0,0 +1,93 @@
/* -*- 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) 2018-2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_SHARED_QUECTEL_H
#define MM_SHARED_QUECTEL_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-firmware.h"
#include "mm-iface-modem-location.h"
#include "mm-iface-modem-time.h"
#define MM_TYPE_SHARED_QUECTEL (mm_shared_quectel_get_type ())
#define MM_SHARED_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SHARED_QUECTEL, MMSharedQuectel))
#define MM_IS_SHARED_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SHARED_QUECTEL))
#define MM_SHARED_QUECTEL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_SHARED_QUECTEL, MMSharedQuectel))
typedef struct _MMSharedQuectel MMSharedQuectel;
struct _MMSharedQuectel {
GTypeInterface g_iface;
MMBroadbandModemClass * (* peek_parent_broadband_modem_class) (MMSharedQuectel *self);
MMIfaceModem * (* peek_parent_modem_interface) (MMSharedQuectel *self);
MMIfaceModemLocation * (* peek_parent_modem_location_interface) (MMSharedQuectel *self);
};
GType mm_shared_quectel_get_type (void);
void mm_shared_quectel_setup_ports (MMBroadbandModem *self);
void mm_shared_quectel_firmware_load_update_settings (MMIfaceModemFirmware *self,
GAsyncReadyCallback callback,
gpointer user_data);
MMFirmwareUpdateSettings *mm_shared_quectel_firmware_load_update_settings_finish (MMIfaceModemFirmware *self,
GAsyncResult *res,
GError **error);
void mm_shared_quectel_setup_sim_hot_swap (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_shared_quectel_setup_sim_hot_swap_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
void mm_shared_quectel_cleanup_sim_hot_swap (MMIfaceModem *self);
void mm_shared_quectel_location_load_capabilities (MMIfaceModemLocation *self,
GAsyncReadyCallback callback,
gpointer user_data);
MMModemLocationSource mm_shared_quectel_location_load_capabilities_finish (MMIfaceModemLocation *self,
GAsyncResult *res,
GError **error);
void mm_shared_quectel_enable_location_gathering (MMIfaceModemLocation *self,
MMModemLocationSource source,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_shared_quectel_enable_location_gathering_finish (MMIfaceModemLocation *self,
GAsyncResult *res,
GError **error);
void mm_shared_quectel_disable_location_gathering (MMIfaceModemLocation *self,
MMModemLocationSource source,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_shared_quectel_disable_location_gathering_finish (MMIfaceModemLocation *self,
GAsyncResult *res,
GError **error);
void mm_shared_quectel_time_check_support (MMIfaceModemTime *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_shared_quectel_time_check_support_finish (MMIfaceModemTime *self,
GAsyncResult *res,
GError **error);
#endif /* MM_SHARED_QUECTEL_H */
@@ -0,0 +1,93 @@
/* -*- 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) 2020 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 <math.h>
#include "mm-log-test.h"
#include "mm-modem-helpers.h"
#include "mm-modem-helpers-quectel.h"
/*****************************************************************************/
/* Test ^CTZU test responses */
typedef struct {
const gchar *response;
gboolean expect_supports_disable;
gboolean expect_supports_enable;
gboolean expect_supports_enable_update_rtc;
} TestCtzuResponse;
static const TestCtzuResponse test_ctzu_response[] = {
{ "+CTZU: (0,1)", TRUE, TRUE, FALSE },
{ "+CTZU: (0,1,3)", TRUE, TRUE, TRUE },
};
static void
common_test_ctzu (const gchar *response,
gboolean expect_supports_disable,
gboolean expect_supports_enable,
gboolean expect_supports_enable_update_rtc)
{
g_autoptr(GError) error = NULL;
gboolean res;
gboolean supports_disable = FALSE;
gboolean supports_enable = FALSE;
gboolean supports_enable_update_rtc = FALSE;
res = mm_quectel_parse_ctzu_test_response (response,
NULL,
&supports_disable,
&supports_enable,
&supports_enable_update_rtc,
&error);
g_assert_no_error (error);
g_assert (res);
g_assert_cmpuint (expect_supports_disable, ==, supports_disable);
g_assert_cmpuint (expect_supports_enable, ==, supports_enable);
g_assert_cmpuint (expect_supports_enable_update_rtc, ==, supports_enable_update_rtc);
}
static void
test_ctzu (void)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (test_ctzu_response); i++)
common_test_ctzu (test_ctzu_response[i].response,
test_ctzu_response[i].expect_supports_disable,
test_ctzu_response[i].expect_supports_enable,
test_ctzu_response[i].expect_supports_enable_update_rtc);
}
/*****************************************************************************/
int main (int argc, char **argv)
{
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/MM/quectel/ctzu", test_ctzu);
return g_test_run ();
}