class for mqtt added but does not work yet as intendet

This commit is contained in:
Sebastian 2020-07-16 16:09:07 +02:00
parent bb58f91a47
commit 1dafad0c72
4 changed files with 31 additions and 5 deletions

View File

@ -4,7 +4,9 @@ var client = mqtt.connect('mqtt://timovolkmann.de')
const PUBLISH_PATH = "smartgarden/commands/";
const MQTT_DEVICE_ID = "esp-sebastian";
client.on('connect', function () {
publishMessage("smartgarden/commands/esp-sebastian/light", "on");
/*client.on('connect', function () {
client.subscribe('presence', function (err) {
if (!err) {
//client.publish('presence', 'Hello mqtt')
@ -17,10 +19,11 @@ client.on('message', function (topic, message) {
// message is Buffer
console.log(message.toString())
client.end()
})
})*/
function publishMessage(topic, message) {
client.publish(topic, message)
client.publish(topic, message);
console.log("publish message got called: " + message);
}
module.exports = {

View File

@ -51,7 +51,7 @@ class Settings extends React.Component{
render(){
return (
<>
<>
<Container>
<Row className="justify-content-md-center">
<Col md="auto">

21
package-lock.json generated
View File

@ -111,6 +111,14 @@
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"dev": true
},
"bufferutil": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.1.tgz",
"integrity": "sha512-xowrxvpxojqkagPcWRQVXZl0YXhRhAtBEIq3VoER1NH5Mw1n1o0ojdspp+GS2J//2gCVyrzQDApQ4unGF+QOoA==",
"requires": {
"node-gyp-build": "~3.7.0"
}
},
"callback-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/callback-stream/-/callback-stream-1.1.0.tgz",
@ -1287,6 +1295,11 @@
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
"dev": true
},
"node-gyp-build": {
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz",
"integrity": "sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w=="
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@ -1844,6 +1857,14 @@
"through2-filter": "^3.0.0"
}
},
"utf-8-validate": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.2.tgz",
"integrity": "sha512-SwV++i2gTD5qh2XqaPzBnNX88N6HdyhQrNNRykvcS0QKvItV9u3vPEJr+X5Hhfb1JC0r0e1alL0iB09rY8+nmw==",
"requires": {
"node-gyp-build": "~3.7.0"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",

View File

@ -10,6 +10,7 @@
"dependencies": {
"@babel/runtime": "^7.8.3",
"bootstrap": "^4.5.0",
"bufferutil": "^4.0.1",
"jquery": "^3.4.1",
"lodash": "^4.17.19",
"meteor-node-stubs": "^1.0.0",
@ -17,7 +18,8 @@
"react-bootstrap": "^1.0.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"recharts": "^1.8.5"
"recharts": "^1.8.5",
"utf-8-validate": "^5.0.2"
},
"meteor": {
"mainModule": {