static gboolean serial_probe_at (MMPortProbe *self) { PortProbeRunTask *task = self->priv->task; task->source_id = 0; /* If already cancelled, do nothing else */ if (port_probe_run_is_cancelled (self)) return FALSE; /* If AT probing cancelled, end this partial probing */ if (g_cancellable_is_cancelled (task->at_probing_cancellable)) { mm_dbg ("(%s) no need to launch probing for AT support", self->priv->name); task->at_result_processor (self, NULL); serial_probe_schedule (self); return FALSE; } mm_at_serial_port_queue_command ( MM_AT_SERIAL_PORT (task->serial), task->at_commands->command, task->at_commands->timeout, task->at_probing_cancellable, (MMAtSerialResponseFn)serial_probe_at_parse_response, self); return FALSE; }
static void serial_flash_done (MMSerialPort *port, GError *error, MMPortProbe *self) { /* Schedule probing */ serial_probe_schedule (self); }
static void serial_buffer_full (MMSerialPort *serial, GByteArray *buffer, MMPortProbe *self) { if (is_non_at_response (buffer->data, buffer->len)) { mm_serial_port_close (serial); mm_port_probe_set_result_at (self, FALSE); serial_probe_schedule (self); } }
static void at_custom_init_ready (MMPortProbe *self, GAsyncResult *res) { PortProbeRunTask *task = self->priv->task; GError *error = NULL; if (!task->at_custom_init_finish (self, res, &error)) { /* All errors propagated up end up forcing an UNSUPPORTED result */ port_probe_run_task_complete (task, FALSE, error); return; } /* Keep on with remaining probings */ task->at_custom_init_run = TRUE; serial_probe_schedule (self); }
static void serial_probe_qcdm_parse_response (MMQcdmSerialPort *port, GByteArray *response, GError *error, MMPortProbe *self) { QcdmResult *result; gint err = QCDM_SUCCESS; gboolean is_qcdm = FALSE; /* Just the initial poke; ignore it */ if (!self) return; /* If already cancelled, do nothing else */ if (port_probe_run_is_cancelled (self)) return; if (!error) { /* Parse the response */ result = qcdm_cmd_version_info_result ((const gchar *) response->data, response->len, &err); if (!result) { mm_warn ("(%s) failed to parse QCDM version info command result: %d", self->priv->name, err); } else { /* yay, probably a QCDM port */ is_qcdm = TRUE; qcdm_result_unref (result); } } /* Set probing result */ mm_port_probe_set_result_qcdm (self, is_qcdm); /* Reschedule probing */ serial_probe_schedule (self); }
static void serial_probe_at_parse_response (MMAtSerialPort *port, GString *response, GError *error, MMPortProbe *self) { PortProbeRunTask *task = self->priv->task; GVariant *result = NULL; GError *result_error = NULL; /* If already cancelled, do nothing else */ if (port_probe_run_is_cancelled (self)) return; /* If AT probing cancelled, end this partial probing */ if (g_cancellable_is_cancelled (task->at_probing_cancellable)) { mm_dbg ("(%s) no need to keep on probing the port for AT support", self->priv->name); task->at_result_processor (self, NULL); serial_probe_schedule (self); return; } if (!task->at_commands->response_processor (task->at_commands->command, response->str, !!task->at_commands[1].command, error, &result, &result_error)) { /* Were we told to abort the whole probing? */ if (result_error) { port_probe_run_task_complete ( task, FALSE, g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "(%s) error while probing AT features: %s", self->priv->name, result_error->message)); g_error_free (result_error); return; } /* Go on to next command */ task->at_commands++; if (!task->at_commands->command) { /* Was it the last command in the group? If so, * end this partial probing */ task->at_result_processor (self, NULL); /* Reschedule */ serial_probe_schedule (self); return; } /* Schedule the next command in the probing group */ task->source_id = g_idle_add ((GSourceFunc)serial_probe_at, self); return; } /* Run result processor. * Note that custom init commands are allowed to not return anything */ task->at_result_processor (self, result); if (result) g_variant_unref (result); /* Reschedule probing */ serial_probe_schedule (self); }
static void serial_probe_qcdm_parse_response (MMQcdmSerialPort *port, GByteArray *response, GError *error, MMPortProbe *self) { QcdmResult *result; gint err = QCDM_SUCCESS; gboolean is_qcdm = FALSE; gboolean retry = FALSE; PortProbeRunTask *task = self->priv->task; /* If already cancelled, do nothing else */ if (port_probe_run_is_cancelled (self)) return; if (!error) { /* Parse the response */ result = qcdm_cmd_version_info_result ((const gchar *) response->data, response->len, &err); if (!result) { mm_warn ("(%s/%s) failed to parse QCDM version info command result: %d", g_udev_device_get_subsystem (self->priv->port), g_udev_device_get_name (self->priv->port), err); retry = TRUE; } else { /* yay, probably a QCDM port */ is_qcdm = TRUE; qcdm_result_unref (result); } } else { if (!g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) mm_dbg ("QCDM probe error: (%d) %s", error->code, error->message); retry = TRUE; } if (retry) { GByteArray *cmd2; cmd2 = g_object_steal_data (G_OBJECT (self), "cmd2"); if (cmd2) { /* second try */ mm_qcdm_serial_port_queue_command (MM_QCDM_SERIAL_PORT (task->serial), cmd2, 3, NULL, (MMQcdmSerialResponseFn)serial_probe_qcdm_parse_response, self); return; } /* no more retries left */ } /* Set probing result */ mm_port_probe_set_result_qcdm (self, is_qcdm); /* Reschedule probing */ serial_probe_schedule (self); }