gpt4 book ai didi

ios - 在哪里可以找到 iOS Obj-C 代码以扫描并连接到 wifi(私有(private) API)

转载 作者:可可西里 更新时间:2023-11-01 03:30:49 24 4
gpt4 key购买 nike

我需要一个扫描并连接到 wifi 的示例 obj-c 代码。私有(private) API 可以,我不会将应用发布到应用商店。我在cydia中找到了一个名为“WiFiFoFum”的应用程序,可以扫描和连接,不幸的是我找不到那个应用程序的源代码。任何人都知道我在哪里可以找到该代码?谢谢

最佳答案

在这里找到答案:http://code.google.com/p/iphone-wireless/issues/detail?id=20

它在我的 iPhone 4 v5.1.1 上运行良好。我能够扫描并连接到网络。您可以在这里下载项目 https://github.com/devinshively/wifiAssociate

引用如下:

Apple80211Associate 仍在工作(至少在 3.1.2 上)。在 iPhone OS 2 和 3 之间,该框架已更改名称,因此您应该按如下方式绑定(bind)您的函数:

void *airportHandle;
int (*Apple80211Open)(void *);
int (*Apple80211BindToInterface)(void *, NSString *);
int (*Apple80211Close)(void *);
int (*Apple80211Info)(void *, NSDictionary**);
int (*Apple80211Associate)(void *, NSDictionary*, void *);
int (*Apple80211Scan)(void *, NSArray **, void *);

libHandle = dlopen("/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager", RTLD_LAZY);
Apple80211Open = dlsym(libHandle, "Apple80211Open");
Apple80211BindToInterface = dlsym(libHandle, "Apple80211BindToInterface");
Apple80211Scan = dlsym(libHandle, "Apple80211Scan");
Apple80211Close = dlsym(libHandle, "Apple80211Close");
Apple80211Info = dlsym(libHandle, "Apple80211GetInfoCopy");
Apple80211Associate = dlsym(libHandle, "Apple80211Associate");

从 v2 到 v3 最显着的变化是 SCAN_RSSI_THRESHOLD 参数(用于扫描功能)。它通常取一个正数,与它应该的物理 dB 相去甚远
现在它采用信号的 dB。如果你使用它,你可以将它设置为 -100:这是一个代码片段(从我的代码中挑选的樱桃,所以未经测试):

void *airportHandle;

NSArray *keys = [NSArray arrayWithObjects:@"SCAN_RSSI_THRESHOLD", @"SSID_STR", nil];
NSArray *objects = [NSArray arrayWithObjects:[NSNumber numberWithInt:-100], ssid, nil];

NSDictionary *params = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
NSArray *found;


int openResult = Apple80211Open(&airportHandle);
NSLog(@"Openning wifi interface %@", (openResult == 0?@"succeeded":@"failed"));

int bindResult = Apple80211BindToInterface(airportHandle, @IF_NAME);

int scanResult = Apple80211Scan(airportHandle, &found, params);

NSDictionary *network;

// get the first network found
network = [found objectAtIndex:0];
int associateResult = Apple80211Associate(airportHandle, network,NULL);

Apple80211Close(airportHandle);

关于ios - 在哪里可以找到 iOS Obj-C 代码以扫描并连接到 wifi(私有(private) API),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11725553/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com