base-modem: make public the method to get best AT port
Sometimes, we want to check whether a given port is available to send commands, and fallback to some other method if so (e.g. using a QCDM port).
This commit is contained in:
@@ -21,32 +21,6 @@
|
|||||||
#include "mm-base-modem-at.h"
|
#include "mm-base-modem-at.h"
|
||||||
#include "mm-errors-types.h"
|
#include "mm-errors-types.h"
|
||||||
|
|
||||||
static MMAtSerialPort *
|
|
||||||
base_modem_at_get_best_port (MMBaseModem *self,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
MMAtSerialPort *port;
|
|
||||||
|
|
||||||
/* Decide which port to use */
|
|
||||||
port = mm_base_modem_get_port_primary (self);
|
|
||||||
g_assert (port);
|
|
||||||
if (mm_port_get_connected (MM_PORT (port))) {
|
|
||||||
/* If primary port is connected, check if we can get the secondary
|
|
||||||
* port */
|
|
||||||
port = mm_base_modem_get_port_secondary (self);
|
|
||||||
if (!port) {
|
|
||||||
/* If we don't have a secondary port, we need to halt the AT
|
|
||||||
* operation */
|
|
||||||
g_set_error (error,
|
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_CONNECTED,
|
|
||||||
"No AT port available to run command");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
abort_async_if_port_unusable (MMBaseModem *self,
|
abort_async_if_port_unusable (MMBaseModem *self,
|
||||||
MMAtSerialPort *port,
|
MMAtSerialPort *port,
|
||||||
@@ -298,7 +272,7 @@ mm_base_modem_at_sequence (MMBaseModem *self,
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
/* No port given, so we'll try to guess which is best */
|
/* No port given, so we'll try to guess which is best */
|
||||||
port = base_modem_at_get_best_port (self, &error);
|
port = mm_base_modem_get_best_at_port (self, &error);
|
||||||
if (!port) {
|
if (!port) {
|
||||||
g_assert (error != NULL);
|
g_assert (error != NULL);
|
||||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
||||||
@@ -504,7 +478,7 @@ mm_base_modem_at_command (MMBaseModem *self,
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
/* No port given, so we'll try to guess which is best */
|
/* No port given, so we'll try to guess which is best */
|
||||||
port = base_modem_at_get_best_port (self, &error);
|
port = mm_base_modem_get_best_at_port (self, &error);
|
||||||
if (!port) {
|
if (!port) {
|
||||||
g_assert (error != NULL);
|
g_assert (error != NULL);
|
||||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
||||||
@@ -553,7 +527,7 @@ mm_base_modem_at_command_ignore_reply (MMBaseModem *self,
|
|||||||
MMAtSerialPort *port;
|
MMAtSerialPort *port;
|
||||||
|
|
||||||
/* No port given, so we'll try to guess which is best */
|
/* No port given, so we'll try to guess which is best */
|
||||||
port = base_modem_at_get_best_port (self, NULL);
|
port = mm_base_modem_get_best_at_port (self, NULL);
|
||||||
if (!port)
|
if (!port)
|
||||||
/* No valid port, and we ignore replies, so just exit. */
|
/* No valid port, and we ignore replies, so just exit. */
|
||||||
return;
|
return;
|
||||||
|
@@ -435,6 +435,32 @@ mm_base_modem_get_best_data_port (MMBaseModem *self)
|
|||||||
self->priv->data);
|
self->priv->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMAtSerialPort *
|
||||||
|
mm_base_modem_get_best_at_port (MMBaseModem *self,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MMAtSerialPort *port;
|
||||||
|
|
||||||
|
/* Decide which port to use */
|
||||||
|
port = mm_base_modem_get_port_primary (self);
|
||||||
|
g_assert (port);
|
||||||
|
if (mm_port_get_connected (MM_PORT (port))) {
|
||||||
|
/* If primary port is connected, check if we can get the secondary
|
||||||
|
* port */
|
||||||
|
port = mm_base_modem_get_port_secondary (self);
|
||||||
|
if (!port) {
|
||||||
|
/* If we don't have a secondary port, we need to halt the AT
|
||||||
|
* operation */
|
||||||
|
g_set_error (error,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_CONNECTED,
|
||||||
|
"No port available to run command");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mm_base_modem_auth_request (MMBaseModem *self,
|
mm_base_modem_auth_request (MMBaseModem *self,
|
||||||
const gchar *authorization,
|
const gchar *authorization,
|
||||||
|
@@ -108,6 +108,8 @@ MMAtSerialPort *mm_base_modem_get_port_primary (MMBaseModem *self);
|
|||||||
MMAtSerialPort *mm_base_modem_get_port_secondary (MMBaseModem *self);
|
MMAtSerialPort *mm_base_modem_get_port_secondary (MMBaseModem *self);
|
||||||
MMQcdmSerialPort *mm_base_modem_get_port_qcdm (MMBaseModem *self);
|
MMQcdmSerialPort *mm_base_modem_get_port_qcdm (MMBaseModem *self);
|
||||||
MMPort *mm_base_modem_get_best_data_port (MMBaseModem *self);
|
MMPort *mm_base_modem_get_best_data_port (MMBaseModem *self);
|
||||||
|
MMAtSerialPort *mm_base_modem_get_best_at_port (MMBaseModem *self,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
void mm_base_modem_set_valid (MMBaseModem *self,
|
void mm_base_modem_set_valid (MMBaseModem *self,
|
||||||
gboolean valid);
|
gboolean valid);
|
||||||
|
Reference in New Issue
Block a user