1. Access Method

Reference iOS_SDK ACCESS METHOD

2. Scan

Reference iOS_SDK SCAN

3. Connect(FEBluetoothSDK)

  1. Introduce:

    Connecting devices

  2. Method:

/// Connect the device to normal communication mode
/// "@param peripheral" devices 
/// "@param isConnectedBlock" Call back whether the connection is successful, and call back when the connection is disconnected

- (void)connectToModify:(FEPeripheral *)peripheral connectState:(void(^)(FEPeripheral *peripheral, CONNECTSTATE connectState))connectStateBlock;
  1. Example:

[[FEBluetoothSDK sharedFEBluetoothSDK] connectToModify:self.peripheral connectState:^(FEPeripheral * _Nonnull peripheral, CONNECTSTATE connectState) {
                    // Judge the connection result according to the "connectState"
                }];

4、Disconnect

[[FEBluetoothSDK sharedFEBluetoothSDK] disconnect:peripheral complete:^(FEPeripheral * _Nonnull peripheral) {
        // Disconnection complete
    }];

4. Distribution Network(FEPeripheral)

  1. Create FEWiFi object and transfer parameters to device object(FEPeripheral)

    wifi = [[FEWiFi alloc] initWithPeripheral:peripheral];
  1. Distribution Network

    Note: It supports dynamic IP distribution network and static IP distribution network.

    The parameters required for dynamic distribution network include: network name SSID (required), network password (optional, if the network does not require a password);

    The parameters required for static distribution network include: network name SSID (required), network password (optional, if the network does not require a password), static IP address (required), GW (optional), subnet mask MASK (optional), DNS (optional);

    It is worth noting that the Bluetooth module needs to be notified clearly which distribution mode (dynamic or static) to use.

    The Bluetooth distribution network steps :

    Step 1: Query the distribution network mode selected by the current module

[wifi checkConfigDynamicOrStaticNetworkCompleteBlock:^(BOOL isSwitchedDynamic, NSError * _Nullable error) {
        if (!error) {
            if (isSwitchedDynamic) {
                // Dynamic distribution network
            } else {
                // Static distribution network
            }
        }
    }];
  Step 2:  Switch the distribution network mode (if the target mode is met, go directly to step 3)
[wifi switchConfigDynamicOrStaticNetwork:YES completeBlock:^(BOOL isSwitchedDynamic, NSError * _Nullable error) {
        // If the switch is successful, you can start to fill in the relevant distribution network parameters
    }];
  Step 3: Call the corresponding distribution network method (Static distribution network, Dynamic distribution network) and pass in the correct parameters

Dynamic Distribution Network:

[wifi btConfigDynamicNetwork:networkName password:password reconnect:YES completeBlock:^(NSString * _Nullable IPAddress, NSError * _Nullable error) {
            __strong __typeof(weakSelf) strongSelf = weakSelf;
            if (error) {
                [strongSelf showAlertControllerWithTitle:LS(@"Distribution network failure")];
            } else {
                if (IPAddress) {
                    [strongSelf showAlertControllerWithTitle:LS(@"Distribution network succeeded") message:[NSString stringWithFormat:@"IP address is:%@", IPAddress]];
                } else {
                    [strongSelf showAlertControllerWithTitle:LS(@"Distribution network failure")];
                }
            }
        }];

Static Distribution Network:

[wifi btConfigStaticNetwork:networkName password:password staticIp:configer_StaticIP GW:configer_GW MASK:configer_MASL DNS:configer_DNS reconnect:YES completeBlock:^(NSString * _Nullable IPAddress, NSError * _Nullable error) {
            __strong __typeof(weakSelf) strongSelf = weakSelf;
            if (error) {
                [strongSelf showAlertControllerWithTitle:LS(@"Distribution network failure")];
            } else {
                if (IPAddress) {
                    [strongSelf showAlertControllerWithTitle:LS(@"Distribution network succeeded") message:[NSString stringWithFormat:@"IP Address is:%@", IPAddress]];
                } else {
                    [strongSelf showAlertControllerWithTitle:LS(@"Distribution network failure")];
                }
            }
        }];

5. The Firmware Update

// @param name The firmware name
[wifi otaWithName:name progress:^(NSNumber * _Nonnull percent) {
        // Some Bluetooth modules support
    } complete:^(BOOL isSuccess, NSError *error) {
        // Priority should be given to handling the error. If the error is nil, judge when the upgrade is successful
    }];

6. Restore Factory Settings

[wifi restore:^(BOOL isOK) {
        // The isOK value is whether the factory settings are restored successfully
    }];

7. Query Version

[wifi checkVersionComplete:^(NSString * _Nullable version) {
        // version: It is the version number. If it is empty, query failed
    }];

8. Query IP

[wifi checkIPWithHandler:^(NSString * _Nullable IPAddress, NSError * _Nullable error) {
        // IPAddress: It is an IP address. If it is empty, query failed
    }];