110
118
char *probe_resp;
111
119
GError *probe_error;
114
guint32 custom_init_max_tries;
115
guint32 custom_init_tries;
116
guint32 custom_init_delay_seconds;
117
gboolean custom_init_fail_if_timeout;
121
/* Custom init commands plugins might want */
123
GSList *cur_custom; /* Pointer to current custom init command */
119
125
MMSupportsPortResultFunc callback;
120
126
gpointer callback_data;
228
mm_plugin_base_supports_task_set_custom_init_command (MMPluginBaseSupportsTask *task,
234
mm_plugin_base_supports_task_add_custom_init_command (MMPluginBaseSupportsTask *task,
230
236
guint32 delay_seconds,
232
gboolean fail_if_timeout)
237
MMBaseSupportsTaskCustomInitResultFunc callback,
238
gpointer callback_data)
234
240
MMPluginBaseSupportsTaskPrivate *priv;
236
243
g_return_if_fail (task != NULL);
237
244
g_return_if_fail (MM_IS_PLUGIN_BASE_SUPPORTS_TASK (task));
245
g_return_if_fail (callback != NULL);
239
247
priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task);
241
g_free (priv->custom_init);
242
priv->custom_init = g_strdup (cmd);
243
priv->custom_init_max_tries = max_tries;
244
priv->custom_init_delay_seconds = delay_seconds;
245
priv->custom_init_fail_if_timeout = fail_if_timeout;
249
custom = g_malloc0 (sizeof (*custom));
250
custom->command = g_strdup (cmd);
251
custom->delay_seconds = delay_seconds ? delay_seconds : 3;
252
custom->callback = callback;
253
custom->callback_data = callback_data;
255
priv->custom = g_slist_append (priv->custom, custom);
254
264
supports_task_dispose (GObject *object)
256
266
MMPluginBaseSupportsTaskPrivate *priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (object);
258
269
if (MM_IS_SERIAL_PORT (priv->probe_port))
259
270
mm_serial_port_flash_cancel (MM_SERIAL_PORT (priv->probe_port));
263
274
g_free (priv->driver);
264
275
g_free (priv->probe_resp);
265
276
g_clear_error (&(priv->probe_error));
266
g_free (priv->custom_init);
278
for (iter = priv->custom; iter; iter = g_slist_next (iter)) {
279
CustomInit *custom = iter->data;
281
g_free (custom->command);
282
memset (custom, 0, sizeof (*custom));
268
286
if (priv->open_id)
269
287
g_source_remove (priv->open_id);
721
739
task_priv->probe_id = g_idle_add (handle_probe_response, task);
743
start_generic_probing (MMPluginBaseSupportsTask *task, MMAtSerialPort *port)
745
mm_at_serial_port_queue_command (port, "+GCAP", 3, parse_response, task);
724
748
static void flash_done (MMSerialPort *port, GError *error, gpointer user_data);
732
756
MMPluginBaseSupportsTask *task = MM_PLUGIN_BASE_SUPPORTS_TASK (user_data);
733
757
MMPluginBaseSupportsTaskPrivate *task_priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task);
736
task_priv->custom_init_tries++;
737
if (task_priv->custom_init_tries < task_priv->custom_init_max_tries) {
738
/* Try the custom command again */
739
flash_done (MM_SERIAL_PORT (port), NULL, user_data);
741
} else if (task_priv->custom_init_fail_if_timeout) {
742
/* Fail the probe if the plugin wanted it and the command timed out */
743
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
744
probe_complete (task);
750
/* Otherwise proceed to probing */
751
mm_at_serial_port_queue_command (port, "+GCAP", 3, parse_response, user_data);
758
CustomInit *custom = task_priv->cur_custom->data;
759
gboolean retry = FALSE;
760
gboolean fail = FALSE;
764
retry = custom->callback (task, response, error, custom->tries, &fail, &level, custom->callback_data);
767
/* Plugin said to fail the probe */
768
probe_complete (task);
773
/* Plugin supports the modem */
774
task_priv->probed_caps = level;
775
probe_complete (task);
780
/* Try the custom command again */
781
flash_done (MM_SERIAL_PORT (port), NULL, task);
785
/* Any more custom init commands? */
786
task_priv->cur_custom = g_slist_next (task_priv->cur_custom);
787
if (task_priv->cur_custom) {
788
/* There are more custom init commands */
789
flash_done (MM_SERIAL_PORT (port), NULL, task);
793
/* Otherwise continue with generic probing */
794
start_generic_probing (task, port);
757
800
MMPluginBaseSupportsTask *task = MM_PLUGIN_BASE_SUPPORTS_TASK (user_data);
758
801
MMPluginBaseSupportsTaskPrivate *task_priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task);
759
guint32 delay_secs = task_priv->custom_init_delay_seconds;
761
803
/* Send the custom init command if any */
762
if (task_priv->custom_init) {
804
if (task_priv->cur_custom) {
805
CustomInit *custom = task_priv->cur_custom->data;
765
807
mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (port),
766
task_priv->custom_init,
809
custom->delay_seconds,
768
810
custom_init_response,
771
813
/* Otherwise start normal probing */
772
custom_init_response (MM_AT_SERIAL_PORT (port), NULL, NULL, user_data);
814
start_generic_probing (task, MM_AT_SERIAL_PORT (port));
846
889
g_object_set (serial,
847
MM_SERIAL_PORT_SEND_DELAY, (guint64) 100000,
890
MM_SERIAL_PORT_SEND_DELAY, send_delay_us,
848
891
MM_PORT_CARRIER_DETECT, FALSE,
892
MM_SERIAL_PORT_SPEW_CONTROL, TRUE,
851
895
mm_at_serial_port_set_response_parser (serial,