wifi
AP
STA
SSID
BSSID
Hotspot


An overview of the

A chance to contact a WiFi application, mainly connected to a WiFi camera. The camera device is turned on to create a wireless network (equivalent to a hotspot). The mobile phone /iPad opens the App to connect to the wifi of the device, and controls the camera taking photos and recording through the operation on the App interface, as well as some file downloading and other functions.

1. What are the STA and AP modes of WiFi?

1) : AP, also known as wireless access point, is the founder of a wireless network and the central node of the network. The average wireless router used in a home or office is an AP.

2) : STA site each terminal connected to a wireless network (such as a laptop, PDA and other user devices that can be connected to the network) can be called a site.

Station site (STA) on the wireless local area network (WLAN, WirelessLocalAreaNetworks) in general for the client, can be equipped with computer, wireless network card have WiFi modules can also be a smartphone, can be mobile, also can be fixed. The process of STA access in wireless environment includes: verifying whether STA has permission and establishing a link with AccessPoint (AP, AccessPoint); Whether STA can access WLAN; After the STA is connected to the WLAN, the STA is authenticated to access the WLAN. In the process of establishing a link between STA and AP, when STA scans the SSID (ServiceSetIdentifier) accessible through Beacon frame or Proberesponse frame, According to have received Beacon frame or Proberesponse frame of signal strength indicator (RSSI, ReceivedSignalStrengthIndication) to select the appropriate SSID to access.

Access Point (AP) : a wireless Access Point (AP) is a very broad concept. In this word, you can regard CC3200 as a wireless router. The feature of this router is that it cannot plug in network cables and cannot Access the Internet. It’s kind of like point-to-point. STA(Station) : Any device connected to a wireless AP can be called a site. Baymax is a device connected to a router

Service Set Identifier (SSID) : SSID, each wireless AP should have an Identifier for user identification, SSID is the name used for user identification, that is, we often talk about wifi name.

BSSID: Each network device has its physical address for identification. This is called a MAC address. Generally, it has a default value that can be changed and a fixed naming format, which is also the identifier for device identification. This BSSID is specific to devices. For STA devices, the MAC address of the AP access point is this BSSID.

ESSID: is an abstract concept. It is the same as an SSID (a string of characters), but if there are several wireless routers with this name, we can extend the SSID, so the common name of all wireless routers is ESSID. (That is, if the wifi signal released on a router is called by a name such as “China_CMCC”, the name “China_CMCC” is called SSID; If the wifi signal is emitted on several routers, everyone will be called “China_CMCC”, which is ESSID

For example, if a large company has several wireless access points (aps or wireless routers) installed, employees only need to know one SSID to access the wireless network anywhere in the company. BSSID is the MAC address of each wireless access point. When an employee moves within the company, the SSID is constant. But the BSSID is constantly changing as you switch to different wireless access points.

In joker terms, BSSID is the number (001) or address of a specific chain store, SSID is the name or photo of the chain store, and ESSID is the head office, signboard or brand of the chain store. Ssid and ESSID are generally the same.

RSSI: This is easier to understand, is the signal strength scanned by STA to AP site.

2. IOS automatically connects to WiFi

Via wi-fi to control device, can only jump to system Settings interface manually before iOS11 connected wi-fi, provide NEHotspotConfiguration iOS11 after apple, NEHotspotConfigurationManager class directly connected wi-fi.

1) Permission configuration

In three simple steps, Hotspot permissions are enabled. And, in the Build Phase – > link Binary With Libraries, also has been added automatically NetworkExtension. Framework.

2) Join WiFi

#import <NetworkExtension/NetworkExtension.h>- (void)getJoinedWifiList{if(@ the available (iOS 11.0, *)) { [[NEHotspotConfigurationManager sharedManager] getConfiguredSSIDsWithCompletionHandler:^(NSArray<NSString *> * array) {if (array && array.count > 0) {
                UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"Connecting device" message:@"Please select the device to connect to." preferredStyle:(UIAlertControllerStyleActionSheet)];
                for (NSString * str in array) {
                    UIAlertAction *action = [UIAlertAction actionWithTitle:str style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
                        [self joinWifiWithSSID:str pwd: @"123456"];
                    }];
                    [alertC addAction:action];
                }
                UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel"style:(UIAlertActionStyleDestructive) handler:^(UIAlertAction * _Nonnull action) { }]; [alertC addAction:cancel]; [self presentViewController:alertC animated:YES completion:nil]; }}]; }else{// Fallback on earlier versions}} // add WiFi - (void)joinWifiWithSSID:(NSString *)ssidpwd:(NSString *)pwd {
    if(@ the available (iOS 11.0, *)) { NEHotspotConfiguration *hotspotConfig = [[NEHotspotConfiguration alloc] initWithSSID:ssid passphrase:pwdisWEP:NO]; hotspotConfig.joinOnce = YES; // Default is NO, the configured wifi will be retained, YES is not save / / connection (this method is called after the system will automatically pop-up confirmation) [[NEHotspotConfigurationManager sharedManager] applyConfiguration: hotspotConfig completionHandler:^(NSError * _Nullable error) { NSLog(@"% @",error);
            if(error && error.code ! = 13 && error.code ! = 7) { NSLog(@"Connection failed");
            }else if(error.code ==7){// Error code =7: the user clicked on the popup cancel button NSLog(@"The user hit the popup cancel button.");
            }else{// error code = 13: NSLog(@) has been connected"Connected"); }}]; }else {
        // Fallback on earlier versions
    }
}
Copy the code
Relevant reference
  1. What are STA and AP modes for WiFi?
  2. IOS App automatically connects to Wi-Fi without skipping to the system