diff --git a/libctru/include/3ds/services/boss.h b/libctru/include/3ds/services/boss.h index 11ec248..92a2a66 100644 --- a/libctru/include/3ds/services/boss.h +++ b/libctru/include/3ds/services/boss.h @@ -4,6 +4,37 @@ */ #pragma once +/// BOSS context. +typedef struct +{ + u32 property[0x7]; + + char url[0x200]; + + u32 property_x8; + u8 property_x9; + + u8 property_xa[0x100]; + + char property_xd[0x360];//Additonal optional HTTP request headers. + + u32 property_xe; + + u32 property_xf[0xc>>2]; + + u8 property_x10; + u8 property_x11; + u8 property_x12; + u32 property_x13; + u32 property_x14; + + u8 property_x15[0x40]; + + u32 property_x16; + + u32 property_x3b; +} bossContext; + /** * @brief Initializes BOSS. * @param programID programID to use, 0 for the current process. Not used internally unless BOSSP is available. @@ -67,3 +98,17 @@ Result bossGetTaskState(const char *taskID, s8 inval, u8 *out0, u32 *out1, u8 *o */ Result bossGetTaskProperty0(const char *taskID, u8 *out); +/** + * @brief Setup a BOSS context with the default config. + * @param bossContext BOSS context. + * @param seconds_interval Interval in seconds for running the task automatically. + * @param url Task URL. + */ +void bossSetupContextDefault(bossContext *ctx, u32 seconds_interval, char *url); + +/** + * @brief Sends the config stored in the context. Used before registering a task. + * @param bossContext BOSS context. + */ +Result bossSendContextConfig(bossContext *ctx); + diff --git a/libctru/source/services/boss.c b/libctru/source/services/boss.c index 563f823..5c09e16 100644 --- a/libctru/source/services/boss.c +++ b/libctru/source/services/boss.c @@ -230,3 +230,120 @@ Result bossGetTaskProperty0(const char *taskID, u8 *out) return ret; } +void bossSetupContextDefault(bossContext *ctx, u32 seconds_interval, const char *url) +{ + memset(ctx, 0, sizeof(bossContext)); + + ctx->property[0x0] = 0xaa; + ctx->property[0x1] = 0x01; + ctx->property[0x2] = 0x00; + ctx->property[0x3] = seconds_interval; + ctx->property[0x4] = 0x64; + ctx->property[0x5] = 0x02; + ctx->property[0x6] = 0x02; + + memset(ctx->url, 0, sizeof(ctx->url)); + strncpy(ctx->url, url, sizeof(ctx->url)-1); + + ctx->property_x8 = 0x00; + + ctx->property_x9 = 0x00; + + memset(ctx->property_xa, 0, sizeof(ctx->property_xa)); + memset(ctx->property_xd, 0, sizeof(ctx->property_xd)); + + ctx->property_xe = 0x00; + + memset(ctx->property_xf, 0, sizeof(ctx->property_xf)); + ctx->property_xf[0] = 0x07; + ctx->property_xf[1] = 0x03; + + ctx->property_x10 = 0x00; + + ctx->property_x11 = 0x00; + + ctx->property_x12 = 0x00; + + ctx->property_x13 = 0x02; + + ctx->property_x14 = 0x01; + + memset(ctx->property_x15, 0, sizeof(ctx->property_x15)); + + ctx->property_x16 = 0x00; + + ctx->property_x3b = 0x00; +} + +Result bossSendContextConfig(bossContext *ctx) +{ + Result ret=0; + + ret = bossSendProperty(0x0, &ctx->property[0x0], 0x1); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x1, &ctx->property[0x1], 0x1); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x2, &ctx->property[0x2], 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x3, &ctx->property[0x3], 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x4, &ctx->property[0x4], 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x5, &ctx->property[0x5], 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x6, &ctx->property[0x6], 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x7, ctx->url, 0x200); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x8, &ctx->property_x8, 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x9, &ctx->property_x9, 0x1); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0xa, &ctx->property_xa, 0x100); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0xd, ctx->property_xd, 0x360); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0xe, &ctx->property_xe, 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0xf, ctx->property_xf, 0xc); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x10, &ctx->property_x10, 0x1); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x11, &ctx->property_x11, 0x1); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x12, &ctx->property_x12, 0x1); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x13, &ctx->property_x13, 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x14, &ctx->property_x14, 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x15, ctx->property_x15, 0x40); + + ret = bossSendProperty(0x16, &ctx->property_x16, 0x4); + if(R_FAILED(ret))return ret; + + ret = bossSendProperty(0x3b, &ctx->property_x3b, 0x4); + if(R_FAILED(ret))return ret; + + return ret; +} +