diff options
Diffstat (limited to 'src/dfu.c')
-rw-r--r-- | src/dfu.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -24,7 +24,7 @@ #include <libirecovery.h> #include "dfu.h" -//#include "recovery.h" +#include "recovery.h" #include "idevicerestore.h" int dfu_progress_callback(irecv_client_t client, const irecv_event_t* event) { @@ -100,46 +100,51 @@ int dfu_open_with_timeout(struct idevicerestore_client_t* client, uint32_t timeo } irecv_event_subscribe(recovery, IRECV_PROGRESS, &dfu_progress_callback, NULL); - client->dfu = recovery; + client->dfu->client = recovery; return 0; } +int dfu_check_mode() { + return -1; +} + int dfu_enter_recovery(struct idevicerestore_client_t* client) { irecv_client_t dfu = NULL; const char* component = "iBSS"; irecv_error_t dfu_error = IRECV_E_SUCCESS; - if (recovery_open_with_timeout(&dfu) < 0 || dfu->mode != kDfuMode) { + if (recovery_open_with_timeout(client) < 0 || dfu->mode != kDfuMode) { error("ERROR: Unable to connect to DFU device\n"); if (dfu) irecv_close(dfu); return -1; } - if (recovery_send_signed_component(dfu, client->ipsw, client->tss, "iBSS") < 0) { + if (recovery_send_signed_component(client, "iBSS") < 0) { error("ERROR: Unable to send %s to device\n", component); irecv_close(dfu); return -1; } - dfu_error = irecv_reset(dfu); + dfu_error = irecv_reset(client->dfu->client); if (dfu_error != IRECV_E_SUCCESS) { error("ERROR: Unable to reset device\n"); irecv_close(dfu); return -1; } - irecv_close(dfu); - dfu = NULL; + irecv_close(client->dfu->client); + client->dfu->client = NULL; // Reconnect to device, but this time make sure we're not still in DFU mode - if (recovery_open_with_timeout(&dfu) < 0 || dfu->mode == kDfuMode) { + if (recovery_open_with_timeout(client) < 0 || client->mode->index != kDfuMode) { error("ERROR: Unable to connect to recovery device\n"); - if (dfu) - irecv_close(dfu); + if (client->dfu->client) + irecv_close(client->dfu->client); return -1; } client->mode = &idevicerestore_modes[MODE_RECOVERY]; - irecv_close(dfu); - dfu = NULL; + irecv_close(client->dfu->client); + client->dfu->client = NULL; return 0; } + |