#include <string.h>
#include <stdio.h>
char regionids_table[7][4] = {
"JPN",
"USA",
"EUR",
"JPN",
"CHN",
"KOR",
"TWN"
};
{
u32 test_NsDataId = 0x57524248;
char *taskID = "tmptask";
char tmpstr[256];
printf("Running BOSS setup...\n");
if(ret!=0)
{
printf("Failed to init cfg: 0x%08x.\n", (unsigned int)ret);
return ret;
}
if(ret!=0)
{
printf("Failed to get region from cfg: 0x%08x.\n", (unsigned int)ret);
return ret;
}
if(region>=7)
{
printf("Region value from cfg is invalid: 0x%02x.\n", (unsigned int)region);
ret = -9;
return ret;
}
memset(tmpstr, 0, sizeof(tmpstr));
snprintf(tmpstr, sizeof(tmpstr)-1, "http://yls8.mtheall.com/boss/libctru_example/%s_bossdata0.bin", regionids_table[region]);
if(
R_FAILED(ret))printf(
"bossSendContextConfig returned 0x%08x.\n", (
unsigned int)ret);
{
if(
R_FAILED(ret))printf(
"bossRegisterTask returned 0x%08x.\n", (
unsigned int)ret);
{
if(
R_FAILED(ret))printf(
"bossStartTaskImmediate returned 0x%08x.\n", (
unsigned int)ret);
{
printf("Waiting for the task to finish running...\n");
while(1)
{
{
printf("bossGetTaskState returned 0x%08x.\n", (unsigned int)ret);
break;
}
{
printf("...\n");
}
if(status!=BOSSTASKSTATUS_STARTED)break;
}
}
{
printf("BOSS task failed. This usually indicates a network failure.\n");
ret = -9;
}
{
printf("Reading BOSS content...\n");
ret =
bossGetNsDataHeaderInfo(test_NsDataId, bossNsDataHeaderInfoType_ContentSize, &contentsize, bossNsDataHeaderInfoTypeSize_ContentSize);
if(
R_FAILED(ret))printf(
"bossGetNsDataHeaderInfo returned 0x%08x.\n", (
unsigned int)ret);
{
printf("Content size: 0x%x.\n", (unsigned int)contentsize);
if(contentsize > sizeof(tmpstr)-1)contentsize = sizeof(tmpstr)-1;
tmp = 0;
memset(tmpstr, 0, sizeof(tmpstr));
ret =
bossReadNsData(test_NsDataId, 0, tmpstr, contentsize, &tmp, NULL);
if(
R_FAILED(ret))printf(
"bossReadNsData returned 0x%08x, transfer_total=0x%x.\n", (
unsigned int)ret, (
unsigned int)tmp);
}
if(
R_SUCCEEDED(ret) && strncmp(tmpstr,
"Test", 4))ret = -11;
if(
R_SUCCEEDED(ret))printf(
"Content data at offset 0x4: %s\n", &tmpstr[4]);
if(
R_FAILED(ret))printf(
"BOSS data reading failed: 0x%08x.\n", (
unsigned int)ret);
}
}
}
return ret;
}
int main(int argc, char **argv) {
ret = setup_boss();
if(
R_FAILED(ret))printf(
"setup_boss() failed: 0x%08x.\n", (
unsigned int)ret);
printf("Press START to exit.\n");
break;
}
return 0;
}
bool aptMainLoop(void)
Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...
Result bossGetTaskState(const char *taskID, s8 inval, u8 *status, u32 *out1, u8 *out2)
Returns task state.
void bossSetupContextDefault(bossContext *ctx, u32 seconds_interval, const char *url)
Setup a BOSS context with the default config.
Result bossSendContextConfig(bossContext *ctx)
Sends the config stored in the context.
Result bossInit(u64 programID, bool force_user)
Initializes BOSS.
Result bossReadNsData(u32 NsDataId, u64 offset, void *buffer, u32 size, u32 *transfer_total, u32 *unk_out)
Reads data from the content for the specified NsDataId.
void bossExit(void)
Exits BOSS.
Result bossStartTaskImmediate(const char *taskID)
Starts a task soon after running this command.
Result bossDeleteTask(const char *taskID, u32 unk)
Deletes a task by using CancelTask and UnregisterTask internally.
Result bossDeleteNsData(u32 NsDataId)
Deletes the content file for the specified NsDataId.
Result bossGetNsDataHeaderInfo(u32 NsDataId, u8 type, void *buffer, u32 size)
Gets header info for the specified NsDataId.
Result bossRegisterTask(const char *taskID, u8 unk0, u8 unk1)
Register a task.
Result cfguInit(void)
Initializes CFGU.
Result CFGU_SecureInfoGetRegion(u8 *region)
Gets the system's region from secure info.
void cfguExit(void)
Exits CFGU.
PrintConsole * consoleInit(gfxScreen_t screen, PrintConsole *console)
Initialise the console.
void gfxSwapBuffers(void)
Updates the configuration of both screens.
void gfxInitDefault(void)
Initializes the LCD framebuffers with default parameters This is equivalent to calling:
@ GFX_TOP
Top screen.
Definition: gfx.h:26
void gfxExit(void)
Deinitializes and frees the LCD framebuffers.
void gfxFlushBuffers(void)
Flushes the data cache for the current framebuffers.
#define gspWaitForVBlank()
Waits for VBlank.
Definition: gspgpu.h:151
@ KEY_START
Start.
Definition: hid.h:15
u32 hidKeysDown(void)
Returns a bitmask of newly pressed buttons, this frame.
void hidScanInput(void)
Scans HID for input data.
#define R_FAILED(res)
Checks whether a result code indicates failure.
Definition: result.h:11
#define R_SUCCEEDED(res)
Checks whether a result code indicates success.
Definition: result.h:9
BOSS context.
Definition: boss.h:9
void svcSleepThread(s64 ns)
Puts the current thread to sleep.
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
s32 Result
Function result.
Definition: types.h:42
uint32_t u32
32-bit unsigned integer
Definition: types.h:23