git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@19 7061adef-622a-194b-ae81-725974e89856

This commit is contained in:
miya 2008-10-21 10:59:53 +00:00
parent 7e63bdf031
commit 6831b18e1d
6 changed files with 394 additions and 156 deletions

View File

@ -31,8 +31,8 @@
extern "C" { extern "C" {
#endif #endif
void ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds); BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds);
void KPSClient(); BOOL KPSClient();
BOOL WaitEC(ECOpId opId); BOOL WaitEC(ECOpId opId);

View File

@ -15,6 +15,11 @@
#include "hatamotolib.h" #include "hatamotolib.h"
#include "text.h"
#include "mprintf.h"
#include "logprintf.h"
#ifdef SDK_DEBUG #ifdef SDK_DEBUG
#define ECDL_LOG(msg) OS_TPrintf("----\nECDL-LOG: %s\n----\n", msg); #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); 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]); OS_TPrintf("%02X", p[i]);
} }
@ -270,10 +275,16 @@ void PrintDeviceInfo(void)
void SetupTitlesDataFile(const NAMTitleId* pTitleIds, u32 numTitleIds) 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); 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 u32 logLevel, clientCertSize, clientKeySize;
static char deviceCode[17]; static char deviceCode[17];
@ -435,16 +446,30 @@ void SetupEC(void)
const u32 nInitArgs = sizeof(initArgs) / sizeof(initArgs[0]); const u32 nInitArgs = sizeof(initArgs) / sizeof(initArgs[0]);
rv = EC_Init(initArgs, nInitArgs); 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", rv = EC_SetWebSvcUrls( "https://ecs.t.shop.nintendowifi.net/ecs/services/ECommerceSOAP",
"https://ias.t.shop.nintendowifi.net/ias/services/IdentityAuthenticationSOAP", "https://ias.t.shop.nintendowifi.net/ias/services/IdentityAuthenticationSOAP",
"https://cas.t.shop.nintendowifi.net/cas/services/CatalogingSOAP" ); "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", rv = EC_SetContentUrls( "http://ccs.t.shop.nintendowifi.net/ccs/download",
"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(;;) for(;;)
{ {
result = EC_GetProgress(opId, &progress); result = EC_GetProgress(opId, &progress);
if( (result != EC_ERROR_OK) && (result != EC_ERROR_NOT_DONE) ) if( (result != EC_ERROR_OK) && (result != EC_ERROR_NOT_DONE) )
{ {
if( result == EC_ERROR_NOT_ACTIVE ) if( result == EC_ERROR_NOT_ACTIVE )
@ -473,9 +497,11 @@ BOOL WaitEC(ECOpId opId)
OS_TPrintf("opId=%d\n", opId); OS_TPrintf("opId=%d\n", opId);
} }
OS_TPrintf("Failed to EC_GetProgress, result=%d %s\n", result, GetECErrorString(result)); 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; return FALSE;
} }
#if 0
//#ifdef SDK_DEBUG //#ifdef SDK_DEBUG
if( MI_CpuComp8(&progress_prev, &progress, sizeof(progress)) != 0 ) if( MI_CpuComp8(&progress_prev, &progress, sizeof(progress)) != 0 )
{ {
@ -492,6 +518,7 @@ BOOL WaitEC(ECOpId opId)
progress_prev = progress; progress_prev = progress;
} }
//#endif //#endif
#endif
if( progress.phase == EC_PHASE_Done ) if( progress.phase == EC_PHASE_Done )
{ {
break; break;
@ -515,7 +542,9 @@ namespace
ECDL_LOG("check registeration"); ECDL_LOG("check registeration");
progress = EC_CheckRegistration(); progress = EC_CheckRegistration();
WaitEC(progress); if( FALSE == WaitEC(progress) ) {
return '\0'; // 微妙・・
}
ecError = EC_GetDeviceInfo(&di); ecError = EC_GetDeviceInfo(&di);
SDK_ASSERT( ecError == EC_ERROR_OK ); SDK_ASSERT( ecError == EC_ERROR_OK );
@ -557,131 +586,254 @@ namespace
return di.registrationStatus[0]; return di.registrationStatus[0];
} }
void GetChallenge(char* challenge) BOOL GetChallenge(char* challenge)
{ {
s32 progress; s32 progress;
ECError ecError; ECError ecError;
ECDL_LOG("get challenge"); ECDL_LOG("get challenge");
progress = EC_SendChallengeReq(); progress = EC_SendChallengeReq();
WaitEC(progress); if( FALSE == WaitEC(progress) ) {
return FALSE;
}
ecError = EC_GetChallengeResp(challenge); ecError = EC_GetChallengeResp(challenge);
SDK_ASSERT( ecError == EC_ERROR_OK ); SDK_ASSERT( ecError == EC_ERROR_OK );
return TRUE;
} }
void SyncRegistration(const char* challenge) BOOL SyncRegistration(const char* challenge)
{ {
s32 progress; s32 progress;
ECDL_LOG("sync registration"); ECDL_LOG("sync registration");
progress = EC_SyncRegistration(challenge); 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; s32 progress;
ECDL_LOG("register"); ECDL_LOG("register");
progress = EC_Register(challenge, NULL, NULL); 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; s32 progress;
ECDL_LOG("transfer"); ECDL_LOG("transfer");
progress = EC_Transfer(challenge); progress = EC_Transfer(challenge);
WaitEC(progress); if( FALSE == WaitEC(progress) ) {
return FALSE;
}
return TRUE;
} }
void SyncTickets() BOOL SyncTickets()
{ {
s32 progress; s32 progress;
ECDL_LOG("sync tickets"); ECDL_LOG("sync tickets");
progress = EC_SyncTickets(EC_SYNC_TYPE_IMPORT_ALL); 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; s32 progress;
ECDL_LOG("download"); ECDL_LOG("download");
for( u32 i = 0; i < numTitleIds; ++i ) for( u32 i = 0; i < numTitleIds; i++ )
{ {
NAMTitleId tid = pTitleIds[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); progress = EC_DownloadTitle(tid, EC_DT_UPDATE_REQUIRED_CONTENTS);
WaitEC(progress); if( FALSE == WaitEC(progress) ) {
return FALSE;
} }
} }
return TRUE;
}
} }
void BOOL ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds)
{ {
char challenge[EC_CHALLENGE_BUF_SIZE]; char challenge[EC_CHALLENGE_BUF_SIZE];
char status; char status;
// mprintf("-CheckRegistration..\n");
status = CheckRegistration(); status = CheckRegistration();
// U unregistered // U unregistered
// R registered // R registered
// P pending // P pending
// T transfered // T transfered
#if 0
SDK_ASSERTMSG(status != 'U', "acount not transfered yet."); SDK_ASSERTMSG(status != 'U', "acount not transfered yet.");
SDK_ASSERTMSG(status != 'R', "already registered. please delete acount."); SDK_ASSERTMSG(status != 'R', "already registered. please delete acount.");
SDK_ASSERTMSG( (status == 'P') || (status == 'T'), "invalid registration status '%c'", status ); 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); mprintf("-get challenge1 ");
Transfer(challenge); 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(); mprintf("-transfer ");
DownloadTitles(pTitleIds, numTitleIds); 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 BOOL KPSClient()
KPSClient()
{ {
s32 progress; s32 progress;
OS_TPrintf("generate key pair\n"); OS_TPrintf("generate key pair\n");
mprintf("-generate key pair ");
progress = EC_GenerateKeyPair(); 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"); OS_TPrintf("confirm key pair\n");
mprintf("-confirm key pair ");
progress = EC_ConfirmKeyPair(); progress = EC_ConfirmKeyPair();
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__); if( FALSE == WaitEC(progress) ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
WaitEC(progress); mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__); 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(); PrintDeviceInfo();
OS_TPrintf("--------------------------------\n"); OS_TPrintf("--------------------------------\n");
// setup // setup
{
// 必須:タイトル ID の偽装 // 必須:タイトル ID の偽装
SetupShopTitleId(); SetupShopTitleId();
@ -692,69 +844,113 @@ BOOL hatamotolib_main(void)
SetupVerData(); SetupVerData();
// 必須:ネットワークへの接続 // 必須:ネットワークへの接続
OS_TPrintf("connecting to AP....\n");
NcStart(SITEDEFS_DEFAULTCLASS); NcStart(SITEDEFS_DEFAULTCLASS);
/******** ネットワークにつないだ *************/
OS_TPrintf("connected\n");
// 必須HTTP と SSL の初期化 // 必須HTTP と SSL の初期化
OS_TPrintf("start NHTTP\n"); OS_TPrintf("start NHTTP\n");
mprintf("-start NHTTP ");
SetupNSSL(); SetupNSSL();
if( FALSE == SetupNHTTP() ) { 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; 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 );
}
/******** NHTTP & NSSLにつないだ *************/
// 必須EC の初期化 // 必須EC の初期化
OS_TPrintf("start EC\n"); OS_TPrintf("start EC\n");
SetupEC(); 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 );
} }
// body
{
// ダウンロードすべきタイトルの指定
NAMTitleId tids[] =
{
0x00030004346b6141ull,
// 0x0003000434616141ull,
// 0x0003000434616241ull,
// 0x000300043461644aull,
// 0x0003000434616741ull,
// 0x0003000434616a41ull,
// 0x0003000434617441ull,
// 0x0003000434626141ull,
// 0x0003000434626341ull,
// 0x0003000434626641ull,
// 0x0003000434626841ull,
// 0x0003000434626941ull,
// 0x0003000434636341ull,
// 0x00030004346b6141ull,
// 0x00030004346b6241ull,
// 0x00030004346b6341ull,
};
// 必須:デバイス証明書の発行 // 必須:デバイス証明書の発行
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,
if( FALSE == ECDownload((NAMTitleId *)title_id_buf , num_title) ) {
return FALSE;
}
// 不要:セーブデータ領域を作成 // 不要:セーブデータ領域を作成
SetupTitlesDataFile(tids, sizeof(tids)/sizeof(*tids)); // NAM_Init を忘れてた
SetupTitlesDataFile((NAMTitleId *)title_id_buf , num_title);
if( title_id_buf != NULL && num_title != 0 ) {
OS_Free( title_id_buf );
} }
// cleanup // cleanup
{
ECError rv = EC_ERROR_OK;
// EC の終了処理 // EC の終了処理
mprintf("-EC_Shutdown.. ");
rv = EC_Shutdown(); rv = EC_Shutdown();
SDK_WARNING(rv == EC_ERROR_OK, "Failed to shutdown EC, rv=%d\n", rv); // 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(); NcFinish();
} // つなぎっぱなしにするならいらない。
TerminateWcmControl();
OS_TPrintf("Done.\n");
mprintf("Done.\n");
// EC が自分の Title ID のディレクトリを作成してしまうため、削除する // EC が自分の Title ID のディレクトリを作成してしまうため、削除する
DeleteECDirectory(); DeleteECDirectory();

