Last Updated on : 2024-05-15 08:40:57download
This topic describes the mode of pairing a narrowband Internet of Things (NB-IoT) device based on the low-power wide-area network (LPWAN) radio technology. NB-IoT connects IoT devices more simply and efficiently on already established mobile networks. Users can scan the QR code of an NB-IoT device and start pairing.
//IThingDeviceActivator.java
void deviceQrCodeParse(String url, IThingDataCallback<QrScanBean> callback);
Parameters
Parameter | Description |
---|---|
url | The URL obtained after the device QR code is scanned. |
IThingDataCallback | The UUID returned in the result.actionData . |
Example
// The URL obtained after the device QR code is scanned.
ThingHomeSdk.getActivatorInstance().deviceQrCodeParse("url", new IThingDataCallback<QrScanBean>() {
@Override
public void onSuccess(QrScanBean result) {
if(result != null){
// Get UUID from result.actionData. This parameter will be used as the request parameter in the subsequent pairing process.
}
}
@Override
public void onError(String errorCode, String errorMessage) {
// errorCode:QR_PROTOCOL_NOT_RECOGNIZED The protocol is unknown.
}
});
void bindNbDeviceWithQRCode(long homeId,String uuid, String timeZone, IThingDevActivatorListener listener);
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
uuid | The UUID returned in the result.actionData . |
timezone | The time zone. |
IThingDevActivatorListener | The pairing callback. |
Example
// The URL obtained after the device QR code is scanned.
ThingHomeSdk.getActivatorInstance().bindNbDeviceWithQRCode(123xx,"uuidxxxx","timezonexx" new IThingDevActivatorListener<DeviceBean>() {
@Override
public void onSuccess(DeviceBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
public String getTimeZone() {
TimeZone tz = TimeZone.getDefault();
String displayName = "+08:00";
if (tz != null) {
String str = tz.getDisplayName();
if (str != null && !str.isEmpty()) {
int indexOf = str.indexOf("+");
if (indexOf == -1) {
indexOf = str.indexOf("-");
}
if (indexOf != -1) {
displayName = str.substring(indexOf);
}
if (!displayName.contains(":")) {
displayName = displayName.substring(0, 3) + ":" + displayName.substring(3);
}
}
}
return displayName;
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback