void ShutdownBeforeExit(void)
{
    DeviceHandle.UnMountAll();
    NandHandle.DeInit_ISFS();
    WDVD_Close();
    Close_Inputs();
    /* Deinit network */
    if(networkInit == true)
    {
        while(net_get_status() == -EBUSY)
            usleep(50);
        WiFiDebugger.Close();
        ftp_endTread();
        net_deinit();
        networkInit = false;
    }
}
示例#2
0
void WiiOptionsDialog::handleTickle() {
	WiiFilesystemFactory &fsf = WiiFilesystemFactory::instance();

	int tab = _tab->getActiveTab();

#ifdef USE_WII_DI
	if (tab == _tabDVD) {
		if (fsf.isMounted(WiiFilesystemFactory::kDVD)) {
			_textDVDStatus->setLabel(_("DVD Mounted successfully"));
		} else {
			if (fsf.failedToMount(WiiFilesystemFactory::kDVD))
				_textDVDStatus->setLabel(_("Error while mounting the DVD"));
			else
				_textDVDStatus->setLabel(_("DVD not mounted"));
		}
	}
#endif

#ifdef USE_WII_SMB
	if (tab == _tabSMB) {
		s32 status = net_get_status();
		String label;

		switch (status) {
		case 0:
			if (fsf.isMounted(WiiFilesystemFactory::kSMB)) {
				label = _("Network up, share mounted");
			} else {
				label = _("Network up");

				if (fsf.failedToMount(WiiFilesystemFactory::kSMB))
					label += _(", error while mounting the share");
				else
					label += _(", share not mounted");
			}

			break;

		case -ENETDOWN:
			label = _("Network down");
			break;

		case -EBUSY:
			label = _("Initializing network");
			break;

		case -ETIMEDOUT:
			label = _("Timeout while initializing network");
			break;

		default:
			label = String::format(_("Network not initialized (%d)"), status);
			break;
		}

		_textSMBStatus->setLabel(label);
	}
#endif

	Dialog::handleTickle();
}
示例#3
0
static void * WiiloadThread(void *arg)
	{
	int netInit = 0;
	int netReady = 0;
	int wc24cleared = 0;
	
	stopNetworkThread = 0;
	errors = 0;
	
	strcpy(wiiload.ip, "<unknown>");
	
	printopt("Net thread running, ready !");
	
	while (!stopNetworkThread)
		{
		if (!netInit)
			{
			s32 res;
			
			res = net_init_async(NULL, NULL);
			Debug ("net_init_async %d", res);

			if (res != 0)
				{
				errors ++;
				continue;
				}
				
			netInit = 1;
			}
			
		if (netInit)
			{
			if (errors > 5 && !wc24cleared)
				{
				Debug ("Cleareing  net_wc24cleanup");
				
				net_deinit ();
				net_wc24cleanup();
				
				errors = 0;
				netInit = 0;
				wc24cleared = 1;
				}
			
			s32 res;
			res = net_get_status();
			Debug ("net_get_status %d", res);

			if (res == 0)
				{
				struct in_addr hostip;
				hostip.s_addr = net_gethostip();

				if (hostip.s_addr)
					{
					strcpy(wiiload.ip, inet_ntoa(hostip));
					netReady = 1;
					}
				}
			else
				errors ++;
			}
			
		if (netReady)
			{
			if (!StartWiiLoadServer ())
				errors ++;
			}
			
		sleep (1);
			
		if (errors > 10)
			{
			Debug ("too many errors");
			stopNetworkThread = 1;
			}
		}
	
	stopNetworkThread = 2;
	
	wiiload.status = WIILOAD_STOPPED;
	
	net_deinit();
	
	return NULL;
	}
