Cloud-Based Activation of Wi-Fi and Bluetooth Combo Devices

Last Updated on : 2024-09-06 06:18:07download

Preparation

  • SDK version of 2.3.0-indy or later supports this feature.
  • To enable cloud-based activation, a Bluetooth connection to the device must be created. This way, cloud-based activation data can be transmitted to the device over Bluetooth.
  • To check whether a device is activated in the cloud, call IDevice.getMeta().get("wifiEnable") to get the Wi-Fi connection status. A value of true indicates that the cloud-based activation is successful.
  • System requirements: Android 4.3 or later. Smart Industry App SDK works with Android 6.0 and later.

  • Manifest permissions:

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    
    <!-- Android 12 added -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    
  • Bluetooth permission precheck: It is performed before each Bluetooth scanning and connection. Otherwise, the app cannot use Bluetooth as expected.

    • Before scanning and connection, check if the app is allowed to access location services.
    • Check if the phone’s Bluetooth is turned on.

      Smart Industry App SDK does not provide the logic for precheck. You can implement it on your own.

Initialize IActivator

Parameters

Parameter Type Required Description
mode ActivatorMode Yes The pairing mode.

Example

BLEWIFICloudActivator blewifiCloudActivator = (BLEWIFICloudActivator) ActivatorService.activator(ActivatorMode.BLE_WIFI_ENABLE);

Initialize pairing parameters

Get the parameters from the result of the scanning listener.

Parameters

Parameter Type Required Description
devId String Yes The ID of the device.
pwd String Yes The password of the Wi-Fi network.
ssid String Yes The SSID of the Wi-Fi network.
timeout Long No The timeout for device activation in the cloud, in milliseconds. Default value: 100.
BLEWIFICloudActivatorParams params = new BLEWIFICloudActivatorParams.Builder()
                            .setSsid(ssid)
                            .setPwd(password)
                            .setDevId(deviceId)
                            .setTimeout(60 * 1000)
                            .build();
blewifiCloudActivator.setParams(params);

Register IActivatorListener to listen for pairing result

Example

blewifiCloudActivator.setListener(new IActivatorListener() {
            @Override
            public void onSuccess(@Nullable IDevice iDevice) {
                Log.d(TAG, "onSuccess: ");

            }

            @Override
            public void onError(@NonNull String s, @NonNull String s1) {
                Log.d(TAG, "onError: ");

            }
        });

Start activation in the cloud

This method starts the device pairing.

Example

blewifiCloudActivator.start();