Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lioujj authored Dec 2, 2023
1 parent 45bfb65 commit a7cd841
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
32 changes: 32 additions & 0 deletions AI/mqtt_0.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html><html><head><meta charset='utf-8'><meta http-equiv='Access-Control-Allow-Origin' content='*'><meta http-equiv='Access-Control-Allow-Credentials' content='true'><script src='https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script><script src='https://fustyles.github.io/webduino/SpBlocklyJS/GameElements_20190131/gameelements.js'></script><link rel='stylesheet' href='https://fustyles.github.io/webduino/SpBlocklyJS/css/icon_custom.css' /><script src='https://fustyles.github.io/webduino/SpBlocklyJS/MQTT_20220324/mqtt.min.js'></script></head><body>
<script>
const delay = (seconds) => {
return new Promise((resolve) => {
setTimeout(resolve, seconds * 1000);
});
};
const main = async () => {
const clientId = "mqtt_" + Math.random().toString(16).substr(2, 8);
const options = {
username: '',
password: '',
keepalive: 60,
clientId: clientId,
protocolId: "MQTT",
protocolVersion: 4,
clean: true,
reconnectPeriod: 1000,
connectTimeout: 30 * 1000
}

var mqtt_client = mqtt.connect('wss://mqtt.webduino.io/mqtt', options);
mqtt_client.on("connect", () => {
console.log("connected");
mqtt_client.on("message", async function(topic, payload) {})
})

mqtt_client.publish('ljj/light1', String('0'));
};
main();
</script>
</body></html>
32 changes: 32 additions & 0 deletions AI/mqtt_1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html><html><head><meta charset='utf-8'><meta http-equiv='Access-Control-Allow-Origin' content='*'><meta http-equiv='Access-Control-Allow-Credentials' content='true'><script src='https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script><script src='https://fustyles.github.io/webduino/SpBlocklyJS/GameElements_20190131/gameelements.js'></script><link rel='stylesheet' href='https://fustyles.github.io/webduino/SpBlocklyJS/css/icon_custom.css' /><script src='https://fustyles.github.io/webduino/SpBlocklyJS/MQTT_20220324/mqtt.min.js'></script></head><body>
<script>
const delay = (seconds) => {
return new Promise((resolve) => {
setTimeout(resolve, seconds * 1000);
});
};
const main = async () => {
const clientId = "mqtt_" + Math.random().toString(16).substr(2, 8);
const options = {
username: '',
password: '',
keepalive: 60,
clientId: clientId,
protocolId: "MQTT",
protocolVersion: 4,
clean: true,
reconnectPeriod: 1000,
connectTimeout: 30 * 1000
}

var mqtt_client = mqtt.connect('wss://mqtt.webduino.io/mqtt', options);
mqtt_client.on("connect", () => {
console.log("connected");
mqtt_client.on("message", async function(topic, payload) {})
})

mqtt_client.publish('ljj/light1', String('1'));
};
main();
</script>
</body></html>

0 comments on commit a7cd841

Please sign in to comment.