Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
608 views
in Technique[技术] by (71.8m points)

iphone - how to enumerate all available Wifi networks at range?

I read on google that this is not possible, and that on OS 2.0, it was some undocumented Api to accomplish that, but then your app will got rejected ....

we are almosto on OS 4.0....any news regarding this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are pre-2.0 solutions to be found on the Internet. One of them seems to be as follows:

void *libHandle;
void *airportHandle;
int (*open)(void *);
int (*bind)(void *, NSString *);
int (*close)(void *);

libHandle = dlopen("/System/Library/Frameworks/Preferences.framework/Preferences", RTLD_LAZY);
open = dlsym(libHandle, "Apple80211Open");
bind = dlsym(libHandle, "Apple80211BindToInterface");
close = dlsym(libHandle, "Apple80211Close");

open(&airportHandle);
bind(airportHandle, CFSTR("en0"));
close(&airportHandle);

dlclose(libHandle);

I'm not sure if accessing this framework is off limits. But running it causes a EXC_BAD_ACCESS. So either the code is wrong, the framework has changed or it's somehow locked. Forgive me for any obvious Objective-C faux-pas. I've only been speaking Objective-C since Thursday, so my Objective-C fluency is probably like parachuting a latin speaker into a hostile Transylvanian mountian region.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...