plugin: renamed custom-init' property to custom-at-probe'

The `custom-at-probe' property is just to modify the way we check for AT port
support.
This commit is contained in:
Aleksander Morgado
2012-07-11 06:53:56 +02:00
parent 89b3c01328
commit 9b0f6c83f2
6 changed files with 47 additions and 74 deletions

View File

@@ -171,26 +171,6 @@
prepare the information required in any expected post-probing filter.
</para>
<itemizedlist>
<listitem>
<para><emphasis>Custom AT initialization</emphasis></para>
<para>
This property allows plugins to specify custom initialization sequences to
run in the modem before any additional probing happens. This helps in the cases
where modems require commands to, for example, shutdown unsolicited messages.
</para>
<para>
An additional benefit of the custom initialization through AT commands is that
it can already provide information on whether the port is AT or not. In other
words, a plugin with custom initialization sequence which reports that the
port being initialized is AT won't run the generic checks to see if the port is
AT or not.
</para>
<para>
This configuration is specified by the <type>MM_PLUGIN_CUSTOM_INIT</type>
property in the <structname>MMPlugin</structname> object provided
by the plugin.
</para>
</listitem>
<listitem>
<para><emphasis>AT allowed</emphasis></para>
<para>
@@ -216,6 +196,18 @@
by the plugin.
</para>
</listitem>
<listitem>
<para><emphasis>Custom AT probing</emphasis></para>
<para>
This property allows plugins to specify custom commands to check whether a port
is AT or not. By default, the 'AT' command will be used if no custom one specified.
</para>
<para>
This configuration is specified by the <type>MM_PLUGIN_CUSTOM_AT_PROBE</type>
property in the <structname>MMPlugin</structname> object provided
by the plugin.
</para>
</listitem>
<listitem>
<para><emphasis>QCDM allowed</emphasis></para>
<para>
@@ -352,10 +344,10 @@ mm_plugin_create (void)
<title>Probing setup for a plugin with custom initialization requirements</title>
<programlisting>
static gboolean
parse_init (const gchar *response,
const GError *error,
GValue *result,
GError **result_error)
parse_custom_at (const gchar *response,
const GError *error,
GValue *result,
GError **result_error)
{
if (error) {
*result_error = g_error_copy (error);
@@ -368,8 +360,8 @@ parse_init (const gchar *response,
return TRUE;
}
static const MMPortProbeAtCommand custom_init[] = {
{ "ATE1 E0", parse_init },
static const MMPortProbeAtCommand custom_at_probe[] = {
{ "AT+SOMETHING", parse_custom_at },
{ NULL }
};
@@ -380,7 +372,7 @@ mm_plugin_create (void)
static const guint16 vendor_ids[] = { 0xabcd, 0 };
return MM_PLUGIN (
g_object_new (MM_TYPE_PLUGIN_NOKIA,
g_object_new (MM_TYPE_PLUGIN_EXAMPLE,
MM_PLUGIN_NAME, "Example",
/* Next items are pre-probing filters */
@@ -388,8 +380,8 @@ mm_plugin_create (void)
MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
/* Next items are probing sequence setup */
MM_PLUGIN_CUSTOM_INIT, custom_init,
MM_PLUGIN_ALLOWED_AT, TRUE,
MM_PLUGIN_CUSTOM_AT_PROBE, custom_at_probe,
MM_PLUGIN_ALLOWED_AT, TRUE,
/* No post-probing filters */
NULL));

View File

@@ -30,9 +30,9 @@ int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
/* CUSTOM INIT */
/* Custom commands for AT probing */
static const MMPortProbeAtCommand custom_init[] = {
static const MMPortProbeAtCommand custom_at_probe[] = {
{ "ATE1 E0", 3, mm_port_probe_response_processor_is_at },
{ "ATE1 E0", 3, mm_port_probe_response_processor_is_at },
{ "ATE1 E0", 3, mm_port_probe_response_processor_is_at },
@@ -104,7 +104,7 @@ mm_plugin_create (void)
MM_PLUGIN_NAME, "Nokia",
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
MM_PLUGIN_CUSTOM_INIT, custom_init,
MM_PLUGIN_CUSTOM_AT_PROBE, custom_at_probe,
MM_PLUGIN_ALLOWED_SINGLE_AT, TRUE, /* only 1 AT port expected! */
NULL));
}

View File

@@ -60,7 +60,7 @@ struct _MMPluginPrivate {
gboolean at;
gboolean single_at;
gboolean qcdm;
MMPortProbeAtCommand *custom_init;
MMPortProbeAtCommand *custom_at_probe;
guint64 send_delay;
};
@@ -77,7 +77,7 @@ enum {
PROP_ALLOWED_AT,
PROP_ALLOWED_SINGLE_AT,
PROP_ALLOWED_QCDM,
PROP_CUSTOM_INIT,
PROP_CUSTOM_AT_PROBE,
PROP_SEND_DELAY,
LAST_PROP
};
@@ -524,7 +524,7 @@ mm_plugin_supports_port (MMPlugin *self,
mm_port_probe_run (probe,
ctx->flags,
self->priv->send_delay,
self->priv->custom_init,
self->priv->custom_at_probe,
(GAsyncReadyCallback)port_probe_run_ready,
ctx);
@@ -646,9 +646,9 @@ set_property (GObject *object,
/* Construct only */
self->priv->qcdm = g_value_get_boolean (value);
break;
case PROP_CUSTOM_INIT:
case PROP_CUSTOM_AT_PROBE:
/* Construct only */
self->priv->custom_init = g_value_dup_boxed (value);
self->priv->custom_at_probe = g_value_dup_boxed (value);
break;
case PROP_SEND_DELAY:
/* Construct only */
@@ -702,8 +702,8 @@ get_property (GObject *object,
case PROP_ALLOWED_UDEV_TAGS:
g_value_set_boxed (value, self->priv->udev_tags);
break;
case PROP_CUSTOM_INIT:
g_value_set_boxed (value, self->priv->custom_init);
case PROP_CUSTOM_AT_PROBE:
g_value_set_boxed (value, self->priv->custom_at_probe);
break;
case PROP_SEND_DELAY:
g_value_set_uint64 (value, self->priv->send_delay);
@@ -833,10 +833,10 @@ mm_plugin_class_init (MMPluginClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_CUSTOM_INIT,
g_param_spec_boxed (MM_PLUGIN_CUSTOM_INIT,
"Custom initialization",
"List of custom initializations this plugin needs, "
(object_class, PROP_CUSTOM_AT_PROBE,
g_param_spec_boxed (MM_PLUGIN_CUSTOM_AT_PROBE,
"Custom AT Probe",
"Custom set of commands to probe for AT support, "
"should be an array of MMPortProbeAtCommand structs "
"finished with 'NULL'",
MM_TYPE_POINTER_ARRAY,

View File

@@ -48,7 +48,7 @@
#define MM_PLUGIN_ALLOWED_AT "allowed-at"
#define MM_PLUGIN_ALLOWED_SINGLE_AT "allowed-single-at"
#define MM_PLUGIN_ALLOWED_QCDM "allowed-qcdm"
#define MM_PLUGIN_CUSTOM_INIT "custom-init"
#define MM_PLUGIN_CUSTOM_AT_PROBE "custom-at-probe"
#define MM_PLUGIN_SEND_DELAY "send-delay"
#define MM_PLUGIN_SORT_LAST "sort-last"

View File

@@ -37,7 +37,6 @@
/*
* Steps and flow of the Probing process:
* ----> AT Serial Open
* |----> Custom Init
* |----> AT?
* |----> Vendor
* |----> Product
@@ -69,8 +68,8 @@ typedef struct {
guint64 at_send_delay;
/* Number of times we tried to open the AT port */
guint at_open_tries;
/* Custom initialization commands for the AT port */
const MMPortProbeAtCommand *at_custom_init;
/* Custom commands to look for AT support */
const MMPortProbeAtCommand *at_custom_probe;
/* Current group of AT commands to be sent */
const MMPortProbeAtCommand *at_commands;
/* Current AT Result processor */
@@ -438,21 +437,6 @@ serial_probe_at_result_processor (MMPortProbe *self,
mm_port_probe_set_result_at (self, FALSE);
}
static void
serial_probe_at_custom_init_result_processor (MMPortProbe *self,
GVariant *result)
{
PortProbeRunTask *task = self->priv->task;
/* No result is really expected here, but we could get a boolean to indicate
* AT support */
if (result)
serial_probe_at_result_processor (self, result);
/* Reset so that it doesn't get scheduled again */
task->at_custom_init = NULL;
}
static void
serial_probe_at_parse_response (MMAtSerialPort *port,
GString *response,
@@ -589,18 +573,15 @@ serial_probe_schedule (MMPortProbe *self)
task->at_result_processor = NULL;
task->at_commands = NULL;
/* If we got some custom initialization commands requested, go on with them
* first. */
if (task->at_custom_init) {
task->at_result_processor = serial_probe_at_custom_init_result_processor;
task->at_commands = task->at_custom_init;
}
/* AT check requested and not already probed? */
else if ((task->flags & MM_PORT_PROBE_AT) &&
!(self->priv->flags & MM_PORT_PROBE_AT)) {
if ((task->flags & MM_PORT_PROBE_AT) &&
!(self->priv->flags & MM_PORT_PROBE_AT)) {
/* Prepare AT probing */
if (task->at_custom_probe)
task->at_commands = task->at_custom_probe;
else
task->at_commands = at_probing;
task->at_result_processor = serial_probe_at_result_processor;
task->at_commands = at_probing;
}
/* Vendor requested and not already probed? */
else if ((task->flags & MM_PORT_PROBE_AT_VENDOR) &&
@@ -851,7 +832,7 @@ void
mm_port_probe_run (MMPortProbe *self,
MMPortProbeFlag flags,
guint64 at_send_delay,
const MMPortProbeAtCommand *at_custom_init,
const MMPortProbeAtCommand *at_custom_probe,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -869,7 +850,7 @@ mm_port_probe_run (MMPortProbe *self,
task = g_new0 (PortProbeRunTask, 1);
task->at_send_delay = at_send_delay;
task->flags = MM_PORT_PROBE_NONE;
task->at_custom_init = at_custom_init;
task->at_custom_probe = at_custom_probe;
task->result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,

View File

@@ -78,7 +78,7 @@ void mm_port_probe_set_result_qcdm (MMPortProbe *self,
void mm_port_probe_run (MMPortProbe *self,
MMPortProbeFlag flags,
guint64 at_send_delay,
const MMPortProbeAtCommand *at_custom_init,
const MMPortProbeAtCommand *at_custom_probe,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_port_probe_run_finish (MMPortProbe *self,