Homebrew Is it possible to disable sleep mode using libctru?

Aridez

New Member
OP
Newbie
Joined
Oct 16, 2018
Messages
4
Trophies
0
Age
29
XP
58
Country
Spain
I'm trying to make a homebrew application but it seems to crash every time it goes into sleep mode, I guess that is because I'm making network requests using sslc so I would like to disable sleep mode altogether.

I've found the function "void aptSetSleepAllowed(bool allowed)" in libctru here:

github. com/smealum/ctrulib/blob/master/libctru/source/services/apt.c
(sorry I can't post links yet)

But it doesn't seem to be working.

Is is possible to disable sleep mode? Is it possible to turn off the screens too? If so, are there any examples?

Thanks!
 
Last edited by Aridez,

Aridez

New Member
OP
Newbie
Joined
Oct 16, 2018
Messages
4
Trophies
0
Age
29
XP
58
Country
Spain
It seems like at least the wifi and the screens are turned off when entering in sleep mode, I'm not sure about the rest of things but I'm guessing that everything goes to sleep. I found an open issue but it's been there for 2 years already and is not answered:

github . com/smealum/ctrulib/issues/286

I made a repo with my code at:

github . com/Aridez/sslc_example_3ds

There I try to simplify the code I'm using, it presents the same problem, when put to sleep it first says "failed to created the socket" and then "socinit failed" the rest of iterations so it seems like the wifi module stops. This is the main loop (there's a space in the url because I can't post links yet):

Code:
#include "request.h"

int main()
{
    gfxInitDefault();
    consoleInit(GFX_TOP, NULL);

    printf("Press B to exit\n");
    while (aptMainLoop())
    {
        gspWaitForVBlank();
        hidScanInput();

        u32 kDown = hidKeysDown();
        if (kDown & KEY_B)
            break; // break in order to return to hbmenu
        if (kDown & KEY_START) {
            aptInit();
            aptSetSleepAllowed(false);
            aptExit();
        }


        printf("Request Start\n");
        Request* request = new_Request("GET", "yls8.mtheall. com", "/testpage", "limit=1");
        char* out = malloc(sizeof(char)*2048);
        if (network_request(request, out)) {
            printf("%s\n", out);
            printf("Request Done\n");
        } else {
            printf("Request failed\n");
        }
        printf("Allowed to sleep: %d\n", aptIsSleepAllowed());
        destroy_Request(request);
        free(out);
        svcSleepThread(2000000000);

        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }

    gfxExit();
    return 0;
}
 
Last edited by Aridez,
General chit-chat
Help Users
  • No one is chatting at the moment.
  • JuanMena @ JuanMena:
    Will you give me mouth to mouth oxygen if my throat closes?
  • K3N1 @ K3N1:
    Nah the air can do that
  • K3N1 @ K3N1:
    Ask @x65943 he's trained for that stuff
  • JuanMena @ JuanMena:
    Kissing random dudes choking in celery? Really? Need to study for that?
  • K3N1 @ K3N1:
    Yes it requires a degree
  • K3N1 @ K3N1:
    I could also yank out the rest of my teeth but theirs professionals for that
  • x65943 @ x65943:
    If your throat closes, putting oxygen in your mouth will not solve anything - as you will be introducing oxygen prior to the area of obstruction
  • JuanMena @ JuanMena:
    Just kiss me Kyle.
  • x65943 @ x65943:
    You either need to be intubated to bypass obstruction or create a stoma inferior to the the area of obstruction to survive
  • x65943 @ x65943:
    "Just kiss me Kyle." And I thought all the godreborn gay stuff was a smear campaign
  • JuanMena @ JuanMena:
    If I die, tell my momma I won't be carrying Baby Jesus this christmas :sad::cry:
  • K3N1 @ K3N1:
    Smear campaigns are in The political section now?
  • JuanMena @ JuanMena:
    Chary! Chary! Chary, Chary, Chary!
  • Sonic Angel Knight @ Sonic Angel Knight:
    Pork Provolone :P
  • Psionic Roshambo @ Psionic Roshambo:
    Sounds yummy
  • K3N1 @ K3N1:
    Sweet found my Wii u PSU right after I ordered a new one :tpi:
  • JuanMena @ JuanMena:
    It was waiting for you to order another one.
    Seems like, your PSU was waiting for a partner.
  • JuanMena @ JuanMena:
    Keep them both
    separated or you'll have more PSUs each year.
  • K3N1 @ K3N1:
    Well one you insert one PSU into the other one you get power
  • JuanMena @ JuanMena:
    It literally turns it on.
  • K3N1 @ K3N1:
    Yeah power supplies are filthy perverts
  • K3N1 @ K3N1:
    @Psionic Roshambo has a new friend
    +1
  • JuanMena @ JuanMena:
    It's Kyle, the guy that went to school to be a Certified man Kisser.
  • Psionic Roshambo @ Psionic Roshambo:
    Cartmans hand has taco flavored kisses
  • A @ abraarukuk:
    hi guys
    A @ abraarukuk: hi guys