1 Star 0 Fork 1

wwkkww/Wechat_MQTT_ESP8266_BaiduIoT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.js 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
IAMLIUBO 提交于 2019-03-30 21:28 . add README.md file
/*
_ _ __
| | (_) / _|
_ __ ___ __ _ | | __ _ _ __ __ _ | |_ _ _ _ __ __ __ _ _ ____
| '_ ` _ \ / _` || |/ /| || '_ \ / _` || _|| | | || '_ \ \ \/ /| | | ||_ /
| | | | | || (_| || < | || | | || (_| || | | |_| || | | | _ > < | |_| | / /
|_| |_| |_| \__,_||_|\_\|_||_| |_| \__, ||_| \__,_||_| |_|(_)/_/\_\ \__, |/___|
__/ | __/ |
|___/ |___/
*/
//app.js
import mqtt from './utils/mqtt.js';
const host = 'wxs://1v1r5ep.mqtt.iot.bj.baidubce.com/mqtt';
const options = {
protocolVersion: 4, //MQTT连接协议版本
clientId: randomString(10),
clean: true,
username: '1v1r5ep/zhihu_iamliubo',
password: 'tNVKODyl2chbm5yp',
reconnectPeriod: 1000,
connectTimeout: 30 * 1000,
resubscribe: true
};
App({
onLaunch: function() {
},
globalData: {
client_ID: randomString(10),
client: mqtt.connect(host, options),
},
})
function randomString(len) {
len = len || 32;
var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
var maxPos = $chars.length;
var pwd = '';
for (let i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/wwkkww1983/Wechat_MQTT_ESP8266_BaiduIoT.git
[email protected]:wwkkww1983/Wechat_MQTT_ESP8266_BaiduIoT.git
wwkkww1983
Wechat_MQTT_ESP8266_BaiduIoT
Wechat_MQTT_ESP8266_BaiduIoT
master

搜索帮助