diff options
Diffstat (limited to 'src/adapter.c')
-rw-r--r-- | src/adapter.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/adapter.c b/src/adapter.c index 52f11a6..98331a5 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -854,6 +854,50 @@ int __near_adapter_remove_target(uint32_t idx, uint32_t target_idx) return 0; } +static gboolean poll_error(gpointer user_data) +{ + struct near_adapter *adapter = user_data; + + DBG("adapter %d", adapter->idx); + + /* + * Resettting the adapter upon polling errors. + * This could be handled through a configuration setting. + */ + __near_netlink_adapter_enable(adapter->idx, false); + __near_netlink_adapter_enable(adapter->idx, true); + + adapter_start_poll(adapter); + + return FALSE; +} + +int __near_adapter_get_targets_done(uint32_t idx) +{ + struct near_adapter *adapter; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + if (g_hash_table_size(adapter->devices) > 0) + return 0; + + if (g_hash_table_size(adapter->tags) > 0) + return 0; + + near_error("No targets found - Polling error"); + + adapter->polling = false; + polling_changed(adapter); + + g_idle_add(poll_error, adapter); + + return 0; +} + int __near_adapter_add_device(uint32_t idx, uint8_t *nfcid, uint8_t nfcid_len) { struct near_adapter *adapter; |