static PyObject* enum_configs(PyObject *self, PyObject *args) { int index = 1; PyObject *ret; netData name, ip; if (!PyArg_ParseTuple(args, "")) return NULL; ret = PyList_New(0); while (1) { if (sceUtilityCheckNetParam(index)) break; sceUtilityGetNetParam(index, PSP_NETPARAM_NAME, &name); sceUtilityGetNetParam(index, PSP_NETPARAM_IP, &ip); PyList_Append(ret, Py_BuildValue("iss", index, name.asString, ip.asString)); index++; } return ret; }
/** * Find Infrastructure Configuration ID for SSID * @param ssid Target SSID * @return Configuration ID > -1 or... -1 */ int _findHotspotConfigId(char * ssid) { // Counter int i = 0; // Find Hotspot by SSID for(; i <= 10; i++) { // Parameter Container netData entry; // Acquire SSID for Configuration if(sceUtilityGetNetParam(i, PSP_NETPARAM_SSID, &entry) == 0) { // Log Parameter printk("Reading PSP Infrastructure Profile for %s\n", entry.asString); // Hotspot Configuration found if(strcmp(entry.asString, ssid) == 0) return i; } } // Hotspot not found return -1; }
int listAccessPoint() { int pick_count = 0; int iNetIndex; // skip the 0th connection for(iNetIndex = 1; iNetIndex < 100; iNetIndex++) { if(sceUtilityCheckNetParam(iNetIndex) == 0) { sceUtilityGetNetParam(iNetIndex, PSP_NETPARAM_NAME, (void*)AccessPoints[pick_count].pInfo->name); strcpy(AccessPoints[pick_count].pInfo->ip,"Acquiring..."); AccessPoints[pick_count].color = ORANGE; AccessPoints[pick_count].index = iNetIndex; pick_count++; if(pick_count >= MAX_APS) { wifiError = 1; break; } } else break; } if(pick_count == 0) { writeToLogFile("No connections\n"); writeToLogFile("Please try Network Settings\n"); sceKernelDelayThread(1000000); // 1sec to read before exit wifiError = 1; return -1; } return 0; }
void WiFiManager::Connect() { if (IsConnected()) return; if (!sceWlanGetSwitchState()) { LCD::PrintMessage("WiFi not enabled"); return; } Console::Print("Initializing WiFi..."); int err = WiFiManager::Init(); if (err != 0) { Console::Print("Error, bailing out..."); Terminate(); return; } #define MAX_PICK 10 struct { int index; char name[64]; } picks[MAX_PICK]; int pick_count = 0; int iNetIndex; for (iNetIndex = 1; iNetIndex < 100; iNetIndex++) // skip the 0th connection { if (sceUtilityCheckNetParam(iNetIndex) != 0) break; // no more sceUtilityGetNetParam(iNetIndex, 0, picks[pick_count].name); picks[pick_count].index = iNetIndex; pick_count++; if (pick_count >= MAX_PICK) break; // no more room } if (pick_count == 0) { Console::Print("No connections"); LCD::PrintMessage("WIFI: No connections"); Terminate(); return; } Console::Print("Found connections"); int connectionConfig = picks[0].index; // Connect err = sceNetApctlConnect(connectionConfig); if (err != 0) { Console::Print("sceNetApctlConnect returns error"); Terminate(); return; } // Report status while waiting for connection to access point int stateLast = -1; Console::Print("Connecting..."); while (1) { int state; err = sceNetApctlGetState(&state); if (err != 0) { Console::Print("sceNetApctlGetState returns error"); return; } if (state > stateLast) { Console::Print("Next state..."); stateLast = state; } if (state == 4) break; // connected with static IP sceKernelDelayThread(50*1000); // 50ms } Console::Print("Connected!"); LCD::PrintMessage("WIFI Connected"); _connected = true; }