【已处理】有线联网,在已接入互联网的情况下,如何使用二维码扫码绑定

网关设备, 语音中控设备等
Post Reply
土豆马铃薯
Posts: 72

请问下 设备支持有线联网,在已接入互联网的情况下,如何使用二维码扫码绑定?该二维码是每台设备出厂时固定的,还是每次要去云端访问某个接口之后获得的?相关文档哪里找?谢谢
pid:z6mgualndoispkjf

always on the road
Posts: 20

Re: 【求助】有线联网,在已接入互联网的情况下,如何使用二维码扫码绑定

从安全的角度出发,二维码肯定是会定期更新的,基本原理其实挺简单的。另外,你直接用tuya app sdk提供的接口就能实现扫码绑定的能力

土豆马铃薯
Posts: 72

Re: 【求助】有线联网,在已接入互联网的情况下,如何使用二维码扫码绑定

always on the road 2022年 Oct 27日 16:30

从安全的角度出发,二维码肯定是会定期更新的,基本原理其实挺简单的。另外,你直接用tuya app sdk提供的接口就能实现扫码绑定的能力

好的,谢谢 想问下具体是哪个接口

always on the road
Posts: 20

Re: 【求助】有线联网,在已接入互联网的情况下,如何使用二维码扫码绑定

土豆马铃薯 2022年 Oct 27日 16:39
always on the road 2022年 Oct 27日 16:30

从安全的角度出发,二维码肯定是会定期更新的,基本原理其实挺简单的。另外,你直接用tuya app sdk提供的接口就能实现扫码绑定的能力

好的,谢谢 想问下具体是哪个接口

android详见以下链接:
https://developer.tuya.com/cn/docs/app- ... xkxky0f221

ios如下:

Device Pairing in QR Code Mode - iOS

Pairing process

This method only applies to devices that are connected to the internet.

Code: Select all

Title: Scan Device QR Code for Pairing

participant Device
participant httpdns
participant mqtt
participant APP
participant cloud

Note over Device: Power on device and connect it to internet
Note over Device: Reset device to be paired

Device -> httpdns: Select HTTP DNS and request mqttsUrl domain name
httpdns -> Device: Return mqttsUrl domain name
Device -> mqtt: Use UUID to connect to mqtt

APP -> Device: Scan device QR code
APP -> cloud: Get device UUID and request a token from the cloud
APP -> cloud: Pool activated device with token

cloud -> mqtt: Push token and region
mqtt -> Device: Pass token and region to device

Device -> cloud: Request to activate device
cloud -> Device: Activated successfully

cloud-->APP: Activated successfully with paired device list returned

Query device UUID

Scan the QR code of the device to get the url, and then get the UUID through the common interface

Common API methods reference

https://developer.tuya.com/en/docs/app- ... vc94pvqo8i

Parameters

ParameterValue
apiNametuya.m.qrcode.parse
Version4.0
postData@{@"code":url}

Get a Token

Before pairing process, the SDK must get a pairing token from the cloud in the networked state. The token is valid for 10 minutes and expires immediately after the device is paired. A new token must be generated if the device needs to be paired again.

API description

Code: Select all

/**
 *  To obtain token with uuid  (valid for 10 minutes)
 *
 *  @param uuid    Device uuid
 *  @param homeId  Home Id
 *  @param success Success block
 *  @param failure Failure block
 */
- (void)getTokenWithUUID:(NSString *)uuid
                  homeId:(long long)homeId
                 success:(TYSuccessString)success
                 failure:(TYFailureError)failure;

Example:

Code: Select all

 [[TuyaSmartActivator sharedInstance] getTokenWithUUID:uuid homeId:homeId success:^(NSString *result) {
       // get token
    } failure:^(NSError *error) {
        
    }];

Start Pairing

Code: Select all

/**
 *  start config (Wireless config)
 *
 *  @param mode     Config mode, EZ or AP
 *  @param ssid     Name of route
 *  @param password Password of route
 *  @param token    配网 Token
 *  @param timeout  Timeout, default 100 seconds
 */
- (void)startConfigWiFi:(TYActivatorMode)mode
                   ssid:(NSString *)ssid
               password:(NSString *)password
                  token:(NSString *)token
                timeout:(NSTimeInterval)timeout;

Example:

Code: Select all

[[TuyaSmartActivator sharedInstance] startConfigWiFi:TYActivatorModeEZ ssid:@"" password:@"" token:self.token timeout:Timeout];

Callback of the pairing delegate

Code: Select all

/**
 Callback of Config Network Status Update

 @param activator   instance
 @param deviceModel deviceModel
 @param error       error
 */
- (void)activator:(TuyaSmartActivator *)activator didReceiveDevice:(TuyaSmartDeviceModel *)deviceModel error:(NSError *)error;

Example

Code: Select all

[TuyaSmartActivator sharedInstance].delegate = self;

- (void)activator:(TuyaSmartActivator *)activator didReceiveDevice:(TuyaSmartDeviceModel *)deviceModel error:(NSError *)error {
      // get deviceModel 
}
luoji
Posts: 99

Re: 【求助】有线联网,在已接入互联网的情况下,如何使用二维码扫码绑定

请按“网关中控论坛技术问题发帖指导”发帖。我们需要知道用的什么sdk才知道哪个接口

Post Reply