|
|
|
@ -12,7 +12,8 @@ void send_msg_Success(int iface)
|
|
|
|
|
// response: Success message (id 2), payload len 0
|
|
|
|
|
PB_CTX ctx;
|
|
|
|
|
pb_start(&ctx, 2);
|
|
|
|
|
usb_hid_write_blocking(iface, pb_build(&ctx), 64, 1);
|
|
|
|
|
pb_end(&ctx);
|
|
|
|
|
usb_hid_write_blocking(iface, ctx.buf, ctx.pos, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void send_msg_Failure(int iface)
|
|
|
|
@ -21,8 +22,9 @@ void send_msg_Failure(int iface)
|
|
|
|
|
// - code = 99 (Failure_FirmwareError)
|
|
|
|
|
PB_CTX ctx;
|
|
|
|
|
pb_start(&ctx, 3);
|
|
|
|
|
pb_add_varint(&ctx, "\x08", 99);
|
|
|
|
|
usb_hid_write_blocking(iface, pb_build(&ctx), 64, 1);
|
|
|
|
|
pb_add_varint(&ctx, 1, 99);
|
|
|
|
|
pb_end(&ctx);
|
|
|
|
|
usb_hid_write_blocking(iface, ctx.buf, ctx.pos, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void send_msg_Features(int iface, bool firmware_present)
|
|
|
|
@ -36,13 +38,14 @@ void send_msg_Features(int iface, bool firmware_present)
|
|
|
|
|
// - firmware_present = True/False
|
|
|
|
|
PB_CTX ctx;
|
|
|
|
|
pb_start(&ctx, 17);
|
|
|
|
|
pb_add_string(&ctx, "\x0a", "trezor.io");
|
|
|
|
|
pb_add_varint(&ctx, "\x10", VERSION_MAJOR);
|
|
|
|
|
pb_add_varint(&ctx, "\x18", VERSION_MINOR);
|
|
|
|
|
pb_add_varint(&ctx, "\x20", VERSION_PATCH);
|
|
|
|
|
pb_add_bool(&ctx, "\x28", true);
|
|
|
|
|
pb_add_bool(&ctx, "\x90\x01", firmware_present);
|
|
|
|
|
usb_hid_write_blocking(iface, pb_build(&ctx), 64, 1);
|
|
|
|
|
pb_add_string(&ctx, 1, "trezor.io");
|
|
|
|
|
pb_add_varint(&ctx, 2, VERSION_MAJOR);
|
|
|
|
|
pb_add_varint(&ctx, 3, VERSION_MINOR);
|
|
|
|
|
pb_add_varint(&ctx, 4, VERSION_PATCH);
|
|
|
|
|
pb_add_bool(&ctx, 5, true);
|
|
|
|
|
pb_add_bool(&ctx, 18, firmware_present);
|
|
|
|
|
pb_end(&ctx);
|
|
|
|
|
usb_hid_write_blocking(iface, ctx.buf, ctx.pos, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void send_msg_FirmwareRequest(int iface, uint32_t offset, uint32_t length)
|
|
|
|
@ -52,7 +55,8 @@ void send_msg_FirmwareRequest(int iface, uint32_t offset, uint32_t length)
|
|
|
|
|
// - length = length
|
|
|
|
|
PB_CTX ctx;
|
|
|
|
|
pb_start(&ctx, 8);
|
|
|
|
|
pb_add_varint(&ctx, "\x08", offset);
|
|
|
|
|
pb_add_varint(&ctx, "\x10", length);
|
|
|
|
|
usb_hid_write_blocking(iface, pb_build(&ctx), 64, 1);
|
|
|
|
|
pb_add_varint(&ctx, 1, offset);
|
|
|
|
|
pb_add_varint(&ctx, 2, length);
|
|
|
|
|
pb_end(&ctx);
|
|
|
|
|
usb_hid_write_blocking(iface, ctx.buf, ctx.pos, 1);
|
|
|
|
|
}
|
|
|
|
|