View File

@ -9,17 +9,13 @@ void PrintDeviceInfo(void);
void SetupShopTitleId(void); void SetupShopTitleId(void);
void SetupUserInfo(void); void SetupUserInfo(void);
void SetupVerData(void); void SetupVerData(void);
void NetworkAutoConnect_DWC(void);
void NetworkShutdown_DWC(void);
void SetupNSSL(void); void SetupNSSL(void);
BOOL SetupNHTTP(void); BOOL SetupNHTTP(void);
void SetupEC(void); BOOL SetupEC(void);
BOOL WaitEC(ECOpId opId);
void DeleteECDirectory(void); void DeleteECDirectory(void);
void SetupTitlesDataFile(const NAMTitleId* pTitleIds, u32 numTitleIds); void SetupTitlesDataFile(const NAMTitleId* pTitleIds, u32 numTitleIds);
BOOL hatamotolib_main(void); BOOL hatamotolib_main(u64 *title_id_buf, u32 num_title);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -583,7 +583,7 @@ static BOOL CheckSystemApp(char path[])
if( ('a' <= c) && (c <= 'f') ) { if( ('a' <= c) && (c <= 'f') ) {
num = (int)( c - 'a' + 10 ); num = (int)( c - 'a' + 10 );
} }
if( ('A' <= c) && (c <= 'F') ) { else if( ('A' <= c) && (c <= 'F') ) {
num = (int)( c - 'A' + 10 ); num = (int)( c - 'A' + 10 );
} }
else if( ('0' <= c) && (c <= '9') ) { else if( ('0' <= c) && (c <= '9') ) {
@ -614,23 +614,19 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
u8 hex; u8 hex;
if( head == NULL ) { if( head == NULL ) {
*pBuffer = buf; *pBuffer = NULL;
*size = count; *size = 0;
} }
else { 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 ) { if( list_temp->src_path ) {
#ifdef MYDEBUG
count++;
#else
if( FALSE == CheckSystemApp( list_temp->src_path) ) { if( FALSE == CheckSystemApp( list_temp->src_path) ) {
count++; count++;
} }
#endif
} }
} }
OS_TPrintf("User App. count1 = %d\n", count); OS_TPrintf("User App. count1 = %d\n", count);
// mprintf("\nUser App. count1 = %d\n", count);
if( count ) { if( count ) {
buf = (u64 *)OS_Alloc( (u32)(count * sizeof(u64)) ); 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; *pBuffer = buf;
*size = count; *size = count;
count = 0; 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 ) { if( list_temp->src_path ) {
/* /*
No. 0 0003000f484e4c41 No. 0 0003000f484e4c41
@ -657,9 +653,8 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
| |
*/ */
#ifndef MYDEBUG
if( FALSE == CheckSystemApp( list_temp->src_path ) ) { if( FALSE == CheckSystemApp( list_temp->src_path ) ) {
#endif /* koko-made */
count++; count++;
/* User App. */ /* User App. */
@ -677,7 +672,7 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
} }
else { else {
/* error! */ /* error! */
count--; // count--;
return; return;
} }
*buf |= (((u64)hex) << ((7-i)*4 + 32 )); *buf |= (((u64)hex) << ((7-i)*4 + 32 ));
@ -697,17 +692,15 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size)
} }
else { else {
/* error! */ /* error! */
count--; // count--;
return; return;
} }
*buf |= (((u64)hex) << ((7-i)*4 )); *buf |= (((u64)hex) << ((7-i)*4 ));
} }
buf++; buf++;
OS_TPrintf("User App. count2 = %d\n", count); // OS_TPrintf("User App. count2 = %d\n", count);
#ifndef MYDEBUG
} }
#endif
/* /*
012345678901234567890123456789 012345678901234567890123456789
nand:/title/00030017/484e4141 nand:/title/00030017/484e4141
@ -1292,6 +1285,7 @@ BOOL TitleIDSave(const char *path, u64 *pData, int count, FSFile *log_fd)
nand:/title/00030017/484e414a nand:/title/00030017/484e414a
*/ */
if( ( pData != NULL ) && ( count != 0 ) ) {
/* 16文字だから */ /* 16文字だから */
if( (count*sizeof(u64)) != FS_WriteFile(&f, pData, (s32)(count*sizeof(u64)) )) { if( (count*sizeof(u64)) != FS_WriteFile(&f, pData, (s32)(count*sizeof(u64)) )) {
res = FS_GetArchiveResultCode( path ); res = FS_GetArchiveResultCode( path );
@ -1299,6 +1293,7 @@ BOOL TitleIDSave(const char *path, u64 *pData, int count, FSFile *log_fd)
miya_log_fprintf(NULL, " Failed write file:%s\n", my_fs_util_get_fs_result_word( res )); miya_log_fprintf(NULL, " Failed write file:%s\n", my_fs_util_get_fs_result_word( res ));
return FALSE; return FALSE;
} }
}
FS_FlushFile(&f); FS_FlushFile(&f);
bSuccess = FS_CloseFile(&f); bSuccess = FS_CloseFile(&f);

