Where Do I Find iOS Obj-C Code to Scan and Connect to Wifi (Private API)

Where do I find iOS Obj-C code to scan and connect to wifi (private API)

Found the answer here: http://code.google.com/p/iphone-wireless/issues/detail?id=20

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

Here is a citation:

Apple80211Associate is still working (at least on 3.1.2). Between the iPhone OS 2 and 3, the framework has changed name, so you should bind your functions as following:

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");

The most significant change from v2 to v3 is SCAN_RSSI_THRESHOLD parameter (used for the scan function). It use to take a positive number, far from the physical dB it should have been

and now it takes the dB of the signal. If you make use of it, you can set it to -100:
Here is a code snipped (cherry picked from my code, so untested as is):

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 Get list of all WiFi networks

This might be possible with NetworkExtension (available since iOS 8). But you need the com.apple.developer.networking.HotspotHelper-entitlement in you app to use these APIs. To get these entitlement, you have to contact Apple and describe, why you need it.

I haven't found any code examples, but maybe the documentation of NetworkExtension helps you.

Is there any private api to monitor network traffic on iPhone?

I got through this.

I didn't need any private Api to get information of inbound/outbound active connections.
Its just you need to know basic C programming and some patience.

I wrote to apple dev forums regarding this,and got response as-

From my perspective most of what I have to say about this issue is covered in the post referenced below.

<https://devforums.apple.com/message/748272#748272>>

The way to make progress on this is to:

o grab the relevant headers from the Mac OS X SDK

o look at the Darwin source for netstat to see how the pieces fit together

WARNING: There are serious compatibility risks associated with shipping an app that uses this technique; it's fine to use this for debugging and so on, but I recommend against shipping code like this to end users.

What I did step by step is -

1)downloaded code of netstat from BSD opensource -

2)add this to your new iphone project.

3)see,some header files are not present in ios sdk so you need take it copied from opensource.apple.com and add those in your iphone sdk at relevant path under-

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include

My xcode version is 4.5.2. so this is path relevent to my xcode. you can have different path according to versions of xcodes.Anyway. and remember to add those headers in both iosSdk & iOSSimulatorSdk both so that code will work on device as well as on simulator.

4)you may find some minor errors in netstat code relating not finding definitions of some structures in header files.e.g " struct xunpcb64 " .dont wory. definitions are present there.you need to comment some "#if !TARGET_OS_EMBEDDED" #else in those header files so that ios sdk can reach in those if condition and access the definition.(need some try and error.be patient.)

5)finally you will be abe to compile your code.Cheers!!

Connect to WiFi programmatically in ios

I ran into this issue last year and after quite a bit of digging I came across a helpful example called SOLStumbler. For this app to work your device must be jailbroken. I modified SOLStumbler and threw up a sample app on github. It uses the IPConfiguration bundle to access Apple80211 framework, which allows you to associate to a network. The readme contains the custom build instructions.

https://github.com/devinshively/wifiAssociate

IOS get list of wifi networks available

You can do this with abilities of the system, but you can't publish it on the appstore because it is private api.

How to programmatically connect to a WiFi network given the SSID and password

With iOS 11, Apple provided public API you can use to programmatically join a WiFi network without leaving your app.

The class you’ll need to use is called NEHotspotConfiguration.

To use it, you need to enable the Hotspot capability in your App Capabilities (Adding Capabilities). Quick working example :

NEHotspotConfiguration *configuration = [[NEHotspotConfiguration
alloc] initWithSSID:@“SSID-Name”];
configuration.joinOnce = YES;

[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:nil];

This will prompt the user to join the “SSID-Name” WiFi network. It will stay connected to the WiFi until the user leaves the app.

This doesn't work with the simulator you need to run this code with an actual device to make it work.

More informations here :
https://developer.apple.com/documentation/networkextension/nehotspotconfiguration



Related Topics



Leave a reply



Submit