Ejemplo n.º 1
0
void writeWifiSettings()
{
// figure out where settings are
	u32 wfcBase = ReadFlashBytes(0x20, 2) * 8 - 0x400;

// loop through wifi settings and reconstruct data
	int i;
	for(i=0;i<3;i++)
	{
		u8 wifiBlock[256];
		memset(wifiBlock, 0, 256);

// read in the current data (if we don't do this, a new friendcode will have to be generated after saving)
		Read_Flash(wfcBase + (i<<8), (char *)wifiBlock, 256);

		if(WifiData->wfc_enable[i] > 0)
		{
// valid profile
			wifiBlock[0xE7] = 0x00;

// modified from the wifi_arm7 read fuction
			wifiBlock[0xE6] = (WifiData->wfc_enable[i] & 0x0F);

			int n;
			for(n=0;n<16;n++) wifiBlock[0x80+n] = WifiData->wfc_wepkey[i][n];
			for(n=0;n<32;n++) wifiBlock[0x40+n] = WifiData->wfc_ap[i].ssid[n];

			memcpy(&wifiBlock[0xC0], (const void *)&WifiData->wfc_config[i][0], 4);
			memcpy(&wifiBlock[0xC4], (const void *)&WifiData->wfc_config[i][1], 4);
			memcpy(&wifiBlock[0xC8], (const void *)&WifiData->wfc_config[i][3], 4);
			memcpy(&wifiBlock[0xCC], (const void *)&WifiData->wfc_config[i][4], 4);

// very simple subnet function
// assumes they typed it in correctly
			char subnet = 0;
			for(n=0;n<32;n++)
			{
				if((WifiData->wfc_config[i][2] >> n) & 1)
				{
					subnet++;
				}
			}

			wifiBlock[0xD0] = subnet;
		}
		else
		{
Ejemplo n.º 2
0
int ReadFlashHWord(int address) {
	if(address<0 || address>510) return 0;
	return ReadFlashBytes(address,2);
}