18. Big Data Transfer Functionality
A big data transfer feature designed to facilitate large data interactions without file operations. It includes sub-functions such as receiving big data from the device, sending big data, and reading big data.
18.1. Receiving Big Data from Device
//Step0. WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
WatchManager mWatchManager = WatchManager.getInstance();
final OnWatchCallback onWatchCallback = new OnWatchCallback() {
/**
* Callback for received big data
* @param device Device object
* @param type Data type
* @param data Big data
*/
@Override
public void onReceiveBigData(BluetoothDevice device, int type, byte[] data) {
super.onReceiveBigData(device, type, data);
}
/**
* Exception occurred during receiving big data
*
* @param device Device object
* @param error Error event
*/
@Override
public void onBigDataError(BluetoothDevice device, BaseError error) {
super.onBigDataError(device, error);
}
};
//Step1. Register event listener
mWatchManager.registerOnWatchCallback(onWatchCallback);
//StepN. When no longer needing to monitor big data, remember to remove the listener
mWatchManager.unregisterOnWatchCallback(onWatchCallback);
Note
Data types, Big Data Type Reference Table
18.2. Sending Big Data
//Step0. WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
WatchManager mWatchManager = WatchManager.getInstance();
//Step1. Build send parameters
int type = RcspConstant.TYPE_RAW_DATA; //Raw data
int version = 0; //Data protocol
int sendLimit = 4 * 1024; //Maximum value for each data transmission
int recvLimit = 4 * 1024; //Maximum value for each data reception
byte[] data = new byte[1024]; //Big data to send
SendParams param = new SendParams(type, version, sendLimit, recvLimit, data);
//Step2. Call send big data interface and wait for callback.
//Note: The big data interface cannot be called multiple times, need to wait for callback to finish before continuing to call
mWatchManager.sendLargeData(param, new OnDataEventCallback() {
/**
* Callback for operation start
* @param way Transmission method
* <p>{@link RcspConstant#WAY_SEND_DATA} -- Send data
* {@link RcspConstant#WAY_READ_DATA} -- Read data</p>
*/
@Override
public void onBegin(int way) {
}
/**
* Callback for progress
* @param progress Progress
*/
@Override
public void onProgress(float progress) {
}
/**
* Callback for operation end
* @param type Data type
* @param data Data
*/
@Override
public void onStop(int type, byte[] data) {
}
/**
* Callback for exception
* @param error Error information
*/
@Override
public void onError(BaseError error) {
}
});
Note
Data types, Big Data Type Reference Table
18.3. Big Data Type Reference Table
Referenced Class Name: DataTransferCmd
Value |
Constant Reference |
Description |
|---|---|---|
0 |
TYPE_RAW_DATA |
Raw data/transparent data |
1 |
TYPE_ALI_DATA |
Alibaba Cloud data |
2 |
TYPE_RTC_DATA |
Alarm clock data |
3 |
TYPE_AI_CLOUD_DATA |
AI cloud data |
4 |
TYPE_TTS_DATA |
Text-to-speech data |
5 |
TYPE_PLATFORM_INTERFACE_DATA |
Third-party platform authentication data |
6 |
TYPE_ESIM_CARD |
ESim card data |
7 |
TYPE_NETWORK_OTA |
Network module upgrade data |
8 |
TYPE_TONE_FILE_DATA |
Tone file data |