summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Benjamin BOURGEAIS2021-05-06 18:01:11 +0200
committerGravatar Nikias Bassen2021-05-26 03:40:03 +0200
commit47934949e0015165a4562b08e824adb3f664c0ea (patch)
treec4f49d5495eb2621a7cf18cd112a4c02907c9c59
parent11324701c89a2ef2ace1686fe25eeec9ad8adac8 (diff)
downloadlibirecovery-47934949e0015165a4562b08e824adb3f664c0ea.tar.gz
libirecovery-47934949e0015165a4562b08e824adb3f664c0ea.tar.bz2
Add new irecv_send_command_breq to allow choosing the b_request usb param when sending commands
-rw-r--r--include/libirecovery.h1
-rw-r--r--src/libirecovery.c20
2 files changed, 13 insertions, 8 deletions
diff --git a/include/libirecovery.h b/include/libirecovery.h
index 224a6a7..a65c6fd 100644
--- a/include/libirecovery.h
+++ b/include/libirecovery.h
@@ -148,6 +148,7 @@ irecv_error_t irecv_event_unsubscribe(irecv_client_t client, irecv_event_type ty
/* I/O */
irecv_error_t irecv_send_file(irecv_client_t client, const char* filename, int dfu_notify_finished);
irecv_error_t irecv_send_command(irecv_client_t client, const char* command);
+irecv_error_t irecv_send_command_breq(irecv_client_t client, const char* command, uint8_t b_request);
irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, unsigned long length, int dfu_notify_finished);
irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned long length);
diff --git a/src/libirecovery.c b/src/libirecovery.c
index c3b3341..3e90178 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -2480,21 +2480,21 @@ IRECV_API void irecv_set_debug_level(int level) {
}
#ifndef USE_DUMMY
-static irecv_error_t irecv_send_command_raw(irecv_client_t client, const char* command) {
+static irecv_error_t irecv_send_command_raw(irecv_client_t client, const char* command, uint8_t b_request) {
unsigned int length = strlen(command);
if (length >= 0x100) {
length = 0xFF;
}
if (length > 0) {
- irecv_usb_control_transfer(client, 0x40, 0, 0, 0, (unsigned char*) command, length + 1, USB_TIMEOUT);
+ irecv_usb_control_transfer(client, 0x40, b_request, 0, 0, (unsigned char*) command, length + 1, USB_TIMEOUT);
}
return IRECV_E_SUCCESS;
}
#endif
-IRECV_API irecv_error_t irecv_send_command(irecv_client_t client, const char* command) {
+IRECV_API irecv_error_t irecv_send_command_breq(irecv_client_t client, const char* command, uint8_t b_request) {
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -2518,7 +2518,7 @@ IRECV_API irecv_error_t irecv_send_command(irecv_client_t client, const char* co
}
}
- error = irecv_send_command_raw(client, command);
+ error = irecv_send_command_raw(client, command, b_request);
if (error != IRECV_E_SUCCESS) {
debug("Failed to send command %s\n", command);
if (error != IRECV_E_PIPE)
@@ -2538,6 +2538,10 @@ IRECV_API irecv_error_t irecv_send_command(irecv_client_t client, const char* co
#endif
}
+IRECV_API irecv_error_t irecv_send_command(irecv_client_t client, const char* command) {
+ return irecv_send_command_breq(client, command, 0);
+}
+
IRECV_API irecv_error_t irecv_send_file(irecv_client_t client, const char* filename, int dfu_notify_finished) {
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
@@ -2815,7 +2819,7 @@ IRECV_API irecv_error_t irecv_getenv(irecv_client_t client, const char* variable
memset(command, '\0', sizeof(command));
snprintf(command, sizeof(command)-1, "getenv %s", variable);
- irecv_error_t error = irecv_send_command_raw(client, command);
+ irecv_error_t error = irecv_send_command_raw(client, command, 0);
if(error == IRECV_E_PIPE) {
return IRECV_E_SUCCESS;
}
@@ -2989,7 +2993,7 @@ IRECV_API irecv_error_t irecv_saveenv(irecv_client_t client) {
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
- irecv_error_t error = irecv_send_command_raw(client, "saveenv");
+ irecv_error_t error = irecv_send_command_raw(client, "saveenv", 0);
if(error != IRECV_E_SUCCESS) {
return error;
}
@@ -3013,7 +3017,7 @@ IRECV_API irecv_error_t irecv_setenv(irecv_client_t client, const char* variable
memset(command, '\0', sizeof(command));
snprintf(command, sizeof(command)-1, "setenv %s %s", variable, value);
- irecv_error_t error = irecv_send_command_raw(client, command);
+ irecv_error_t error = irecv_send_command_raw(client, command, 0);
if(error != IRECV_E_SUCCESS) {
return error;
}
@@ -3026,7 +3030,7 @@ IRECV_API irecv_error_t irecv_reboot(irecv_client_t client) {
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
- irecv_error_t error = irecv_send_command_raw(client, "reboot");
+ irecv_error_t error = irecv_send_command_raw(client, "reboot", 0);
if(error != IRECV_E_SUCCESS) {
return error;
}