struct near_p2p_driver handover_driver = {
.name = "Handover",
.service_name = NEAR_DEVICE_SN_HANDOVER,
+ .fallback_service_name = NEAR_DEVICE_SN_SNEP,
.read = handover_read,
.push = handover_push,
.close = handover_close,
struct near_p2p_driver npp_driver = {
.name = "NPP",
.service_name = NEAR_DEVICE_SN_NPP,
+ .fallback_service_name = NULL,
.read = npp_read,
};
if (strcmp(driver->service_name, service_name) != 0)
continue;
-
+ /*
+ * Because of Android's implementation, we have use SNEP for
+ * Handover. So, on Handover session, we try to connect to
+ * the handover service and fallback to SNEP on connect fail.
+ */
fd = p2p_connect(adapter_idx, target_idx, ndef, cb, driver);
if (fd < 0)
- return fd;
-
- return driver->push(fd, adapter_idx, target_idx, ndef, cb);
+ return p2p_push(adapter_idx, target_idx, ndef,
+ (char *) driver->fallback_service_name, cb);
+ else
+ return driver->push(fd, adapter_idx, target_idx,
+ ndef, cb);
}
return -1;
struct near_p2p_driver {
const char *name;
const char *service_name;
+ const char *fallback_service_name;
near_bool_t (*read)(int client_fd,
uint32_t adapter_idx, uint32_t target_idx,
near_device_io_cb cb);
struct near_p2p_driver snep_driver = {
.name = "SNEP",
.service_name = NEAR_DEVICE_SN_SNEP,
+ .fallback_service_name = NEAR_DEVICE_SN_NPP,
.read = snep_read,
.push = snep_push,
.close = snep_close,