20. Network Module Upgrade Function

Network module information, network module upgrade operations, etc.

20.1. Whether Network Module Function is Supported

//Step0. WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
WatchManager watchManager = WatchManager.getInstance();
//Step1. Get cached watch configuration information
WatchConfigure configure = watchManager.getWatchConfigure(watchManager.getConnectedDevice());
if (null == configure) {
    //You can try requesting from the device once
    watchManager.requestDeviceConfigure(new OnWatchOpCallback<WatchConfigure>() {
        @Override
        public void onSuccess(WatchConfigure result) {
            //Successfully obtained watch configuration information
        }

        @Override
        public void onFailed(BaseError error) {
            //Failed to obtain watch configuration information
            //error -- Error information
        }
    });
    return;
}
configure.getFunctionOption().isSupportNetworkModule(); //Whether network module is supported

20.2. Query Network Module Basic Information

//Step0. WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
WatchManager watchManager = WatchManager.getInstance();
//Step1. Initialize network module upgrade operation object
NetworkOpImpl networkOp = NetworkOpImpl.instance(watchManager);
//Step2. Register network event listener
final OnNetworkListener listener = new OnNetworkListener() {
    @Override
    public void onNetworkInfo(BluetoothDevice device, NetworkInfo info) {
        //Callback network module basic information
//        info.getVid();         //4G module manufacturer ID
//        info.isMandatoryOTA(); //Whether mandatory upgrade is needed, triggered after upgrade failure
//        info.getVersion();     //4G module version number
    }

    @Override
    public void onNetworkOTAState(BluetoothDevice device, NetworkOTAState state) {
        //Callback network module upgrade status
    }
};
networkOp.addOnNetworkListener(listener);
//Step3. Execute query network information interface, and wait for result callback
networkOp.queryNetworkInfo(watchManager.getConnectedDevice(), new OnOperationCallback<Boolean>() {
    @Override
    public void onSuccess(Boolean result) {
        //Callback operation success result
    }

    @Override
    public void onFailed(BaseError error) {
        //Callback operation failure
        //error -- Error description
    }
});
//StepN. Remove listener when no longer needed
//    networkOp.removeOnNetworkListener(listener);

20.2.1. Get Cached Network Module Information

//WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
WatchManager watchManager = WatchManager.getInstance();
final DeviceInfo deviceInfo = watchManager.getDeviceInfo();
if (null == deviceInfo) return; //Device not initialized completely
//Get network module information
final NetworkInfo networkInfo = deviceInfo.getNetworkInfo();
if(null == networkInfo){//Device does not support network module function
    //May not have updated yet, can also query according to above interface
    return;
}

20.3. Start Network Module OTA

//Step0. WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
WatchManager watchManager = WatchManager.getInstance();
//Step1. Initialize network module upgrade operation object
NetworkOpImpl networkOp = NetworkOpImpl.instance(watchManager);
if (networkOp.isNetworkOTA()) {
    //OTA in progress
    return;
}
//Execute start network OTA
//filePath --- 4G module upgrade file path
networkOp.startNetworkOTA(watchManager.getConnectedDevice(), new OTAParam(filePath), new OnNetworkOTACallback() {
    @Override
    public void onStart() {
        //Callback OTA start
    }

    @Override
    public void onProgress(int progress) {
        //Callback OTA progress
    }

    @Override
    public void onCancel() {
        //Callback OTA cancelled
    }

    @Override
    public void onStop() {
        //Callback OTA success
    }

    @Override
    public void onError(int code, String message) {
        //Callback OTA exception
        //code --- Error code
        //message --- Error description
    }
});

Important

  1. Must support 4G module to perform function operations

  2. Cannot execute other command operations during upgrade

20.4. Network Module OTA Exception Callback

//Step1. WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
 WatchManager watchManager = WatchManager.getInstance();
 //Step2. Register watch event listener
 final OnWatchCallback watchCallback = new OnWatchCallback() {
     @Override
     public void onNetworkModuleException(BluetoothDevice device, NetworkInfo info) {
         //Callback upgrade module upgrade exception, need mandatory upgrade
         //info --- Network module basic information
     }
 };
 watchManager.registerOnWatchCallback(watchCallback);

 //StepN. Unregister listener when no longer needed
 //        watchManager.unregisterOnWatchCallback(watchCallback);

20.5. Network Module OTA Interface Flow Chart

Network Module OTA Interface Flow Chart

20.6. Network Module Upgrade Package Differential Upgrade Strategy

Network Module Differential Upgrade Strategy

sdk_map.json

  {
      "cursdk": {
        "version": "gx318l_h6_v0022_p7",
        "vendor": "归芯科技",
        "chip": "BR28"
    },
    "map": [
        {
            "version": "gx318l_h6_v0022_p5",
            "pakage": "gx318l_h6_v0022_p5_to_gx318l_h6_v0022_p7.diff"
        },
  {
            "version": "gx318l_h6_v0022_p6",
            "pakage": "gx318l_h6_v0022_p6_to_gx318l_h6_v0022_p7.diff"
        }
    ]
}

Field Description

Parameter

Meaning

cursdk

Contains current package information, such as: version number, vendor information, etc.

map

Mapping rules, provided in array format inside