mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
iap: Improve IAPGeneralCommandID_RequestIPodName
iap-serial was hardcoded to return "ROCKBOX", and it was not implemented at all in iap-usb. Extend the iap-serial implementation to return the contents of <ROCKBOX_DIR>/playername.txt, or "Rockbox" if there is an error opening/reading that file. And cut-n-paste this into the iap-usb side of things Change-Id: I9d328be390b4cc8bd92237f996c41ef1e5e19724
This commit is contained in:
parent
2d2b03d314
commit
21d48d5ae3
2 changed files with 30 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
#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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue