Example 1. Probing setup for a plugin requiring udev-based vendor/product checks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
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)); } |