mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-29 23:32:14 +02:00
New upstream release 0.0.3
This commit is contained in:
3
src/at.c
3
src/at.c
@@ -206,7 +206,8 @@ int at_init(struct EG25Manager *manager)
|
|||||||
void at_destroy(struct EG25Manager *manager)
|
void at_destroy(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
g_source_remove(manager->at_source);
|
g_source_remove(manager->at_source);
|
||||||
close(manager->at_fd);
|
if (manager->at_fd > 0)
|
||||||
|
close(manager->at_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void at_sequence_configure(struct EG25Manager *manager)
|
void at_sequence_configure(struct EG25Manager *manager)
|
||||||
|
14
src/gpio.c
14
src/gpio.c
@@ -189,10 +189,18 @@ void gpio_destroy(struct EG25Manager *manager)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < GPIO_OUT_COUNT; i++)
|
for (i = 0; i < GPIO_OUT_COUNT; i++) {
|
||||||
gpiod_line_release(manager->gpio_out[i]);
|
if (manager->gpio_out[i])
|
||||||
|
gpiod_line_release(manager->gpio_out[i]);
|
||||||
|
}
|
||||||
|
|
||||||
gpiod_chip_close(manager->gpiochip[0]);
|
for (i = 0; i < GPIO_IN_COUNT; i++) {
|
||||||
|
if (manager->gpio_in[i])
|
||||||
|
gpiod_line_release(manager->gpio_in[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (manager->gpiochip[0])
|
||||||
|
gpiod_chip_close(manager->gpiochip[0]);
|
||||||
if (manager->gpiochip[1])
|
if (manager->gpiochip[1])
|
||||||
gpiod_chip_close(manager->gpiochip[1]);
|
gpiod_chip_close(manager->gpiochip[1]);
|
||||||
}
|
}
|
||||||
|
@@ -17,39 +17,29 @@
|
|||||||
|
|
||||||
#include <glib-unix.h>
|
#include <glib-unix.h>
|
||||||
|
|
||||||
static gboolean quit_timeout_cb(struct EG25Manager *manager)
|
|
||||||
{
|
|
||||||
g_message("Modem down, quitting...");
|
|
||||||
g_main_loop_quit(manager->loop);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean gpio_poll_cb(struct EG25Manager *manager)
|
|
||||||
{
|
|
||||||
if (gpio_check_poweroff(manager)) {
|
|
||||||
quit_timeout_cb(manager);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean quit_app(struct EG25Manager *manager)
|
static gboolean quit_app(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
g_message("Request to quit...");
|
g_message("Request to quit...");
|
||||||
|
|
||||||
|
at_destroy(manager);
|
||||||
|
mm_iface_destroy(manager);
|
||||||
|
suspend_destroy(manager);
|
||||||
|
|
||||||
if (manager->modem_state >= EG25_STATE_STARTED) {
|
if (manager->modem_state >= EG25_STATE_STARTED) {
|
||||||
g_message("Powering down the modem...");
|
g_message("Powering down the modem...");
|
||||||
gpio_sequence_shutdown(manager);
|
gpio_sequence_shutdown(manager);
|
||||||
manager->modem_state = EG25_STATE_FINISHING;
|
manager->modem_state = EG25_STATE_FINISHING;
|
||||||
g_timeout_add(500, G_SOURCE_FUNC(gpio_poll_cb), manager);
|
for (i = 0; i < 30; i++) {
|
||||||
g_timeout_add_seconds(30, G_SOURCE_FUNC(quit_timeout_cb), manager);
|
if (gpio_check_poweroff(manager))
|
||||||
|
break;
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
g_message("Modem down, quitting...");
|
||||||
|
|
||||||
mm_iface_destroy(manager);
|
g_main_loop_quit(manager->loop);
|
||||||
suspend_destroy(manager);
|
|
||||||
g_bus_unwatch_name(manager->mm_watch);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -160,7 +150,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
g_main_loop_run(manager.loop);
|
g_main_loop_run(manager.loop);
|
||||||
|
|
||||||
at_destroy(&manager);
|
|
||||||
gpio_destroy(&manager);
|
gpio_destroy(&manager);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -47,6 +47,9 @@ static void add_modem(struct EG25Manager *manager, GDBusObject *object)
|
|||||||
modem_configure(manager);
|
modem_configure(manager);
|
||||||
|
|
||||||
path = mm_modem_get_device(manager->mm_modem);
|
path = mm_modem_get_device(manager->mm_modem);
|
||||||
|
|
||||||
|
if (manager->modem_usb_id)
|
||||||
|
g_free(manager->modem_usb_id);
|
||||||
manager->modem_usb_id = g_strdup(strrchr(path, '/') + 1);
|
manager->modem_usb_id = g_strdup(strrchr(path, '/') + 1);
|
||||||
|
|
||||||
gdbus_modem = MM_GDBUS_MODEM(manager->mm_modem);
|
gdbus_modem = MM_GDBUS_MODEM(manager->mm_modem);
|
||||||
@@ -189,5 +192,12 @@ void mm_iface_init(struct EG25Manager *manager)
|
|||||||
|
|
||||||
void mm_iface_destroy(struct EG25Manager *manager)
|
void mm_iface_destroy(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
g_clear_object(&manager->mm_manager);
|
if (manager->mm_manager) {
|
||||||
|
g_clear_object(&manager->mm_manager);
|
||||||
|
manager->mm_manager = NULL;
|
||||||
|
}
|
||||||
|
if (manager->mm_watch != 0) {
|
||||||
|
g_bus_unwatch_name(manager->mm_watch);
|
||||||
|
manager->mm_watch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -114,11 +114,12 @@ static void name_owner_cb(GObject *object,
|
|||||||
g_assert(proxy == manager->suspend_proxy);
|
g_assert(proxy == manager->suspend_proxy);
|
||||||
|
|
||||||
owner = g_dbus_proxy_get_name_owner(proxy);
|
owner = g_dbus_proxy_get_name_owner(proxy);
|
||||||
if (owner)
|
if (owner) {
|
||||||
take_inhibitor(manager);
|
take_inhibitor(manager);
|
||||||
else
|
g_free(owner);
|
||||||
|
} else {
|
||||||
drop_inhibitor(manager);
|
drop_inhibitor(manager);
|
||||||
g_free(owner);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_proxy_acquired(GObject *object,
|
static void on_proxy_acquired(GObject *object,
|
||||||
@@ -139,9 +140,10 @@ static void on_proxy_acquired(GObject *object,
|
|||||||
g_signal_connect(manager->suspend_proxy, "g-signal", G_CALLBACK(signal_cb), manager);
|
g_signal_connect(manager->suspend_proxy, "g-signal", G_CALLBACK(signal_cb), manager);
|
||||||
|
|
||||||
owner = g_dbus_proxy_get_name_owner(manager->suspend_proxy);
|
owner = g_dbus_proxy_get_name_owner(manager->suspend_proxy);
|
||||||
if (owner)
|
if (owner) {
|
||||||
take_inhibitor(manager);
|
take_inhibitor(manager);
|
||||||
g_free(owner);
|
g_free(owner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void suspend_init(struct EG25Manager *manager)
|
void suspend_init(struct EG25Manager *manager)
|
||||||
@@ -156,7 +158,10 @@ void suspend_init(struct EG25Manager *manager)
|
|||||||
void suspend_destroy(struct EG25Manager *manager)
|
void suspend_destroy(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
drop_inhibitor(manager);
|
drop_inhibitor(manager);
|
||||||
g_object_unref(manager->suspend_proxy);
|
if (manager->suspend_proxy) {
|
||||||
|
g_object_unref(manager->suspend_proxy);
|
||||||
|
manager->suspend_proxy = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void suspend_inhibit(struct EG25Manager *manager, gboolean inhibit)
|
void suspend_inhibit(struct EG25Manager *manager, gboolean inhibit)
|
||||||
|
Reference in New Issue
Block a user