Allow to build without mmglib

This commit is contained in:
Adam Pigg
2021-03-31 20:13:27 +01:00
parent ea19b0271c
commit 40136c2a52
6 changed files with 38 additions and 8 deletions

View File

@@ -53,9 +53,13 @@ mgr_deps = [
dependency('gudev-1.0'),
dependency('libgpiod'),
dependency('libusb-1.0'),
dependency('mm-glib'),
]
mmglib_dep = dependency('mm-glib', required : false)
if mmglib_dep.found()
add_global_arguments('-DHAVE_MMGLIB=1', language : 'c')
endif
subdir('data')
subdir('src')
subdir('udev')

View File

@@ -77,12 +77,14 @@ static gboolean send_at_command(struct EG25Manager *manager)
g_message("Sending command: %s", g_strstrip(command));
} else if (manager->modem_state < EG25_STATE_CONFIGURED) {
if (manager->modem_iface == MODEM_IFACE_MODEMMANAGER) {
#ifdef HAVE_MMGLIB
MMModemState modem_state = mm_modem_get_state(manager->mm_modem);
if (manager->mm_modem && modem_state >= MM_MODEM_STATE_REGISTERED)
modem_update_state(manager, modem_state);
else
manager->modem_state = EG25_STATE_CONFIGURED;
#endif
} else {
manager->modem_state = EG25_STATE_CONFIGURED;
}

View File

@@ -7,7 +7,11 @@
#include "at.h"
#include "gpio.h"
#include "manager.h"
#ifdef HAVE_MMGLIB
#include "mm-iface.h"
#endif
#include "ofono-iface.h"
#include "suspend.h"
#include "udev.h"
@@ -35,7 +39,9 @@ static gboolean quit_app(struct EG25Manager *manager)
g_message("Request to quit...");
at_destroy(manager);
#ifdef HAVE_MMGLIB
mm_iface_destroy(manager);
#endif
ofono_iface_destroy(manager);
suspend_destroy(manager);
udev_destroy(manager);
@@ -100,6 +106,7 @@ static gboolean modem_start(struct EG25Manager *manager)
return FALSE;
}
#ifdef HAVE_MMGLIB
void modem_update_state(struct EG25Manager *manager, MMModemState state)
{
switch (state) {
@@ -116,6 +123,7 @@ void modem_update_state(struct EG25Manager *manager, MMModemState state)
break;
}
}
#endif
void modem_configure(struct EG25Manager *manager)
{
@@ -328,7 +336,9 @@ int main(int argc, char *argv[])
at_init(&manager, toml_table_in(toml_config, "at"));
gpio_init(&manager, toml_table_in(toml_config, "gpio"));
#ifdef HAVE_MMGLIB
mm_iface_init(&manager, toml_table_in(toml_config, "mm-iface"));
#endif
ofono_iface_init(&manager);
suspend_init(&manager, toml_table_in(toml_config, "suspend"));
udev_init(&manager, toml_table_in(toml_config, "udev"));

View File

@@ -9,7 +9,9 @@
#include <glib.h>
#include <gpiod.h>
#include <gudev/gudev.h>
#ifdef HAVE_MMGLIB
#include <libmm-glib.h>
#endif
#include <libgdbofono/gdbo-manager.h>
#include "toml.h"
@@ -51,9 +53,10 @@ struct EG25Manager {
enum ModemIface modem_iface;
guint mm_watch;
#ifdef HAVE_MMGLIB
MMManager *mm_manager;
MMModem *mm_modem;
#endif
guint ofono_watch;
GDBOManager *ofono_manager;
GDBusConnection *ofono_connection;
@@ -80,4 +83,6 @@ void modem_suspend_pre(struct EG25Manager *data);
void modem_suspend_post(struct EG25Manager *data);
void modem_resume_pre(struct EG25Manager *data);
void modem_resume_post(struct EG25Manager *data);
#ifdef HAVE_MMGLIB
void modem_update_state(struct EG25Manager *data, MMModemState state);
#endif

View File

@@ -7,18 +7,23 @@
subdir('libgdbofono')
executable (
'eg25manager',
[
src = [
'at.c', 'at.h',
'gpio.c', 'gpio.h',
'manager.c', 'manager.h',
'mm-iface.c', 'mm-iface.h',
'ofono-iface.c', 'ofono-iface.h',
'suspend.c', 'suspend.h',
'toml.c', 'toml.h',
'udev.c', 'udev.h',
],
]
if mmglib_dep.found()
src += ['mm-iface.c', 'mm-iface.h']
endif
executable (
'eg25manager',
src,
dependencies : mgr_deps,
link_with: gdbofono_lib,
install : true

View File

@@ -170,7 +170,11 @@ static void signal_cb(GDBusProxy *proxy,
g_message("system is resuming");
take_inhibitor(manager, FALSE);
modem_resume_pre(manager);
if (manager->mm_modem || manager->modem_iface == MODEM_IFACE_OFONO) {
if (
#ifdef HAVE_MMGLIB
manager->mm_modem ||
#endif
manager->modem_iface == MODEM_IFACE_OFONO) {
/*
* On some systems ModemManager doesn't handle suspend/resume, so
* we still have a valid/managed modem when resuming. In this case,