1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: demo_AcTestMain.cpp 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev:$ 14 *---------------------------------------------------------------------------*/ 15 16 #include <nn.h> 17 18 static size_t STACK_SIZE = 4096; 19 static nn::os::Event s_DisconnectEvent(false); 20 DisconnectWaitThread()21extern "C" void DisconnectWaitThread() 22 { 23 NN_LOG( "Start to wait for a disconnect event.\n" ); 24 s_DisconnectEvent.Wait(); 25 NN_LOG( "Signal disconnect event!\n" ); 26 } 27 nnMain(void)28extern "C" void nnMain( void ) 29 { 30 // Call only nn::applet::Enable to also allow execution from the HOME Menu 31 // HOME Menu transitions, POWER Button presses, and sleep are all unsupported 32 nn::applet::Enable(); 33 34 nn::Result result; 35 36 nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMicroSeconds(1200)); 37 38 NN_LOG("client: Initialize AC\n"); 39 nn::fs::Initialize(); 40 result = nn::ac::Initialize(); 41 if( result.IsSuccess() ) 42 { 43 nn::ac::Config config; 44 nn::ac::CreateDefaultConfig( &config ); 45 46 nn::ac::RegisterDisconnectEvent( &s_DisconnectEvent ); 47 nn::os::Thread thread; 48 thread.StartUsingAutoStack( DisconnectWaitThread, STACK_SIZE ); 49 thread.Detach(); 50 51 NN_LOG("client: Connecting\n"); 52 result = nn::ac::Connect( config ); 53 if( result.IsSuccess() ) 54 { 55 // Connection successful 56 NN_LOG("Successfully connected.\n"); 57 58 NN_LOG("client: Close\n"); 59 nn::ac::Close(); 60 } 61 else 62 { 63 // Connection failure 64 NN_LOG("Connection failed.\n"); 65 } 66 } 67 else 68 { 69 NN_LOG("client: Initialization failure\n"); 70 } 71 72 NN_LOG("client: Finalize AC\n"); 73 nn::ac::Finalize(); 74 75 NN_LOG("Exit client\n"); 76 while(true) 77 { 78 nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromSeconds(1)); 79 } 80 } 81