diff --git a/micropython/extmod/modtrezormsg/modtrezormsg-unix.h b/micropython/extmod/modtrezormsg/modtrezormsg-unix.h index eacae226..f00499ae 100644 --- a/micropython/extmod/modtrezormsg/modtrezormsg-unix.h +++ b/micropython/extmod/modtrezormsg/modtrezormsg-unix.h @@ -15,6 +15,7 @@ #include "../../trezorhal/usb.h" #include "../../trezorhal/touch.h" +#define TREZOR_UDP_IFACE 0 #define TREZOR_UDP_PORT 21324 static int sock; @@ -74,6 +75,9 @@ int usb_vcp_add(const usb_vcp_info_t *info) { } int usb_hid_can_read(uint8_t iface_num) { + if (iface_num != TREZOR_UDP_IFACE) { + return 0; + } struct pollfd fds[] = { { sock, POLLIN, 0 }, }; @@ -86,6 +90,9 @@ int usb_hid_can_read(uint8_t iface_num) { } int usb_hid_can_write(uint8_t iface_num) { + if (iface_num != TREZOR_UDP_IFACE) { + return 0; + } struct pollfd fds[] = { { sock, POLLOUT, 0 }, }; @@ -98,6 +105,9 @@ int usb_hid_can_write(uint8_t iface_num) { } int usb_hid_read(uint8_t iface_num, uint8_t *buf, uint32_t len) { + if (iface_num != TREZOR_UDP_IFACE) { + return 0; + } struct sockaddr_in si; socklen_t sl = sizeof(si); ssize_t r = recvfrom(sock, buf, len, MSG_DONTWAIT, (struct sockaddr *)&si, &sl); @@ -116,6 +126,9 @@ int usb_hid_read(uint8_t iface_num, uint8_t *buf, uint32_t len) { } int usb_hid_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) { + if (iface_num != TREZOR_UDP_IFACE) { + return 0; + } ssize_t r = len; if (slen > 0) { r = sendto(sock, buf, len, MSG_DONTWAIT, (const struct sockaddr *)&si_other, slen);