我在哪里可以找到iOS Obj-C代码来扫描并连接到wifi(私有API) [英] Where do I find iOS Obj-C code to scan and connect to wifi (private API)

查看:126
本文介绍了我在哪里可以找到iOS Obj-C代码来扫描并连接到wifi(私有API)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个示例obj-c代码来扫描并连接到wifi。私有API是好的,我不会将应用程序发布到appStore。
我发现cydia中的应用程序称为WiFiFoFum,可以扫描和连接,遗憾的是我无法找到该应用程序的源代码。
有谁知道我在哪里可以找到该代码?
谢谢

I need a sample obj-c code that scans and connects to wifi. Private API is ok, I'm not going to publish the app to appStore. I found the app in cydia called "WiFiFoFum" that can scan and connect, unfortunately I can't find the source code of that app. Anybody knows where I can find that code? Thanks

推荐答案

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

我的iPhone 4 v5.1.1完全正常。我能够扫描并连接到网络。
您可以在此处下载项目 https://github.com/devinshively/wifiAssociate

It works perfectly fine on my iPhone 4 v5.1.1. I'm able to scan and connect to networks. You can download the project here https://github.com/devinshively/wifiAssociate

这是一个引文:

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

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 Obj-C代码来扫描并连接到wifi(私有API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