core: allow plugins to handle custom init responses
This commit is contained in:

committed by
Dan Williams

parent
971600b909
commit
b3b1d5309a
@@ -113,7 +113,7 @@ supports_port (MMPluginBase *base,
|
|||||||
* 1235f71b20c92cded4abd976ccc5010649aae1a0 and
|
* 1235f71b20c92cded4abd976ccc5010649aae1a0 and
|
||||||
* f38ad328acfdc6ce29dd1380602c546b064161ae for more details.
|
* f38ad328acfdc6ce29dd1380602c546b064161ae for more details.
|
||||||
*/
|
*/
|
||||||
mm_plugin_base_supports_task_set_custom_init_command (task, "ATE0+CPMS?", 3, 4, FALSE);
|
mm_plugin_base_supports_task_set_custom_init_command (task, "ATE0+CPMS?", 3, 4, FALSE, NULL, NULL);
|
||||||
|
|
||||||
if (mm_plugin_base_probe_port (base, task, NULL))
|
if (mm_plugin_base_probe_port (base, task, NULL))
|
||||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||||
|
@@ -115,6 +115,8 @@ typedef struct {
|
|||||||
guint32 custom_init_tries;
|
guint32 custom_init_tries;
|
||||||
guint32 custom_init_delay_seconds;
|
guint32 custom_init_delay_seconds;
|
||||||
gboolean custom_init_fail_if_timeout;
|
gboolean custom_init_fail_if_timeout;
|
||||||
|
MMBaseSupportsTaskCustomInitResultFunc custom_init_callback;
|
||||||
|
gpointer custom_init_callback_data;
|
||||||
|
|
||||||
MMSupportsPortResultFunc callback;
|
MMSupportsPortResultFunc callback;
|
||||||
gpointer callback_data;
|
gpointer callback_data;
|
||||||
@@ -229,7 +231,9 @@ mm_plugin_base_supports_task_set_custom_init_command (MMPluginBaseSupportsTask *
|
|||||||
const char *cmd,
|
const char *cmd,
|
||||||
guint32 delay_seconds,
|
guint32 delay_seconds,
|
||||||
guint32 max_tries,
|
guint32 max_tries,
|
||||||
gboolean fail_if_timeout)
|
gboolean fail_if_timeout,
|
||||||
|
MMBaseSupportsTaskCustomInitResultFunc callback,
|
||||||
|
gpointer callback_data)
|
||||||
{
|
{
|
||||||
MMPluginBaseSupportsTaskPrivate *priv;
|
MMPluginBaseSupportsTaskPrivate *priv;
|
||||||
|
|
||||||
@@ -243,6 +247,8 @@ mm_plugin_base_supports_task_set_custom_init_command (MMPluginBaseSupportsTask *
|
|||||||
priv->custom_init_max_tries = max_tries;
|
priv->custom_init_max_tries = max_tries;
|
||||||
priv->custom_init_delay_seconds = delay_seconds;
|
priv->custom_init_delay_seconds = delay_seconds;
|
||||||
priv->custom_init_fail_if_timeout = fail_if_timeout;
|
priv->custom_init_fail_if_timeout = fail_if_timeout;
|
||||||
|
priv->custom_init_callback = callback;
|
||||||
|
priv->custom_init_callback_data = callback_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -731,6 +737,7 @@ custom_init_response (MMAtSerialPort *port,
|
|||||||
{
|
{
|
||||||
MMPluginBaseSupportsTask *task = MM_PLUGIN_BASE_SUPPORTS_TASK (user_data);
|
MMPluginBaseSupportsTask *task = MM_PLUGIN_BASE_SUPPORTS_TASK (user_data);
|
||||||
MMPluginBaseSupportsTaskPrivate *task_priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task);
|
MMPluginBaseSupportsTaskPrivate *task_priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task);
|
||||||
|
MMPluginBaseClass* klass = MM_PLUGIN_BASE_GET_CLASS (task_priv->plugin);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
task_priv->custom_init_tries++;
|
task_priv->custom_init_tries++;
|
||||||
@@ -745,6 +752,24 @@ custom_init_response (MMAtSerialPort *port,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* custom handle init response */
|
||||||
|
if (klass->handle_custom_init_response != NULL)
|
||||||
|
klass->handle_custom_init_response (task, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for custom init callback */
|
||||||
|
if (task_priv->custom_init_callback != NULL) {
|
||||||
|
MMBaseSupportsTaskCustomInitResultFunc callback = task_priv->custom_init_callback;
|
||||||
|
guint32 level;
|
||||||
|
|
||||||
|
level = callback (response, task_priv->custom_init_callback_data);
|
||||||
|
if (level > 0) {
|
||||||
|
/* Plugin supports the modem */
|
||||||
|
task_priv->probed_caps = level;
|
||||||
|
probe_complete (task);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise proceed to probing */
|
/* Otherwise proceed to probing */
|
||||||
@@ -1243,6 +1268,7 @@ mm_plugin_base_class_init (MMPluginBaseClass *klass)
|
|||||||
g_type_class_add_private (object_class, sizeof (MMPluginBasePrivate));
|
g_type_class_add_private (object_class, sizeof (MMPluginBasePrivate));
|
||||||
|
|
||||||
klass->handle_probe_response = real_handle_probe_response;
|
klass->handle_probe_response = real_handle_probe_response;
|
||||||
|
klass->handle_custom_init_response = NULL;
|
||||||
|
|
||||||
/* Virtual methods */
|
/* Virtual methods */
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
|
@@ -56,6 +56,9 @@ typedef struct {
|
|||||||
|
|
||||||
GType mm_plugin_base_supports_task_get_type (void);
|
GType mm_plugin_base_supports_task_get_type (void);
|
||||||
|
|
||||||
|
typedef guint32 (*MMBaseSupportsTaskCustomInitResultFunc) (GString* response,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
MMPlugin *mm_plugin_base_supports_task_get_plugin (MMPluginBaseSupportsTask *task);
|
MMPlugin *mm_plugin_base_supports_task_get_plugin (MMPluginBaseSupportsTask *task);
|
||||||
|
|
||||||
GUdevDevice *mm_plugin_base_supports_task_get_port (MMPluginBaseSupportsTask *task);
|
GUdevDevice *mm_plugin_base_supports_task_get_port (MMPluginBaseSupportsTask *task);
|
||||||
@@ -73,7 +76,9 @@ void mm_plugin_base_supports_task_set_custom_init_command (MMPluginBaseSupportsT
|
|||||||
const char *cmd,
|
const char *cmd,
|
||||||
guint32 delay_seconds,
|
guint32 delay_seconds,
|
||||||
guint32 max_tries,
|
guint32 max_tries,
|
||||||
gboolean fail_if_timeout);
|
gboolean fail_if_timeout,
|
||||||
|
MMBaseSupportsTaskCustomInitResultFunc callback,
|
||||||
|
gpointer callback_data);
|
||||||
|
|
||||||
#define MM_TYPE_PLUGIN_BASE (mm_plugin_base_get_type ())
|
#define MM_TYPE_PLUGIN_BASE (mm_plugin_base_get_type ())
|
||||||
#define MM_PLUGIN_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBase))
|
#define MM_PLUGIN_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBase))
|
||||||
@@ -114,6 +119,9 @@ struct _MMPluginBaseClass {
|
|||||||
const char *response,
|
const char *response,
|
||||||
const GError *error);
|
const GError *error);
|
||||||
|
|
||||||
|
void (*handle_custom_init_response) (MMPluginBaseSupportsTask *task,
|
||||||
|
GString *response);
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
void (*probe_result) (MMPluginBase *self,
|
void (*probe_result) (MMPluginBase *self,
|
||||||
MMPluginBaseSupportsTask *task,
|
MMPluginBaseSupportsTask *task,
|
||||||
|
Reference in New Issue
Block a user