diff --git a/apps/iap/iap-lingo4.c b/apps/iap/iap-lingo4.c index 746d59f397..d29f4d1612 100644 --- a/apps/iap/iap-lingo4.c +++ b/apps/iap/iap-lingo4.c @@ -16,6 +16,7 @@ * ******************************************************************************/ +#include "misc.h" #include "iap-core.h" #include "iap-lingo.h" #include "dir.h" @@ -1034,12 +1035,18 @@ void iap_handlepkt_mode4(const unsigned int len, const unsigned char *buf) * 5 0x14 Command ID (bits 7:0) * 6 0xE5 Telegram payload checksum byte * - * We return ROCKBOX, should this be definable? * Should it be Volume Name? */ { + char ipod_name[32] = "Rockbox"; + int fd = open_utf8(ROCKBOX_DIR "/playername.txt", O_RDONLY); + if (fd >= 0) { + read_line(fd, ipod_name, sizeof(ipod_name)); + close(fd); + ipod_name[sizeof(ipod_name)-1] = 0; + } IAP_TX_INIT4(0x04, 0x0015); - IAP_TX_PUT_STRING("ROCKBOX"); + IAP_TX_PUT_STRING(ipod_name); iap_send_tx(); break; } diff --git a/firmware/usbstack/iap/libiap/iap.c b/firmware/usbstack/iap/libiap/iap.c index b5f700b0a2..af1fe2545c 100644 --- a/firmware/usbstack/iap/libiap/iap.c +++ b/firmware/usbstack/iap/libiap/iap.c @@ -1,6 +1,8 @@ #include #include +#include "misc.h" + #include "constants.h" #include "endian.h" #include "iap.h" @@ -201,6 +203,25 @@ static int32_t handle_command(struct IAPContext* ctx, uint8_t lingo, uint16_t co response->is_ext_mode = 1; return IAPGeneralCommandID_ReturnExtendedInterfaceMode; } break; + case IAPGeneralCommandID_RequestIPodName: { + // Note: This should be pulled from .rockbox/playername.txt + char ipod_name[32] = "Rockbox"; + int fd = open_utf8(ROCKBOX_DIR "/playername.txt", O_RDONLY); + if (fd >= 0) { + read_line(fd, ipod_name, sizeof(ipod_name)); + close(fd); + ipod_name[sizeof(ipod_name)-1] = 0; + } + + check_ret( + iap_span_append(response_span, + ipod_name, + strlen(ipod_name) + 1), + -IAPAckStatus_EOutOfResource + ); + + return IAPGeneralCommandID_ReturnIPodName; + } break; case IAPGeneralCommandID_RequestIPodSoftwareVersion: { alloc_response(IAPReturnIPodSoftwareVersionPayload); response->major = 18;