Example 1. Probing setup for a plugin requiring udev-based vendor/product checks
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
static const gchar *subsystems[] = { "tty", NULL };
static const guint16 vendor_ids[] = { 0xabcd, 0 };
static const mm_uint16_pair product_ids[] = {
{ 0x1234, 0xffff }
};
static const gchar *vendor_strings[] = { "vendor", NULL };
return MM_PLUGIN (
g_object_new (MM_TYPE_PLUGIN_IRIDIUM,
MM_PLUGIN_NAME, "Example",
/* Next items are pre-probing filters */
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
MM_PLUGIN_ALLOWED_PRODUCT_IDS, product_ids,
/* Next items are probing sequence setup */
MM_PLUGIN_ALLOWED_AT, TRUE,
/* No post-probing filters */
NULL));
}
Example 2. Probing setup for a plugin requiring AT-probed vendor/product checks
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
static const gchar *subsystems[] = { "tty", NULL };
static const gchar *vendor_strings[] = { "vendor", NULL };
static const mm_str_pair product_strings[] = { "another-vendor", "product xyz" };
return MM_PLUGIN (
g_object_new (MM_TYPE_PLUGIN_IRIDIUM,
MM_PLUGIN_NAME, "Example",
/* Next items are pre-probing filters */
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
/* Next items are probing sequence setup */
MM_PLUGIN_ALLOWED_AT, TRUE,
/* Next items are post-probing filters */
MM_PLUGIN_VENDOR_STRINGS, vendor_strings,
MM_PLUGIN_PRODUCT_STRINGS, product_strings,
NULL));
}
Example 3. Probing setup for a plugin with custom initialization requirements
static gboolean
parse_custom_at (const gchar *response,
const GError *error,
GValue *result,
GError **result_error)
{
if (error) {
*result_error = g_error_copy (error);
return FALSE;
}
/* Otherwise, done. And also report that it's an AT port. */
g_value_init (result, G_TYPE_BOOLEAN);
g_value_set_boolean (result, TRUE);
return TRUE;
}
static const MMPortProbeAtCommand custom_at_probe[] = {
{ "AT+SOMETHING", parse_custom_at },
{ NULL }
};
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
static const gchar *subsystems[] = { "tty", NULL };
static const guint16 vendor_ids[] = { 0xabcd, 0 };
return MM_PLUGIN (
g_object_new (MM_TYPE_PLUGIN_EXAMPLE,
MM_PLUGIN_NAME, "Example",
/* Next items are pre-probing filters */
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
/* Next items are probing sequence setup */
MM_PLUGIN_CUSTOM_AT_PROBE, custom_at_probe,
MM_PLUGIN_ALLOWED_AT, TRUE,
/* No post-probing filters */
NULL));
}