示例#4
0
bool
display_status(void)
{
    static uint32_t bytes_sent;
    static uint32_t bytes_received;
    static uint32_t	rate;

    // Clear screen
    putchar(CTRL(FF));

    struct datetime_t datetime;
    time_decode(&datetime, clock_time());

    printf_P(PSTR("Time: %02d:%02d:%02d\n\n"), datetime.hour, datetime.min, datetime.sec);

    const struct net_status_t* net_status;
    net_status = net_get_status();

    printf_P(PSTR("Network connection:\n"));
    printf_P(PSTR(" Link state: [ %s ]\n\n"), (net_status->link) ? "UP" : "DOWN");

    printf_P(PSTR(" Packets sent: %lu\n"), net_status->packets_sent);

    printf_P(PSTR(" Data sent: "));

    if(net_status->bytes_sent < 1024) {
        printf_P(PSTR("%lu Bytes\n"), net_status->bytes_sent);
    } else if(net_status->bytes_sent < 1048576) {
        printf_P(PSTR("%lu kB\n"), net_status->bytes_sent / 1024);
    } else {
        printf_P(PSTR("%lu MB\n"), net_status->bytes_sent / 1048576);
    }

    rate = net_status->bytes_sent - bytes_sent;

    printf_P(PSTR(" Data rate: "));

    if(rate < 1024) {
        printf_P(PSTR("%lu B/s\n\n"), rate);
    } else if(rate < 1048576) {
        printf_P(PSTR("%lu kB/s\n\n"), rate / 1024);
    } else {
        printf_P(PSTR("%lu MB/s\n\n"), rate / 1048576);
    }

    bytes_sent = net_status->bytes_sent;


    printf_P(PSTR(" Packets received: %lu\n"), net_status->packets_received);

    printf_P(PSTR(" Data received: "));

    if(net_status->bytes_received < 1024) {
        printf_P(PSTR("%lu Bytes\n"), net_status->bytes_received);
    } else if(net_status->bytes_received < 1048576) {
        printf_P(PSTR("%lu kB\n"), net_status->bytes_received / 1024);
    } else {
        printf_P(PSTR("%lu MB\n"), net_status->bytes_received / 1048576);
    }

    rate = net_status->bytes_received - bytes_received;

    printf_P(PSTR(" Data rate: "));

    if(rate < 1024) {
        printf_P(PSTR("%lu B/s\n"), rate);
    } else if(rate < 1048576) {
        printf_P(PSTR("%lu kB/s\n"), rate / 1024);
    } else {
        printf_P(PSTR("%lu MB/s\n"), rate / 1048576);
    }

    bytes_received = net_status->bytes_received;

    return true;
}
示例#5
0
static void * netcb (void *arg)
{
	s32 res=-1;
	int retry;
	int wait;
	static bool prevInit = false;

	while(netHalt != 2)
	{
		retry = 5;
		
		while (retry>0 && (netHalt != 2))
		{			
			if(prevInit) 
			{
				int i;
				net_deinit();
				for(i=0; i < 400 && (netHalt != 2); i++) // 10 seconds to try to reset
				{
					res = net_get_status();
					if(res != -EBUSY) // trying to init net so we can't kill the net
					{
						usleep(2000);
						net_wc24cleanup(); //kill the net 
						prevInit=false; // net_wc24cleanup is called only once
						usleep(20000);
						break;					
					}
					usleep(20000);
				}
			}

			usleep(2000);
			res = net_init_async(NULL, NULL);

			if(res != 0)
			{
				sleep(1);
				retry--;
				continue;
			}

			res = net_get_status();
			wait = 400; // only wait 8 sec
			while (res == -EBUSY && wait > 0  && (netHalt != 2))
			{
				usleep(20000);
				res = net_get_status();
				wait--;
			}

			if(res==0) break;
			retry--;
			usleep(2000);
		}
		if (res == 0)
		{
			struct in_addr hostip;
			hostip.s_addr = net_gethostip();
			if (hostip.s_addr)
			{
				strcpy(wiiIP, inet_ntoa(hostip));
				networkInit = true;	
				prevInit = true;
			}
		}
		if(netHalt != 2) LWP_SuspendThread(networkthread);
	}
	return NULL;
}