plugin-base: new 'custom-init' property
The plugins can set this property to provide custom initialization commands that should be issued to the modem before real probing starts. The value given to the property should be an array of MMPortProbeAtCommand variables finished with a last one exposing a NULL command, e.g.: static gboolean parse_init (const gchar *response, const GError *error, GValue *result, GError **result_error) { if (error) return FALSE; /* If we didn't get any error, it is an AT port */ g_value_init (result, G_TYPE_BOOLEAN); g_value_set_boolean (result, TRUE); return TRUE; } static gboolean parse_init_last (const gchar *response, const GError *error, GValue *result, GError **result_error) { g_value_init (result, G_TYPE_BOOLEAN); /* On last error, report as not being an AT port */ g_value_set_boolean (result, error ? FALSE : TRUE); return TRUE; } static const MMPortProbeAtCommand custom_init[] = { { "ATE1 E0", parse_init }, { "ATE1 E0", parse_init }, { "ATE1 E0", parse_init_last }, { NULL } };
This commit is contained in:

committed by
Aleksander Morgado

parent
806aabd22d
commit
2d8fb51c6b
@@ -28,6 +28,7 @@
|
|||||||
#include <gudev/gudev.h>
|
#include <gudev/gudev.h>
|
||||||
|
|
||||||
#include "mm-plugin-base.h"
|
#include "mm-plugin-base.h"
|
||||||
|
#include "mm-port-probe.h"
|
||||||
#include "mm-at-serial-port.h"
|
#include "mm-at-serial-port.h"
|
||||||
#include "mm-qcdm-serial-port.h"
|
#include "mm-qcdm-serial-port.h"
|
||||||
#include "mm-serial-parsers.h"
|
#include "mm-serial-parsers.h"
|
||||||
@@ -72,6 +73,7 @@ typedef struct {
|
|||||||
const gchar **subsystems;
|
const gchar **subsystems;
|
||||||
const guint16 *vendor_ids;
|
const guint16 *vendor_ids;
|
||||||
const guint16 *product_ids;
|
const guint16 *product_ids;
|
||||||
|
const MMPortProbeAtCommand *custom_init;
|
||||||
} MMPluginBasePrivate;
|
} MMPluginBasePrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -80,6 +82,7 @@ enum {
|
|||||||
PROP_ALLOWED_SUBSYSTEMS,
|
PROP_ALLOWED_SUBSYSTEMS,
|
||||||
PROP_ALLOWED_VENDOR_IDS,
|
PROP_ALLOWED_VENDOR_IDS,
|
||||||
PROP_ALLOWED_PRODUCT_IDS,
|
PROP_ALLOWED_PRODUCT_IDS,
|
||||||
|
PROP_CUSTOM_INIT,
|
||||||
PROP_SORT_LAST,
|
PROP_SORT_LAST,
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
@@ -1564,6 +1567,10 @@ set_property (GObject *object, guint prop_id,
|
|||||||
/* Construct only */
|
/* Construct only */
|
||||||
priv->product_ids = (const guint16 *)g_value_get_pointer (value);
|
priv->product_ids = (const guint16 *)g_value_get_pointer (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_CUSTOM_INIT:
|
||||||
|
/* Construct only */
|
||||||
|
priv->custom_init = (const MMPortProbeAtCommand *)g_value_get_pointer (value);
|
||||||
|
break;
|
||||||
case PROP_SORT_LAST:
|
case PROP_SORT_LAST:
|
||||||
/* Construct only */
|
/* Construct only */
|
||||||
priv->sort_last = g_value_get_boolean (value);
|
priv->sort_last = g_value_get_boolean (value);
|
||||||
@@ -1593,6 +1600,9 @@ get_property (GObject *object, guint prop_id,
|
|||||||
case PROP_ALLOWED_PRODUCT_IDS:
|
case PROP_ALLOWED_PRODUCT_IDS:
|
||||||
g_value_set_pointer (value, (gpointer)priv->product_ids);
|
g_value_set_pointer (value, (gpointer)priv->product_ids);
|
||||||
break;
|
break;
|
||||||
|
case PROP_CUSTOM_INIT:
|
||||||
|
g_value_set_pointer (value, (gpointer)priv->custom_init);
|
||||||
|
break;
|
||||||
case PROP_SORT_LAST:
|
case PROP_SORT_LAST:
|
||||||
g_value_set_boolean (value, priv->sort_last);
|
g_value_set_boolean (value, priv->sort_last);
|
||||||
break;
|
break;
|
||||||
@@ -1662,6 +1672,15 @@ mm_plugin_base_class_init (MMPluginBaseClass *klass)
|
|||||||
"should be an array of guint16 finished with '0'",
|
"should be an array of guint16 finished with '0'",
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_CUSTOM_INIT,
|
||||||
|
g_param_spec_pointer (MM_PLUGIN_BASE_CUSTOM_INIT,
|
||||||
|
"Custom initialization",
|
||||||
|
"List of custom initializations this plugin needs, "
|
||||||
|
"should be an array of MMPortProbeAtCommand structs "
|
||||||
|
"finished with 'NULL'",
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_SORT_LAST,
|
(object_class, PROP_SORT_LAST,
|
||||||
g_param_spec_boolean (MM_PLUGIN_BASE_SORT_LAST,
|
g_param_spec_boolean (MM_PLUGIN_BASE_SORT_LAST,
|
||||||
|
@@ -112,10 +112,22 @@ void mm_plugin_base_supports_task_add_custom_init_command (MMPluginBaseSupportsT
|
|||||||
#define MM_IS_PLUBIN_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_BASE))
|
#define MM_IS_PLUBIN_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_BASE))
|
||||||
#define MM_PLUGIN_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass))
|
#define MM_PLUGIN_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass))
|
||||||
|
|
||||||
|
/* Structure defining custom commands that the plugins may need to initialize
|
||||||
|
* the devices */
|
||||||
|
typedef struct {
|
||||||
|
/* AT command to send to the modem */
|
||||||
|
gchar *command;
|
||||||
|
/* Number of allowed retries (>= 0) */
|
||||||
|
guint retries;
|
||||||
|
/* Callback to call when reply received */
|
||||||
|
MMBaseSupportsTaskCustomInitResultFunc callback;
|
||||||
|
} MMPluginCustomInit;
|
||||||
|
|
||||||
#define MM_PLUGIN_BASE_NAME "name"
|
#define MM_PLUGIN_BASE_NAME "name"
|
||||||
#define MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS "allowed-subsystems"
|
#define MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS "allowed-subsystems"
|
||||||
#define MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS "allowed-vendor-ids"
|
#define MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS "allowed-vendor-ids"
|
||||||
#define MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS "allowed-product-ids"
|
#define MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS "allowed-product-ids"
|
||||||
|
#define MM_PLUGIN_BASE_CUSTOM_INIT "custom-init"
|
||||||
#define MM_PLUGIN_BASE_SORT_LAST "sort-last"
|
#define MM_PLUGIN_BASE_SORT_LAST "sort-last"
|
||||||
|
|
||||||
typedef struct _MMPluginBase MMPluginBase;
|
typedef struct _MMPluginBase MMPluginBase;
|
||||||
|
Reference in New Issue
Block a user