View File

@ -23,6 +23,11 @@
#include "netconnect.h" #include "netconnect.h"
#include "mywlan.h" #include "mywlan.h"
#include "text.h"
#include "mprintf.h"
#include "logprintf.h"
/*---------------------------------------------------------------------------* /*---------------------------------------------------------------------------*
<EFBFBD>Šú» <EFBFBD>Šú»
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
@ -250,13 +255,15 @@ static void ncFinishInet(void)
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
void NcStart(const char* apClass) 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()) ) { if( FALSE == ENV_SetBinary("WiFi.LAN.1.AP.1.WEP.KEY", (void *)GetWlanKEYSTR()) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__); OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
} }
if( FALSE == ENV_SetString("WiFi.LAN.1.AP.1.ESSID", GetWlanSSID()) ) { if( FALSE == ENV_SetString("WiFi.LAN.1.AP.1.ESSID", GetWlanSSID()) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__); OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
} }
@ -270,31 +277,75 @@ void NcStart(const char* apClass)
OS_Panic("Invalid AP Class...."); OS_Panic("Invalid AP Class....");
} }
while (WCM_GetPhase() != WCM_PHASE_NULL) 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); OS_Sleep(100);
} }
InitWcmControlByApInfoEx(&apInfo, g_deviceId); InitWcmControlByApInfoEx(&apInfo, g_deviceId);
OS_TPrintf("LINK UP....\n"); 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) 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); OS_Sleep(100);
counter++;
} }
OS_TPrintf("connected\n");
mprintf(" connected\n");
#ifndef SDK_WIFI_INET #ifndef SDK_WIFI_INET
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
ncStartWiFi(); ncStartWiFi();
#else // SDK_WIFI_INET #else // SDK_WIFI_INET
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
ncStartInet(); ncStartInet();
#endif // SDK_WIFI_INET #endif // SDK_WIFI_INET
} }
void NcFinish() void NcFinish()

View File

@ -101,7 +101,7 @@ static void PlayStream(StreamInfo * strm, const char *filename)
u32 alarmPeriod; u32 alarmPeriod;
// 再生中であれば停止する // 再生中であれば停止する
OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__); // OS_TPrintf("%s %d\n",__FUNCTION__,__LINE__);
if (strm->isPlay) if (strm->isPlay)