问题描述:
用EC*00U开发板按照贵司接入阿里云的DEMO,设备的三元组数据替换为我的设备的三元组数据,ClintID也已替换为我设备的ID, 运行后总是反馈mqtt连接失败,错误码为2,代码如下:
de* __init__(sel*):
aliyun_Class.inst = sel*
sel*.p*ductKey = &k02hsyTOPaI& # 产品标识
sel*.p*ductSecret = None # 产品密钥(一机一密认证此参数传入None)
sel*.DeviceSecret = &8b5e8d25d87358*7ee8584c*19*4e0ba& # 设备密钥(一型一密认证此参数传入None)
sel*.DeviceName = &**ID& # 设备名称
# sel*.MqttServer = &iot-0*z00emc70oh9ko.mqtt.iothub.aliyun*.com&
# /b*adcas/a1llZotKk*/123
sel*.subsc*be_topic1 = &/sys&+&/&+sel*.p*ductKey+&/&+sel*.DeviceName+&/&+&thing/service/p*perty/set&
sel*.subsc*be_topic2 = &/sys&+&/&+sel*.p*ductKey+&/&+sel*.DeviceName+&/&+&thing/*nt/p*perty/post_reply&
sel*.publish_topic1 = &/sys&+&/&+sel*.p*ductKey+&/&+sel*.DeviceName+&/&+&thing/*nt/p*perty/post&
# 创建aliyun连接对象
sel*.ali = aLiYun(
sel*.p*ductKey,
sel*.p*ductSecret,
sel*.DeviceName,
sel*.DeviceSecret,)
# sel*.MqttServer,
# 设置mqtt连接属性
clientID = b'k02hsyTOPaI.**ID|sec*emode=2,si*method=hma*ha25*' # 自定义字符(不超过*4)
ret = sel*.ali.setMqtt(
clientID,
clean_session=*alse,
keepAlive=*0,
reconn=True) # *alse True