FeasyWiFi SDK For Android

[中文]

SDK Resource Kit Download

[Dwonload FeasyWiFi_SDK_2.0.3]

SDK Access Documents

SDK Version

Writing Date

Author

V2.0.3

2024/4/13

Chang Jigang

Access Method

Unzip the SDK and drag all the files in the libs directory into the project.

Permission Request

To use the SDK, it is necessary to dynamically obtain location permissions, turn on the phone’s location and Bluetooth in order to use it normally (For Android 6.0 or above, user needs to have dynamic location permissions and turn on the phone’s location, if it is not turned on, the phone will not be able to scan the BLE device due to the limitation of Android.)

The following permissions need to be added to AndroidManifest.xml.

// Bluetooth related permissions
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

// Positioning related permissions
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Iitialization

// Initialization only needs to be called once. Suggest initializing in Application
// If FscBleCentralApi is needed elsewhere, simply call the unarmed method of FscBleCentralApiImp. getInstance()
FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance(context)
mFscBleCentralApi.initialize()

Connect

Introduce

Connecting devices

Method

/**
* Connect the device based on the address code of the BLE device
*/
public boolean connect(String address);

Connection Example

FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance();

mFscBleCentralApi.setCallbacks(new FscBleCentralCallbacksImp(){

  void blePeripheralConnected(BluetoothGatt gatt, BluetoothDevice device){
      // Connection successful
  }

});

// Connecting device
mFscBleCentralApi.connect(device.getAddress);

Disconnect

FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance();
mFscBleCentralApi.setCallbacks(new FscBleCentralCallbacksImp(){
   void blePeripheralDisconnected(BluetoothGatt gatt, BluetoothDevice device, boolean isPinError){
        // Whether the call to isPinError after the device is disconnected is caused by a pin code error. This parameter is ignored temporarily
   }

});
// Connecting device
mFscBleCentralApi.disconnect();

Distribution Network

Bluetooth Network Distribution

1.Introduce

Bluetooth network distribution

2.Method

/**
* Bluetooth network distribution
* @param ssid
* @param password
* @param fscNetworkCentralCallbacks
*/
public void setNetwork(String ssid, String password, FscNetworkCentralCallbacks fscNetworkCentralCallbacks);

3.Bluetooth Networking Example

FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance();

mFscBleCentralApi.setNetwork(ssid, password, new FscNetworkCentralCallbacks(){
   void success(String ip){
       // Bluetooth network configuration successful, return module IP address
   }

   void failure(){
       // Bluetooth network configuration failure
   }
});

Simple Distribution Network

1.Introduce

BW246 simple network configuration (2.4G), the phone needs to first connect to the required WiFi configuration.

2.Method

 /**
 * Start simple network distribution
 * @param i {@link Commont#BW_246}
 * @param result
 * @param password
 */
void startConfig(int i, StateResult result, String password)

3.Distribution Network Example

ConfigNetworkApi mConfigNetworkApi = ConfigNetworkApiImp.getInstance(this);

mConfigNetworkApi.setCallback(new ConfigNetworkCallback(){
   void success(String ip){
       // Successfully configured, return the successfully configured IP address
   }

   void failure(int status){
       // Configuration failed, returning failure status
   }
});

StateResult result = mConfigNetworkApi.getStateResult();

mConfigNetworkApi.startConfig(Commont.BW_246, result, password);

4.Stop Distribution Network

mConfigNetworkApi.stopConfig();

Restore Factory Settings

FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance();

mFscBleCentralApi.reset();

Upgrade

FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance();

//  Name Local IP address or firmware name
mFscBleCentralApi.startOTA(name, new FscOtaCentralCallbacks(){
  void success(){
      // Upgrade successful
  }

  void failure(){
      // Upgrade failed
  }

  void progress(String progress){
      // Upgrade progress
  }

  void networkIsNotConfigured(){
      // Not yet connected to the network. Unable to upgrade
  }

  void startConfig(){
      // Start configuration
  }
})

Query Version

FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance();
mFscBleCentralApi.setCallback(new FscBleCentralCallbacksImp(){
  void versionInformation(String version){
      // Discovered version information
  }
});
mFscBleCentralApi.getVersion();

Query IP

FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance();
mFscBleCentralApi.setCallback(new FscBleCentralCallbacksImp(){
  void ipInformation(String ip){
      // Found IP information
  }
});
mFscBleCentralApi.getIP();

Configure Static IP

FscBleCentralApi mFscBleCentralApi = FscBleCentralApiImp.getInstance();
mFscBleCentralApi.setDhcp(b)
mFscBleCentralApi.setIp(ip)
mFscBleCentralApi.setGw(gw)
mFscBleCentralApi.setMask(mask)

Attachment

Download PDF Version

Download PDF Version