You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public interface IHttpCallBack {
public void onSuccess(String result);
public void onFail(Throwable e);
}
public interface IResponseCallBack {
public void onSuccess();
public void onFail(Throwable e);
public void onError(String errorMsg);
}
//Change user address information
public void updateUserAddress(String address ,IHttpCallBack callback);
//Change user avatar
public void updateUserHeadImage(String headImage ,IHttpCallBack callback);
//Change language
public void updateUserLanguage(int language ,IHttpCallBack callback);
//Change nickname
public void updateUserNickName(String nikeName ,IHttpCallBack callback);
//Change gender
public void updateUserSex(int sex ,IHttpCallBack callback);
//Change timezone
public void updateUserTimezone(int timezone ,IHttpCallBack callback);
//Change nationality
public void updateUserNationality(int nationality ,IHttpCallBack callback);
Logout
public void userLogout(IHttpCallBack callback);
Change User Password
public void changeUserPassword(String newPwd,String oldPwd,IHttpCallBack callback);
Parameter
Required
Description
newPwd
Yes
New password
oldPwd
Yes
Old password
Query Language List
public void queryLanguageList(IHttpCallBack callback);
Query Country List
public void queryNationalityList(IHttpCallBack callback);
Query Timezone List
public void queryTimezoneList(IHttpCallBack callback);
Send Email Registration Verification Code
public void sendEmailRegisterCode(String email,IHttpCallBack callback);
Parameter
Required
Description
email
Yes
Email
Email Password Registration
public void emailPwdRegister(String code,String email,String password,int lang,int nationality,int timezone,IHttpCallBack callback);
Parameter
Required
Description
code
Yes
Email verification code
email
Yes
Email
password
Yes
Password
lang
Yes
Language, default is 0
nationality
Yes
Country, default is 0
timezone
Yes
Timezone, default is 0
Email Password Login
public void emailPwdLogin(String email,String password,IResponseCallBack callback);
Parameter
Required
Description
email
Yes
Email
password
Yes
Password
Send Email Password Reset Verification Code
public void sendEmailRepwdCode(String email,IHttpCallBack callback);
Parameter
Required
Description
email
Yes
Email
Validate User Sent Email Verification Code
public void validateEmailCode(String email,String code,int isDisabled, IHttpCallBack callback);
Parameter
Required
Description
email
Yes
Email
code
Yes
Verification code
isDisabled
Yes
Whether the verification code is invalid after verification, 1: Invalid, 2: Not invalid, default is 1 (Note: This interface only validates the email verification code sent when canceling the user)
Get User Token
public String getToken();
Clear Local Token
public void clearToken();
One-click Login with Phone Number
public void phoneOneKeyLogin(OneKeyBean oneKeyBean, IHttpCallBack callback);
Refer to the mobile document http://dev.10086.cn/dev10086/pub/loadAttach?attachId=6EF75FD09D4F40D1973CB7C36C3DB2E2
Parameter
Required
Description
appid
Yes
Application ID applied for in unified authentication
version
Yes
2.0
strictcheck
Yes
Temporarily fill in "0", fill in "1" to perform strict verification on the server IP whitelist (IP strict verification will be mandatory in the future)
token
Yes
Business credential
sign
Yes
Request signature appid+version+msgid+systemtime+strictcheck+oneKeyBean.getToken()+appSecret MD5 byte to hexadecimal
userDomain
Yes
User domain
systemtime
Yes
System time when the request message is sent, accurate to milliseconds, a total of 17 digits, format: 20121227180001165
msgid
Yes
Random number to identify the request (1-36 digits)
User Message List
public void queryUserMessageList(String pk,String dk,int msgType, int page,int pageSize,boolean isRead, String content,String title,IHttpCallBack callback);
Parameter
Required
Description
pk
No
Product key
dk
No
Device key
msgType
No
Message type 1-Device notification 2-Device alarm 3-Device fault 4-System message
page
No
pageSize
No
isRead
Yes
Whether it is read
content
Yes
Query content
title
Yes
Query title
Read Message
public void userReadMessage(String msgIdList,int msgType,IHttpCallBack callback);
Parameter
Required
Description
msgIdList
No
List of message IDs to be read, multiple IDs are separated by commas, if not provided, all messages will be read
msgType
No
Message type
Delete Message
public void userDeleteMessage(String msgId,String language,IHttpCallBack callback);
Parameter
Required
Description
msgId
Yes
Message ID
language
Yes
Not required, pass ""
Query User Message Type
public void queryUserMessageType(IHttpCallBack callback);
{"code":200,"msg":"","data":"1,2,3"}
Set User Message Type
public void setUserMessageType(String recvMsgPushType, IHttpCallBack callback);
Parameter
Required
Description
recvMsgPushType
Yes
1-Device notification 2-Device alarm 3-Device fault 4-System message, the received message types and any combination, multiple types are separated by commas
HTTP Response Code
Value
Description
code
200
Success
code
5032
token_invalid, code returns 5032, please exit the current page, actively jump to the login page, let the user re-acquire the token
code
5106
Please enter the token, the user directly calls the interface without logging in and returns this content
Expiration time of the sharing QR code seed, timestamp (milliseconds)
pk
Yes
product key
dk
Yes
product key
coverMark
No
Cover mark 1 Directly cover the previous valid share (default) (cover the original share code); 2 Directly add, allow multiple coexist; 3 Only when the sharing time is extended, it is allowed to cover the previous share
sharingExpireAt
No
Device usage expiration time, timestamp (milliseconds), indicating the time the shared device can be used by the shared person, if not filled, it is valid for life, only the authorizer actively unbinds
publicvoidqueryProductTSL(Stringpk, IHttpCallBackcallback);
// Please call the SDK's buildModelListContent method to parse the TSL data structureList<ModelBasic> modelBasics = ObjectModelParse.buildModelListContent(jsonArray);
Query Object Model TSL with Network or Local Cache (Deprecated)
publicvoidqueryProductTSLWithCache(Contextcontext, Stringpk, IHttpCallBackcallback);
// Please call the SDK's buildModelListContent method to parse the TSL data structureList<ModelBasic> modelBasics = ObjectModelParse.buildModelListContent(jsonArray);
Parameter
Required
Description
context
Yes
Context
pk
Yes
productKey
Query Object Model TSL with Network or Local Cache
Gateway device pk, if not provided, pass an empty string ""
gatewayDk
No
Gateway device dk, if not provided, pass an empty string ""
codeList
No
Attributes to query; used with query types, if null, query all attributes, and typeList is also null
typeList
No
Query types 1 Query device basic attributes 2 Query object model attributes 3 Query location information
Query Device Upgrade Plan
public void queryFetchPlan(String productKey,String deviceKey,IHttpCallBack callback);
Parameter
Required
Description
productKey
Yes
Device pk
deviceKey
Yes
Device dk
Report Component Upgrade Status
public void reportUpgradeStatus(String productKey,String deviceKey,String componentNo,int reportStatus,IHttpCallBack callback);
Parameter
Required
Description
productKey
Yes
pk
deviceKey
Yes
dk
componentNo
Yes
Component number returned by the query plan
reportStatus
Yes
Upgrade status 0-12
Add Device Group
public void addDeviceGroup(String name,IHttpCallBack callback);
Parameter
Required
Description
name
Yes
Device group name
Query Device Group Details
public void queryDeviceGroup(String dgid,IHttpCallBack callback);
Parameter
Required
Description
dgid
Yes
Device group dgid
Modify Device Group
public void updateDeviceGroup(String name,String dgid,IHttpCallBack callback);
Parameter
Required
Description
name
Yes
Device group name
dgid
Yes
Device group dgid
Add Device to Device Group
public void addDeviceToGroup(String dgid,List<AddDeviceParam> list, IHttpCallBack callback);
Parameter
Required
Description
dgid
Yes
Device group dgid
list
Yes
List of devices to add
Query Device List in Device Group
public void getGroupDeviceList(String dgid,String pk, int page,int pageSize,IHttpCallBack callback);
Parameter
Required
Description
dgid
Yes
Device group dgid
pk
Yes
pk
page
Yes
Page number
pageSize
Yes
Number of items per page
Remove Device from Device Group
public void deleteDeviceToGroup(String dgid,List<AddDeviceParam> list,IHttpCallBack callback);
Parameter
Required
Description
dgid
Yes
Device group ID
list
Yes
List of devices to remove
Query Device Group List
public void queryDeviceGroupList(int page,int pageSize,IHttpCallBack callback);
Parameter
Required
Description
page
Yes
Page number
pageSize
Yes
Number of items per page
Delete Device Group
public void deleteDeviceGroup(String dgid,IHttpCallBack callback);
Parameter
Required
Description
dgid
Yes
Device group ID
Query Device Group List by Device
public void queryGroupListByDevice(String pk,String dk,IHttpCallBack callback);
Parameter
Required
Description
pk
Yes
pk
dk
Yes
dk
Query Device List Not in Device Group
public void getDeviceListByNotInDeviceGroup(int page, int pageSize, String dgid, IHttpCallBack callback);
Parameter
Required
Description
dgid
Yes
Device group ID
page
Yes
Current page, default is page 1
pageSize
Yes
Page size, default is 10 items
Query Child Device List under Gateway Device
public void getGatewayChildList(String pk, String dk, int page, int pageSize, IHttpCallBack callback);
Parameter
Required
Description
pk
Yes
product key
dk
Yes
device key
page
Yes
Current page, default is page 1
pageSize
Yes
Page size, default is 10 items
Get Device Attribute Data List
public void getPropertyDataList(DeviceCodeList deviceCodeList, IHttpCallBack callback);
Parameter
Required
Description
attributeCode
Yes
Object model attribute identifier
pk
Yes
product key
dk
Yes
device key
startTimestamp
Yes
Start time (millisecond timestamp)
endTimestamp
Yes
End time (millisecond timestamp)
gatewayDk
No
Gateway device Device Key
gatewayPk
No
Gateway device Product Key
page
No
Current page, default is page 1
pageSize
No
Page size, default is 10 items
Get Device Attribute Chart List
public void getPropertyChartList(DeviceChartListBean deviceChartListBean, IHttpCallBack callback);
Parameter
Required
Description
attributeCode
Yes
Object model attribute identifier, when querying multiple attributes, use commas to separate, up to 10 attributes
pk
Yes
product key
dk
Yes
device key
startTimestamp
Yes
Start time (millisecond timestamp)
endTimestamp
Yes
End time (millisecond timestamp)
gatewayDk
No
Gateway device Device Key
gatewayPk
No
Gateway device Product Key
countType
No
Aggregation type (default is 3): 1-Maximum value 2-Minimum value 3-Average value 4-Difference 5-Total value
timeGranularity
No
Statistical time granularity (default is 2): 1-Month 2-Day 3-Hour 4-Minute 5-Second
timezone
No
Time zone offset, format: ±hh:mm
Get Device Historical Track
public void getLocationHistory(TrackBean trackBean, IHttpCallBack callback);
Parameter
Required
Description
pk
Yes
product key
dk
Yes
device key
startTimestamp
Yes
Start time (millisecond timestamp)
endTimestamp
Yes
End time (millisecond timestamp)
gatewayDk
No
Gateway device Device Key
gatewayPk
No
Gateway device Product Key
locateTypes
No
Location types (default is to query all types of locations): GP/GL/GA/GN/BD/PQ/LBS, when querying multiple locations, use commas to separate
Get Device Attribute Comparison Data
public void getPropertyCompare(DeviceCompareBean deviceCompareBean, IHttpCallBack callback);
Parameter
Required
Description
attributeCode
Yes
Object model attribute identifier
pk
Yes
product key
dk
Yes
device key
startTimestamp
Yes
Start time (millisecond timestamp)
endTimestamp
Yes
End time (millisecond timestamp)
gatewayDk
No
Gateway device Device Key
gatewayPk
No
Gateway device Product Key
countType
No
Aggregation type (default is 3): 1-Maximum value 2-Minimum value 3-Average value 4-Difference 5-Total value
timeGranularity
No
Statistical time granularity, when querying multiple granularities, use commas to separate (default is 1): 1-Day 2-Week 3-Month 4-Year
Set Device Group Sharing Information by Sharer
public void shareGroupInfo(long acceptingExpireAt,String dgid, int coverMark,long sharingExpireAt,IHttpCallBack callback);
Parameter
Required
Description
dgid
Yes
Device group id
acceptingExpireAt
Yes
Expiration time of the sharing QR code seed, timestamp (milliseconds)
coverMark
No
Cover mark 1 Directly cover the previous valid share (default) (cover the original share code); 2 Directly add, allow multiple coexist; 3 Only when the sharing time is extended, it is allowed to cover the previous share
sharingExpireAt
No
Device usage expiration time, timestamp (milliseconds), indicating the time the shared device can be used by the shared person, if not filled, it is valid for life, only the authorizer actively unbinds
Accept Device Group Sharing by Shared Person
public void acceptDeviceGroupShare(String shareCode ,IHttpCallBack callback);
Parameter
Required
Description
shareCode
Yes
Share code
Query Accepted Device Group Details by Shared Person
public void queryAcceptSharedDeviceGroup(String shareCode ,IHttpCallBack callback);
Parameter
Required
Description
shareCode
Yes
Share code
Query Shared Person List of Device Group by Sharer
public void deviceGroupShareUserList(String dgid ,IHttpCallBack callback);
Parameter
Required
Description
dgid
Yes
Device group id
Modify Shared Device Group Name by Shared Person
public void shareUserSetDeviceGroupName(String deviceGroupName,String shareCode,IHttpCallBack callback);
Parameter
Required
Description
deviceGroupName
Yes
Device group name
shareCode
Yes
Share code
Modify Shared Device Name in Device Group by Shared Person
public void shareUserSetDeviceName(String deviceName, String pk,String dk, String shareCode,IHttpCallBack callback);
Parameter
Required
Description
deviceName
Yes
Device name
pk
Yes
pk
dk
Yes
dk
shareCode
Yes
Share code
Cancel Device Group Sharing by Shared Person
public void shareUserUnshare(String shareCode,IHttpCallBack callback);
Parameter
Required
Description
shareCode
Yes
Share code
Cancel Device Group Sharing by Sharer
public void owerUserUnshare(String shareCode,IHttpCallBack callback);
Parameter
Required
Description
shareCode
Yes
Share code
Batch Control Devices
public void batchControlDevice(String data, List<BatchControlDevice> deviceList, int cacheTime,int isCache,int isCover,int dataFormat, int type, IHttpCallBack callback);
Parameter
Required
Description
type
Yes
1: Transparent transmission 2: Attribute 3: Service
data
Yes
Attribute bool int float double enum date text" [{"key":"value"}]" Attribute array "[{"key":[{"id":"value1"},{"id":"value2"}]}]" (id is 0) Attribute struct "[{"key":[{"key1":"value1"},{"key2":"value2"}]}]" Attribute array containing struct "[{"key":[{"id":[{"key1":"value1"}]},{"id":[{"key2":"value2"}]}]}]" (id is 0)
dataFormat
Yes
Data type 1: Hex 2: Text (when type is transparent transmission, dataFormat needs to be specified) Default is 2
isCache
Yes
Whether to enable cache 1: Enable 2: Do not enable, default is not enabled, HTTP downlink needs to be enabled, default is 1
isCover
Yes
Whether to cover the same command sent before 1: Cover 2: Do not cover, default is not covered, this parameter is valid when cache is enabled, default is 2
cacheTime
Yes
Cache time, in seconds, cache time range is 1-7776000 seconds, cache time must be set when cache is enabled
When type is custom-repeat, multi-section, random, required, any combination of Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday, format is "1,3,4", separated by ","
timers
CloudTimingTimer
Timer list
CloudTimingTimer class
Member
Type
Description
action
String
JSON format, specify object model (attribute/service) + specify status
time
String
When type is once, day-repeat, custom-repeat, multi-section, required, format is "HH:mm:ss", such as "12:00:00"
startTime
String
Start time, when type is random, required, format is "HH:mm:ss", such as "12:00:00"
endTime
String
End time, when type is random, required, and endTime must be after startTime, format is "HH:mm:ss", such as "13:00:00"
1-Upgrade immediately (confirm upgrade at any time) 2-Scheduled upgrade (schedule upgrade at a specified time window) 3-(Cancel schedule and cancel upgrade)
appointEndTime
long
Scheduled upgrade end time (millisecond timestamp), required when operation type is 2
appointStartTime
long
Scheduled upgrade start time (millisecond timestamp), required when operation type is 2
IIotChannelControl Device Control
This class mainly includes device control related, such as device data downlink, listening to device uplink data, the underlying will automatically select the appropriate link for connection and data transmission based on the device's capability value and the current APP and device environment.
Get IIotChannelControl Object
IotChannelController.getInstance()
Set Channel Online Status and Uplink/Downlink Data Listener
You need to use MmkvManager.getInstance().put("uid",”****”) in advance, it is recommended to call the following method when the user logs in successfully;
You need to use MmkvManager.getInstance().put("uid",”****”) in advance, it is recommended to call the following method when the user logs in successfully;
Type 1: Transparent transmission 2: Attribute 3: Service
extraDataBean
No
{ dataFormat Data type 1: Hex 2: Text (when type is transparent transmission, dataFormat needs to be specified) cacheTime Cache time, in seconds, cache time range is 1-7776000 seconds, cache time must be set when cache is enabled isCache Whether to enable cache 1: Enable 2: Do not enable, default is not enabled isCover Whether to cover the same command sent before 1: Cover 2: Do not cover, default is not covered, this parameter is valid when cache is enabled
public void subscribeDevice(String deviceKey,String productKey);
Unsubscribe Device
public void unsubscribeDevice(String deviceKey,String productKey);
Check if WebSocket is Open
public boolean isWebSocketOpenCallback();
Check if WebSocket Login is Successful
public boolean isWebSocketLoginCallback();
Send Basic Type Data bool/int/float/double/enum/date/text
public void writeWebSocketBaseData(KValue value, String deviceKey, String productKey);
KValue data = new KValue(3,"buer", ModelStyleConstant.BOOL,"true");
WebSocketServiceLocater.getService(IWebSocketService.class).writeWebSocketBaseData(data,dk,pk);
Send Array or Struct Type Data
public void writeWebSocketArrayOrStructBaseData(int id, String name, List<KValue> mListChild,String dataType, String deviceKey, String productKey);
/**
* Parameter id is the object model attribute id
* name is the object model name
* Send array type content as basic types INT FLOAT DOUBLE TEXT
* mListChild content is KValue of the following types id=0 name="" The third parameter is the type, the fourth parameter is the value of the array:
* Boolean value can pass "false" "true"
* KValue v1 = new KValue(0,"",ModelStyleConstant.INT,8);
* KValue v2 = new KValue(0,"",ModelStyleConstant.INT,10);
* mListChild.add(v1);
* mListChild.add(v2);
* dataType Array ModelStyleConstant.ARRAY Struct ModelStyleConstant.STRUCT
*
* Send type as Struct
* The first parameter is the attribute model id in the Struct The third parameter is the type The fourth parameter is the attribute value
* KValue v1 = new KValue(1,"Refresh",ModelStyleConstant.BOOL,"true");
* KValue v2 = new KValue(2,"Time duration",ModelStyleConstant.INT,55);
* mListChild.add(v1);
* mListChild.add(v2);
*/
Send Array Type Content as Struct
public void writeWebSocketArrayContainStructData(int id, String name, List<KValue> mListChild, String deviceKey, String productKey);
/**
*
* mListChild content is KValue of the following values
* KValue v1 = new KValue(0,"",ModelStyleConstant.STRUCT,ChildList1);
* KValue v2 = new KValue(0,"",ModelStyleConstant.STRUCT,ChildList2);
* mListChild.add(v1);
* Parameter ChildList1 value is the attribute value encapsulation in each struct
* KValue v11 = new KValue(1,"Test1",ModelStyleConstant.BOOL,"true");
* KValue v12 = new KValue(2,"Test2",ModelStyleConstant.ENUM,1);
* List<KValue> ChildList1 = new ArrayList<KValue>();
* ChildList1.add(v11);
* ChildList1.add(v12);
*/
MQTT Channel SDK
I. Function List
Feature
Description
Implemented Version
Microservice Version
MQTT Communication Related
Scan peripherals, connect peripherals, send data to peripherals, receive data uploaded by peripherals
true is auto reconnect, false is not auto reconnect
Connect MQTT
You need to use MmkvManager.getInstance().put("uid",”****”) in advance, it is recommended to call the following method when the user logs in successfully;
Message type READ-ATTR Object model attribute-read; WRITE-ATTR Object model attribute-write; EXE-SERV Call object model service; EXE-SERV2 Call object model service (data protocol > 1.8); RAW Transparent command
kv
String
Object model downlink data
msgId
long
Message ID to identify the sent command, not required, maximum length 20. Used to correspond when sending a response
isCache
boolean
Whether to cache the downlink command
cacheTime
long
Downlink command cache time, in seconds
isCover
boolean
Whether to cover the downlink command, default is false
Scan peripherals, connect peripherals, send data to peripherals, receive data uploaded by peripherals
1.0.0
II. Design Interface/Properties
IBleService Bluetooth Service
Get Service Object
BleServiceLocater.getService(IBleService.class)
Scan Devices, can pass name or MAC address filter, pass "" for no filter
public void startScan(String name, String mac, IScanCallBack iScanCallBack)
Stop Scan
public void stopScan();
Connect Device by MAC Address
public void connectDevice(String mac,IBleCallBack callBack);
BleServiceLocater.getService(IBleService.class).connectDevice(macAddress, new IBleCallBack() {
@Override
public void onSuccess() {
SystemClock.sleep(300);
//Connection successful, set notify to listen for data
BleServiceLocater.getService(IBleService.class).setNotify(NOTIFY_CHARACTERISTIC_UUID, new IFeedbackCallBack() {
@Override
public void receiveData(byte[] data) {
String notifyContent = StringUtils.bytesToHex(data,true);
System.out.println("receiveData--:"+notifyContent);
}
@Override
public void onFail(Throwable e) {
e.printStackTrace();
}
});
}
@Override
public void onFail(Throwable e) {
e.printStackTrace();
}
});
Disconnect
public void disConnect();
Release Resources, call in Activity onStop method
public void release();
Discover Device Services after Connection
public void findServiceCharacter(IFindServiceCallBack findServiceCallBack);
public interface IFindServiceCallBack {
public void onScan(String UUID,FindCharacter findCharacter);
public void onFail(Throwable throwable);
}
setNotify or setIndicate
public void setNotify(String notify_UUID, IFeedbackCallBack iFeedbackCallBack);
public void setIndicate(String indicate_UUID, IFeedbackCallBack iFeedbackCallBack);
public interface IFeedbackCallBack {
public void receiveData(byte[] data);
public void onFail(Throwable throwable);
}
Read Attribute
public void read(String read_UUID, IFeedbackCallBack iFeedbackCallBack);
BleServiceLocater.getService(IBleService.class).read(READ_UUID, new IFeedbackCallBack() {
@Override
public void receiveData(byte[] data) {
String str = new String(data, StandardCharsets.UTF_8);
System.out.println("read-str--:"+str);
}
@Override
public void onFail(Throwable throwable) {
}
});
Write Data to Device
public void write(String write_UUID, byte[] data, IFeedbackCallBack iFeedbackCallBack);
BleServiceLocater.getService(IBleService.class).write(WRITE_UUID, byte[] data, new IFeedbackCallBack() {
@Override
public void receiveData(byte[] data) {
System.out.println("write--success");
}
@Override
public void onFail(Throwable throwable) {
}
});
Check if Device is Connected, returns true if connected
public boolean isConnected(String mac);
Set Device Connection Status Callback
public void setiConnectChange(IConnectChange iConnectChange);
Check if UUID Supports Notify
public void isNotifiable(String uuid,INotifyCallBack iNotifyCallBack);
Check if UUID Supports Indicate
public void isIndicatable(String uuid,IndicateCallBack indicateCallBack);
TTLV Format Data Encoding and Decoding
ttlv data
publicclassTTLVData<T> {
/** * Data type * type Boolean 0 false 1 true 2 Numeric 3 Binary 4 Struct *///id Data identifierpublicshortid;
publicshorttype;
publicTdata;
//Whether it is ttlvpublicbooleanttlv;
ttlv Encoding
public EncodeResult startEncode(short cmd,List<TTLVData> payloads)
TTLVData<Boolean> test1 = new TTLVData<Boolean>((short)1, (short)0, false, true) ;
TTLVData<Boolean> test2 = new TTLVData<Boolean>((short)2, (short)1, true, true) ;
…………
List<TTLVData> payLoads = new ArrayList<TTLVData>();
payLoads.add(test1);
payLoads.add(test2);
//ttlv format data encoding and decoding
EncodeResult encodeResult = EncodeTools.getInstance().startEncode((short) 0x0018, payLoads);
Decode ttlv Package
DecodeTools.getInstance().packetSlice(encodeResult.getCmdData(), new IParseDataListener() {
@Override
public void onSuccess(ParseResultData resultData) {
Map<Integer, ReceiveTTLVData> paramMap = resultData.getValueMap();
Set<Map.Entry<Integer, ReceiveTTLVData>> me = paramMap.entrySet();
for (Iterator<Map.Entry<Integer, ReceiveTTLVData>> it = me.iterator(); it.hasNext();)
{
Map.Entry<Integer,ReceiveTTLVData> mapValue = it.next();
int key = mapValue.getKey();
ReceiveTTLVData useValue = mapValue.getValue();
String dataType = useValue.getData().getClass().getSimpleName();
switch (dataType)
{
case DataStyle.BYTE:
byte[] data1 = (byte[]) useValue.getData();
String str = new String(data1, StandardCharsets.UTF_8);
System.out.println("byte str --:" + str);
break;
case DataStyle.LONG:
long data2 = (Long) useValue.getData();
break;
case DataStyle.DOUBLE:
double data3 = (double) useValue.getData();
break;
case DataStyle.BOOLEAN:
boolean data4 = (boolean) useValue.getData();
break;
case DataStyle.Array:
List<ReceiveTTLVData> data5 = (List<ReceiveTTLVData>) useValue.getData();
for(ReceiveTTLVData rt: data5)
{
String style = rt.getData().getClass().getSimpleName();
if(style.equals(DataStyle.BYTE))
{
byte[] data = (byte[]) rt.getData();
String content = new String(data, StandardCharsets.UTF_8);
System.out.println("byte--:" + content);
}
System.out.println("ReceiveTTLVData-:"+rt);
}
break;
}
}
}
@Override
public void onProcessing(String msg) {
System.out.println("onProcessing--:"+msg);
}
});
WiFi Configuration (Deprecated, use IQuecDevicePairingService)
1. Scan and connect to the Bluetooth device;
2. Encode WiFi name ssid and password pass in ttlv format, write data via BLE
3. Decode the returned pk, dk, authCode from the device;
4. Call the HTTP interface bindDeviceByWifi to bind the device;
example:
byte[] bytes = ssid.getBytes(StandardCharsets.UTF_8);
byte[] bytes2 = pass.getBytes(StandardCharsets.UTF_8);
TTLVData<byte[]> test1 = new TTLVData<byte[]>((short) 1, (short)3, bytes, true) {
};
TTLVData<byte[]> test2 = new TTLVData<byte[]>((short) 2, (short)3, bytes2, true) {
};
List<TTLVData> list = new ArrayList<TTLVData>();
list.add(test1);
list.add(test2);
//ttlv data encoding
EncodeResult encodeResult = EncodeTools.getInstance().startEncode((short) 0x7010, list);
//WiFi configuration, write data
BleServiceLocater.getService(IBleService.class).write(writeUUID, encodeResult.getCmdData(), new IFeedbackCallBack()
…………
Bluetooth notify, decode data…… Call interface for configuration
DeviceServiceFactory.getInstance().getService(IDevService.class).bindDeviceByWifi(String deviceName, String pk,String dk, String authCode,IHttpCallBack callback);
Configuration SDK quec-smart-config-sdk-api
I. Function List
Feature
Description
Implemented Version
Microservice Version
Device Configuration
Device configuration
1.0.0
Register Configuration Listener
1.0.0
Unregister Configuration Listener
1.0.0
II. IQuecSmartConfigService Design Interface/Properties (Deprecated, use IQuecDevicePairingService)
WiFi device is configured, 1 means configured, 0 means not configured
isBind
Boolean
Is bound
isEnableBind
String
Is binding allowed
capabilitiesBitmask
Int
Device capability value bit0=1 means the device supports WAN far-field communication capability bit1=1 means the device supports WiFi LAN near-field communication capability bit2=1 means the device supports BLE near-field communication capability
QuecPairErrorCodes Description
Type
Value
Description
QUEC_PAIRING_WAITING
301
Device waiting to be bound
QUEC_PAIRING_BLE_CONNECTING
302
Bluetooth connecting
QUEC_PAIRING_BLE_CONNECTED_FAIL
303
Bluetooth connection failed
QUEC_PAIRING_WIFI_GET_BINDING_CODE_FAIL
304
WiFi configuration device, timeout without getting binding code
QUEC_PAIRING_WIFI_BINDING_SUCCESS
305
WiFi configuration successful
QUEC_PAIRING_WIFI_BINDING_FAIL
306
WiFi configuration failed
QUEC_PAIRING_BLE_GET_RANDOM_FAIL
307
Failed to get random from Bluetooth device
QUEC_PAIRING_BLE_GET_ENCRYPTION_CODE_FAIL
308
Failed to request encrypted binding code from the cloud
QUEC_PAIRING_BLE_CODE_AUTH_FAIL
309
Failed to authenticate with Bluetooth device
QUEC_PAIRING_BLE_CODE_AUTH_SUCCESS
310
Authentication with device successful
QUEC_PAIRING_BLE_BINDING_SUCCESS
311
Bluetooth binding successful
QUEC_PAIRING_BLE_BINDING_FAIL
312
Bluetooth binding failed
QUEC_PAIRING_FAIL
313
General exception scenario: binding failed, such as parameter issues
1-Upgrade immediately (confirm upgrade at any time) 2-Scheduled upgrade (schedule upgrade at a specified time window) 3-(Cancel schedule and cancel upgrade)
appointStartTime
long
Scheduled upgrade start time (millisecond timestamp), required when operation type is 2
appointEndTime
long
Scheduled upgrade end time (millisecond timestamp), required when operation type is 2