mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@19 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
7e63bdf031
commit
6831b18e1d
@ -31,8 +31,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds);
|
||||
void KPSClient();
|
||||
BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds);
|
||||
BOOL KPSClient();
|
||||
BOOL WaitEC(ECOpId opId);
|
||||
|
||||
|
||||
|
||||
@ -15,6 +15,11 @@
|
||||
|
||||
#include "hatamotolib.h"
|
||||
|
||||
#include "text.h"
|
||||
#include "mprintf.h"
|
||||
#include "logprintf.h"
|
||||
|
||||
|
||||
|
||||
#ifdef SDK_DEBUG
|
||||
#define ECDL_LOG(msg) OS_TPrintf("----\nECDL-LOG: %s\n----\n", msg);
|
||||
@ -72,7 +77,7 @@ static void PrintBytes(const void* pv, u32 size)
|
||||
{
|
||||
const u8* p = reinterpret_cast<const u8*>(pv);
|
||||
|
||||
for( u32 i = 0; i < size; ++i )
|
||||
for( u32 i = 0; i < size; i++ )
|
||||
{
|
||||
OS_TPrintf("%02X", p[i]);
|
||||
}
|
||||
@ -270,10 +275,16 @@ void PrintDeviceInfo(void)
|
||||
|
||||
void SetupTitlesDataFile(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
for( u32 i = 0; i < numTitleIds; ++i )
|
||||
NAMTitleId tid;
|
||||
|
||||
// OS_TPrintf("%s %d num=%d\n",__FUNCTION__,__LINE__,numTitleIds);
|
||||
|
||||
for( u32 i = 0; i < numTitleIds; i++ )
|
||||
{
|
||||
NAMTitleId tid = pTitleIds[i];
|
||||
tid = pTitleIds[i];
|
||||
// OS_TPrintf("%s %d 0x%016X\n",__FUNCTION__,__LINE__,(u64)tid);
|
||||
NAM_SetupTitleDataFile(tid);
|
||||
//OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,7 +413,7 @@ LoadCert(void** ppCert, u32* pSize, const char* name)
|
||||
}
|
||||
|
||||
|
||||
void SetupEC(void)
|
||||
BOOL SetupEC(void)
|
||||
{
|
||||
static u32 logLevel, clientCertSize, clientKeySize;
|
||||
static char deviceCode[17];
|
||||
@ -435,16 +446,30 @@ void SetupEC(void)
|
||||
const u32 nInitArgs = sizeof(initArgs) / sizeof(initArgs[0]);
|
||||
|
||||
rv = EC_Init(initArgs, nInitArgs);
|
||||
SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to initialize EC, rv=%d\n", rv);
|
||||
|
||||
// SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to initialize EC, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
OS_TPrintf("Failed to initialize EC, rv=%d\n", rv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
rv = EC_SetWebSvcUrls( "https://ecs.t.shop.nintendowifi.net/ecs/services/ECommerceSOAP",
|
||||
"https://ias.t.shop.nintendowifi.net/ias/services/IdentityAuthenticationSOAP",
|
||||
"https://cas.t.shop.nintendowifi.net/cas/services/CatalogingSOAP" );
|
||||
SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to EC_SetWebSvcUrls, rv=%d\n", rv);
|
||||
// SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to EC_SetWebSvcUrls, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
OS_TPrintf("Failed to EC_SetWebSvcUrls, rv=%d\n", rv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
rv = EC_SetContentUrls( "http://ccs.t.shop.nintendowifi.net/ccs/download",
|
||||
"http://ccs.t.shop.nintendowifi.net/ccs/download" );
|
||||
SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to EC_SetContentUrls, rv=%d\n", rv);
|
||||
// SDK_ASSERTMSG(rv == EC_ERROR_OK, "Failed to EC_SetContentUrls, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
OS_TPrintf("Failed to EC_SetContentUrls, rv=%d\n", rv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -465,7 +490,6 @@ BOOL WaitEC(ECOpId opId)
|
||||
for(;;)
|
||||
{
|
||||
result = EC_GetProgress(opId, &progress);
|
||||
|
||||
if( (result != EC_ERROR_OK) && (result != EC_ERROR_NOT_DONE) )
|
||||
{
|
||||
if( result == EC_ERROR_NOT_ACTIVE )
|
||||
@ -473,9 +497,11 @@ BOOL WaitEC(ECOpId opId)
|
||||
OS_TPrintf("opId=%d\n", opId);
|
||||
}
|
||||
OS_TPrintf("Failed to EC_GetProgress, result=%d %s\n", result, GetECErrorString(result));
|
||||
mprintf("EC_GetProgress failed %d\n %s\n", result, GetECErrorString(result));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//#ifdef SDK_DEBUG
|
||||
if( MI_CpuComp8(&progress_prev, &progress, sizeof(progress)) != 0 )
|
||||
{
|
||||
@ -492,6 +518,7 @@ BOOL WaitEC(ECOpId opId)
|
||||
progress_prev = progress;
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
if( progress.phase == EC_PHASE_Done )
|
||||
{
|
||||
break;
|
||||
@ -515,7 +542,9 @@ namespace
|
||||
|
||||
ECDL_LOG("check registeration");
|
||||
progress = EC_CheckRegistration();
|
||||
WaitEC(progress);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return '\0'; // 微妙・・
|
||||
}
|
||||
|
||||
ecError = EC_GetDeviceInfo(&di);
|
||||
SDK_ASSERT( ecError == EC_ERROR_OK );
|
||||
@ -557,205 +586,372 @@ namespace
|
||||
return di.registrationStatus[0];
|
||||
}
|
||||
|
||||
void GetChallenge(char* challenge)
|
||||
BOOL GetChallenge(char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
ECError ecError;
|
||||
|
||||
ECDL_LOG("get challenge");
|
||||
progress = EC_SendChallengeReq();
|
||||
WaitEC(progress);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ecError = EC_GetChallengeResp(challenge);
|
||||
SDK_ASSERT( ecError == EC_ERROR_OK );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void SyncRegistration(const char* challenge)
|
||||
BOOL SyncRegistration(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync registration");
|
||||
progress = EC_SyncRegistration(challenge);
|
||||
WaitEC(progress);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Register(const char* challenge)
|
||||
BOOL Register(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("register");
|
||||
progress = EC_Register(challenge, NULL, NULL);
|
||||
WaitEC(progress);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Transfer(const char* challenge)
|
||||
BOOL Transfer(const char* challenge)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("transfer");
|
||||
progress = EC_Transfer(challenge);
|
||||
WaitEC(progress);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void SyncTickets()
|
||||
BOOL SyncTickets()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("sync tickets");
|
||||
progress = EC_SyncTickets(EC_SYNC_TYPE_IMPORT_ALL);
|
||||
WaitEC(progress);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
BOOL DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
ECDL_LOG("download");
|
||||
for( u32 i = 0; i < numTitleIds; ++i )
|
||||
for( u32 i = 0; i < numTitleIds; i++ )
|
||||
{
|
||||
NAMTitleId tid = pTitleIds[i];
|
||||
|
||||
OS_TPrintf("download %08X %08X\n", (u32)(tid >> 32), (u32)tid);
|
||||
progress = EC_DownloadTitle(tid, EC_DT_UPDATE_REQUIRED_CONTENTS);
|
||||
WaitEC(progress);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
|
||||
{
|
||||
char challenge[EC_CHALLENGE_BUF_SIZE];
|
||||
char status;
|
||||
|
||||
// mprintf("-CheckRegistration..\n");
|
||||
status = CheckRegistration();
|
||||
// U unregistered
|
||||
// R registered
|
||||
// P pending
|
||||
// T transfered
|
||||
#if 0
|
||||
SDK_ASSERTMSG(status != 'U', "acount not transfered yet.");
|
||||
SDK_ASSERTMSG(status != 'R', "already registered. please delete acount.");
|
||||
SDK_ASSERTMSG( (status == 'P') || (status == 'T'), "invalid registration status '%c'", status );
|
||||
#else
|
||||
if( status == 'U') {
|
||||
mprintf(" acount not transfered yet.\n");
|
||||
return FALSE;
|
||||
}
|
||||
if( status == 'R') {
|
||||
mprintf(" already registered. please delete acount.\n");
|
||||
return FALSE;
|
||||
}
|
||||
if( (status != 'P') && (status != 'T') ) {
|
||||
mprintf(" invalid registration status '%c'\n", status );
|
||||
return FALSE;
|
||||
}
|
||||
// mprintf(" succeeded.");
|
||||
#endif
|
||||
|
||||
GetChallenge(challenge);
|
||||
Transfer(challenge);
|
||||
mprintf("-get challenge1 ");
|
||||
if( FALSE == GetChallenge(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
GetChallenge(challenge);
|
||||
SyncRegistration(challenge);
|
||||
|
||||
SyncTickets();
|
||||
DownloadTitles(pTitleIds, numTitleIds);
|
||||
mprintf("-transfer ");
|
||||
if( FALSE == Transfer(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
mprintf("-get challenge2 ");
|
||||
if( FALSE == GetChallenge(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
|
||||
mprintf("-sync registration ");
|
||||
if( FALSE == SyncRegistration(challenge) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
mprintf("-sync tickets ");
|
||||
if( FALSE == SyncTickets() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
|
||||
mprintf("-download titles ");
|
||||
if( FALSE == DownloadTitles(pTitleIds, numTitleIds) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KPSClient()
|
||||
BOOL KPSClient()
|
||||
{
|
||||
s32 progress;
|
||||
|
||||
OS_TPrintf("generate key pair\n");
|
||||
mprintf("-generate key pair ");
|
||||
progress = EC_GenerateKeyPair();
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
WaitEC(progress);
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
OS_TPrintf("confirm key pair\n");
|
||||
mprintf("-confirm key pair ");
|
||||
progress = EC_ConfirmKeyPair();
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
WaitEC(progress);
|
||||
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
if( FALSE == WaitEC(progress) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL hatamotolib_main(void)
|
||||
BOOL hatamotolib_main(u64 *title_id_buf, u32 num_title)
|
||||
{
|
||||
ECError rv = EC_ERROR_OK;
|
||||
|
||||
// 不要:デバイス情報の表示
|
||||
PrintDeviceInfo();
|
||||
|
||||
OS_TPrintf("--------------------------------\n");
|
||||
|
||||
// setup
|
||||
{
|
||||
// 必須:タイトル ID の偽装
|
||||
SetupShopTitleId();
|
||||
// 必須:タイトル ID の偽装
|
||||
SetupShopTitleId();
|
||||
|
||||
// ?:ユーザ設定がされていないと接続できないので適当に設定
|
||||
SetupUserInfo();
|
||||
|
||||
// 必須:バージョンデータのマウント
|
||||
SetupVerData();
|
||||
|
||||
// 必須:ネットワークへの接続
|
||||
NcStart(SITEDEFS_DEFAULTCLASS);
|
||||
|
||||
/******** ネットワークにつないだ *************/
|
||||
|
||||
// ?:ユーザ設定がされていないと接続できないので適当に設定
|
||||
SetupUserInfo();
|
||||
|
||||
// 必須:バージョンデータのマウント
|
||||
SetupVerData();
|
||||
|
||||
// 必須:ネットワークへの接続
|
||||
OS_TPrintf("connecting to AP....\n");
|
||||
|
||||
NcStart(SITEDEFS_DEFAULTCLASS);
|
||||
|
||||
|
||||
OS_TPrintf("connected\n");
|
||||
|
||||
// 必須:HTTP と SSL の初期化
|
||||
OS_TPrintf("start NHTTP\n");
|
||||
SetupNSSL();
|
||||
if( FALSE == SetupNHTTP() ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 必須:EC の初期化
|
||||
OS_TPrintf("start EC\n");
|
||||
SetupEC();
|
||||
// 必須:HTTP と SSL の初期化
|
||||
OS_TPrintf("start NHTTP\n");
|
||||
mprintf("-start NHTTP ");
|
||||
SetupNSSL();
|
||||
if( FALSE == SetupNHTTP() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
// body
|
||||
{
|
||||
// ダウンロードすべきタイトルの指定
|
||||
NAMTitleId tids[] =
|
||||
{
|
||||
0x00030004346b6141ull,
|
||||
// 0x0003000434616141ull,
|
||||
// 0x0003000434616241ull,
|
||||
// 0x000300043461644aull,
|
||||
// 0x0003000434616741ull,
|
||||
// 0x0003000434616a41ull,
|
||||
// 0x0003000434617441ull,
|
||||
// 0x0003000434626141ull,
|
||||
// 0x0003000434626341ull,
|
||||
// 0x0003000434626641ull,
|
||||
// 0x0003000434626841ull,
|
||||
// 0x0003000434626941ull,
|
||||
// 0x0003000434636341ull,
|
||||
// 0x00030004346b6141ull,
|
||||
// 0x00030004346b6241ull,
|
||||
// 0x00030004346b6341ull,
|
||||
};
|
||||
/******** NHTTP & NSSLにつないだ *************/
|
||||
|
||||
// 必須:EC の初期化
|
||||
OS_TPrintf("start EC\n");
|
||||
mprintf("-start EC ");
|
||||
if( FALSE == SetupEC() ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
// 必須:デバイス証明書の発行
|
||||
KPSClient();
|
||||
// 必須:デバイス証明書の発行
|
||||
if( FALSE == KPSClient() ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 必須:指定タイトルをダウンロード
|
||||
ECDownload(tids, sizeof(tids)/sizeof(*tids));
|
||||
// 必須:指定タイトルをダウンロード
|
||||
// ダウンロードすべきタイトルの指定
|
||||
// 0x00030004346b6141ull,
|
||||
// 0x0003000434616141ull,
|
||||
// 0x0003000434616241ull,
|
||||
// 0x000300043461644aull,
|
||||
// 0x0003000434616741ull,
|
||||
// 0x0003000434616a41ull,
|
||||
// 0x0003000434617441ull,
|
||||
// 0x0003000434626141ull,
|
||||
// 0x0003000434626341ull,
|
||||
// 0x0003000434626641ull,
|
||||
// 0x0003000434626841ull,
|
||||
// 0x0003000434626941ull,
|
||||
// 0x0003000434636341ull,
|
||||
// 0x00030004346b6141ull,
|
||||
// 0x00030004346b6241ull,
|
||||
// 0x00030004346b6341ull,
|
||||
|
||||
// 不要:セーブデータ領域を作成
|
||||
SetupTitlesDataFile(tids, sizeof(tids)/sizeof(*tids));
|
||||
if( FALSE == ECDownload((NAMTitleId *)title_id_buf , num_title) ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 不要:セーブデータ領域を作成
|
||||
// NAM_Init を忘れてた
|
||||
SetupTitlesDataFile((NAMTitleId *)title_id_buf , num_title);
|
||||
|
||||
if( title_id_buf != NULL && num_title != 0 ) {
|
||||
OS_Free( title_id_buf );
|
||||
}
|
||||
|
||||
// cleanup
|
||||
{
|
||||
ECError rv = EC_ERROR_OK;
|
||||
|
||||
// EC の終了処理
|
||||
rv = EC_Shutdown();
|
||||
SDK_WARNING(rv == EC_ERROR_OK, "Failed to shutdown EC, rv=%d\n", rv);
|
||||
|
||||
// ネットワークからの切断
|
||||
NcFinish();
|
||||
// EC の終了処理
|
||||
mprintf("-EC_Shutdown.. ");
|
||||
rv = EC_Shutdown();
|
||||
// SDK_WARNING(rv == EC_ERROR_OK, "Failed to shutdown EC, rv=%d\n", rv);
|
||||
if( rv != EC_ERROR_OK ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
|
||||
mprintf("OK.\n");
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
|
||||
|
||||
|
||||
// ネットワークからの切断
|
||||
OS_TPrintf("Disconnecting ..\n");
|
||||
mprintf("-Disconnecting... ");
|
||||
|
||||
NHTTP_Cleanup();
|
||||
// int NSSL_Finish( void )
|
||||
NSSL_Finish();
|
||||
|
||||
|
||||
NcFinish();
|
||||
// つなぎっぱなしにするならいらない。
|
||||
TerminateWcmControl();
|
||||
|
||||
OS_TPrintf("Done.\n");
|
||||
mprintf("Done.\n");
|
||||
|
||||
// EC が自分の Title ID のディレクトリを作成してしまうため、削除する
|
||||
DeleteECDirectory();
|
||||
return TRUE;
|
||||
|
||||
@ -9,17 +9,13 @@ void PrintDeviceInfo(void);
|
||||
void SetupShopTitleId(void);
|
||||
void SetupUserInfo(void);
|
||||
void SetupVerData(void);
|
||||
void NetworkAutoConnect_DWC(void);
|
||||
void NetworkShutdown_DWC(void);
|
||||
void SetupNSSL(void);
|
||||
BOOL SetupNHTTP(void);
|
||||
void SetupEC(void);
|
||||
BOOL WaitEC(ECOpId opId);
|
||||
BOOL SetupEC(void);
|
||||
void DeleteECDirectory(void);
|
||||
void SetupTitlesDataFile(const NAMTitleId* pTitleIds, u32 numTitleIds);
|
||||
|
||||
BOOL hatamotolib_main(void);
|
||||
|
||||
BOOL hatamotolib_main(u64 *title_id_buf, u32 num_title);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ static BOOL CheckSystemApp(char path[])
|
||||
if( ('a' <= c) && (c <= 'f') ) {
|
||||
num = (int)( c - 'a' + 10 );
|
||||
}
|
||||
if( ('A' <= c) && (c <= 'F') ) {
|
||||
else if( ('A' <= c) && (c <= 'F') ) {
|
||||
num = (int)( c - 'A' + 10 );
|
||||
}
|
||||
else if( ('0' <= c) && (c <= '9') ) {
|
||||
@ -612,25 +612,21 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
|
||||
u64 *buf = NULL;
|
||||
char c;
|
||||
u8 hex;
|
||||
|
||||
|
||||
if( head == NULL ) {
|
||||
*pBuffer = buf;
|
||||
*size = count;
|
||||
*pBuffer = NULL;
|
||||
*size = 0;
|
||||
}
|
||||
else {
|
||||
for( list_temp = head ; list_temp->next != NULL ; list_temp = list_temp->next ) {
|
||||
for( list_temp = head ; list_temp != NULL ; list_temp = list_temp->next ) {
|
||||
if( list_temp->src_path ) {
|
||||
#ifdef MYDEBUG
|
||||
count++;
|
||||
#else
|
||||
if( FALSE == CheckSystemApp( list_temp->src_path) ) {
|
||||
count++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
OS_TPrintf("User App. count1 = %d\n", count);
|
||||
// mprintf("\nUser App. count1 = %d\n", count);
|
||||
|
||||
if( count ) {
|
||||
buf = (u64 *)OS_Alloc( (u32)(count * sizeof(u64)) );
|
||||
@ -642,9 +638,9 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
|
||||
*pBuffer = buf;
|
||||
*size = count;
|
||||
|
||||
|
||||
count = 0;
|
||||
for( ; list_temp != NULL ; list_temp = list_temp->prev ) {
|
||||
|
||||
for( list_temp = head ; list_temp != NULL ; list_temp = list_temp->next ) {
|
||||
if( list_temp->src_path ) {
|
||||
/*
|
||||
No. 0 0003000f484e4c41
|
||||
@ -657,11 +653,10 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
|
||||
|
|
||||
システムアプリはダウンロード対象外
|
||||
*/
|
||||
#ifndef MYDEBUG
|
||||
if( FALSE == CheckSystemApp( list_temp->src_path ) ) {
|
||||
#endif
|
||||
/* koko-made */
|
||||
count++;
|
||||
|
||||
|
||||
/* User App. */
|
||||
for( i = 0 ; i < 8 ; i++ ) {
|
||||
c = list_temp->src_path[12 + i];
|
||||
@ -677,7 +672,7 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
|
||||
}
|
||||
else {
|
||||
/* error! */
|
||||
count--;
|
||||
// count--;
|
||||
return;
|
||||
}
|
||||
*buf |= (((u64)hex) << ((7-i)*4 + 32 ));
|
||||
@ -697,17 +692,15 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
|
||||
}
|
||||
else {
|
||||
/* error! */
|
||||
count--;
|
||||
// count--;
|
||||
return;
|
||||
}
|
||||
*buf |= (((u64)hex) << ((7-i)*4 ));
|
||||
}
|
||||
buf++;
|
||||
OS_TPrintf("User App. count2 = %d\n", count);
|
||||
// OS_TPrintf("User App. count2 = %d\n", count);
|
||||
|
||||
#ifndef MYDEBUG
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
012345678901234567890123456789
|
||||
nand:/title/00030017/484e4141 は ランチャー
|
||||
@ -1292,12 +1285,14 @@ BOOL TitleIDSave(const char *path, u64 *pData, int count, FSFile *log_fd)
|
||||
nand:/title/00030017/484e414a
|
||||
*/
|
||||
|
||||
if( ( pData != NULL ) && ( count != 0 ) ) {
|
||||
/* 16文字だから */
|
||||
if( (count*sizeof(u64)) != FS_WriteFile(&f, pData, (s32)(count*sizeof(u64)) )) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(NULL, "%s file write error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(NULL, " Failed write file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
return FALSE;
|
||||
if( (count*sizeof(u64)) != FS_WriteFile(&f, pData, (s32)(count*sizeof(u64)) )) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(NULL, "%s file write error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(NULL, " Failed write file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
FS_FlushFile(&f);
|
||||
|
||||
@ -23,6 +23,11 @@
|
||||
#include "netconnect.h"
|
||||
#include "mywlan.h"
|
||||
|
||||
#include "text.h"
|
||||
#include "mprintf.h"
|
||||
#include "logprintf.h"
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
<EFBFBD>‰Šú‰»
|
||||
*---------------------------------------------------------------------------*/
|
||||
@ -250,13 +255,15 @@ static void ncFinishInet(void)
|
||||
*---------------------------------------------------------------------------*/
|
||||
void NcStart(const char* apClass)
|
||||
{
|
||||
int counter = 0;
|
||||
s32 wcm_phase;
|
||||
|
||||
SiteDefs_Init();
|
||||
SiteDefs_Init();
|
||||
|
||||
|
||||
if( FALSE == ENV_SetBinary("WiFi.LAN.1.AP.1.WEP.KEY", (void *)GetWlanKEYSTR()) ) {
|
||||
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
if( FALSE == ENV_SetString("WiFi.LAN.1.AP.1.ESSID", GetWlanSSID()) ) {
|
||||
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
|
||||
}
|
||||
@ -270,31 +277,75 @@ void NcStart(const char* apClass)
|
||||
OS_Panic("Invalid AP Class....");
|
||||
}
|
||||
|
||||
while (WCM_GetPhase() != WCM_PHASE_NULL)
|
||||
{
|
||||
OS_Sleep(100);
|
||||
while (1) {
|
||||
wcm_phase = WCM_GetPhase();
|
||||
if( wcm_phase == WCM_PHASE_NULL) {
|
||||
break;
|
||||
}
|
||||
// OS_TPrintf("%s %d phase = %d\n", __FUNCTION__,__LINE__,wcm_phase);
|
||||
OS_Sleep(100);
|
||||
}
|
||||
|
||||
InitWcmControlByApInfoEx(&apInfo, g_deviceId);
|
||||
|
||||
OS_TPrintf("LINK UP....\n");
|
||||
mprintf("-LINK UP");
|
||||
while ( 1 ) {
|
||||
wcm_phase = WCM_GetPhase();
|
||||
if( wcm_phase == WCM_PHASE_DCF ) {
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
#define WCM_PHASE_NULL 0 // 初期化前
|
||||
#define WCM_PHASE_WAIT 1 // 初期化直後の状態( 要求待ち )
|
||||
#define WCM_PHASE_WAIT_TO_IDLE 2 // 初期化直後の状態 から 無線機能の起動シーケンス中
|
||||
#define WCM_PHASE_IDLE 3 // 無線機能アイドル状態
|
||||
#define WCM_PHASE_IDLE_TO_WAIT 4 // アイドル状態 から 無線機能の停止シーケンス中
|
||||
#define WCM_PHASE_IDLE_TO_SEARCH 5 // アイドル状態 から AP 自動探索状態への移行シーケンス中
|
||||
#define WCM_PHASE_SEARCH 6 // AP 自動探索状態
|
||||
#define WCM_PHASE_SEARCH_TO_IDLE 7 // AP 自動探索状態 から アイドル状態への移行シーケンス中
|
||||
#define WCM_PHASE_IDLE_TO_DCF 8 // アイドル状態 から AP への無線接続シーケンス中
|
||||
#define WCM_PHASE_DCF 9 // AP と無線接続された DCF 通信可能状態
|
||||
#define WCM_PHASE_DCF_TO_IDLE 10 // DCF 通信状態 から 無線接続を切断するシーケンス中
|
||||
#define WCM_PHASE_FATAL_ERROR 11 // 復旧不可能なエラーが発生し、全ての処理が受け付けられない状態
|
||||
#define WCM_PHASE_IRREGULAR 12 // 状態遷移シーケンスの途中で問題が発生した状態
|
||||
#define WCM_PHASE_TERMINATING 13 // WCM ライブラリの強制停止シーケンス中
|
||||
#endif
|
||||
|
||||
while (WCM_GetPhase() != WCM_PHASE_DCF)
|
||||
{
|
||||
OS_Sleep(100);
|
||||
switch( counter ) {
|
||||
case 0:
|
||||
mprintf("\r-LINK UP. ");
|
||||
break;
|
||||
case 1:
|
||||
mprintf("\r-LINK UP.. ");
|
||||
break;
|
||||
case 2:
|
||||
mprintf("\r-LINK UP... ");
|
||||
break;
|
||||
case 3:
|
||||
mprintf("\r-LINK UP.... ");
|
||||
break;
|
||||
case 5:
|
||||
mprintf("\r-LINK UP..... ");
|
||||
break;
|
||||
case 6:
|
||||
mprintf("\r-LINK UP......");
|
||||
counter = -1;
|
||||
break;
|
||||
}
|
||||
OS_Sleep(100);
|
||||
counter++;
|
||||
}
|
||||
|
||||
OS_TPrintf("connected\n");
|
||||
mprintf(" connected\n");
|
||||
|
||||
#ifndef SDK_WIFI_INET
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
ncStartWiFi();
|
||||
|
||||
#else // SDK_WIFI_INET
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
ncStartInet();
|
||||
#endif // SDK_WIFI_INET
|
||||
|
||||
}
|
||||
|
||||
void NcFinish()
|
||||
|
||||
@ -101,7 +101,7 @@ static void PlayStream(StreamInfo * strm, const char *filename)
|
||||
u32 alarmPeriod;
|
||||
|
||||
// 再生中であれば停止する
|
||||
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
// OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
|
||||
if (strm->isPlay)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user