Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea #111

Open
miniexploit opened this issue May 25, 2022 · 1 comment
Open

Idea #111

miniexploit opened this issue May 25, 2022 · 1 comment

Comments

@miniexploit
Copy link
Contributor

As soon as the device is disconnected client will be NULL so before sending a file or a command, we just need to check if client is NULL or not. if client == NULL we will proceed reconnect, so i think sendFile() will be something like this:

int DFUDevice::sendFile(const char* filename) {
    if(!(this -> client)) {
        this -> freeDevice();
        usleep(500000);
        if (this -> openConnection(5) != 0) {
            printf("error connecting to device, stopping here\n");
            return 2;
        }
        usleep(500000);
        this -> setAllDeviceInfo();
        usleep(500000);
    }
    usleep(500000);
    irecv_error_t stat = irecv_send_file(this -> client, filename, 1);
    usleep(500000);
    /* for some reason it returns USB upload error even though it uploads
      the file just fine, so we're only worried about IRECV_E_UNABLE_TO_CONNECT here */
    if (stat == IRECV_E_SUCCESS) {
        return 0;
    } else if (stat == IRECV_E_USB_UPLOAD) {
        if (strcmp(filename, "/dev/null") == 0) return 0;
        else return 2;
    }
    return 1;
}

i'll open a PR if you agree

@rA9stuff
Copy link
Owner

I think I already handle this with the withReconnect parameter of the sendFile method. The only time device gets nulled is after uploading iBSS and iBEC, which the main viewcontroller already assumes by calling the sendFile method with the bool parameter set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants