mqtt-devices-parser 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +6 -0
- package/Readme.md +4 -0
- package/Release.md +11 -0
- package/index.js +6 -5
- package/package.json +1 -1
package/Changelog.md
CHANGED
package/Readme.md
CHANGED
|
@@ -33,3 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
The default configuration uses ./config/index.js file\
|
|
35
35
|
In your program set the same struct and pass it as argument on the module init call.
|
|
36
|
+
|
|
37
|
+
An mqtt account will be created using the following settings
|
|
38
|
+
mqtt.user - mqtt user login
|
|
39
|
+
mqtt.pwd - mqtt pwd login
|
package/Release.md
ADDED
package/index.js
CHANGED
|
@@ -92,12 +92,13 @@ var self = module.exports = {
|
|
|
92
92
|
await $.models.dropTableIndexes();
|
|
93
93
|
await $.models.sync();
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
// adds user for mqtt with admin credentials
|
|
96
|
+
let user = await $.models.insertUser($.config.mqtt.user,$.config.mqtt.pwd,5);
|
|
97
97
|
let user_id = user.dataValues.id;
|
|
98
98
|
await $.models.insertUser("device","device",3);
|
|
99
99
|
await $.models.insertUser("client","client_pwd",3);
|
|
100
|
-
|
|
100
|
+
// adds client with credentials admin@admin
|
|
101
|
+
await $.models.insertClient("admin","admin",user_id); // dashboard login
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
// project tables
|
|
@@ -136,9 +137,9 @@ function mqtt_connect(){
|
|
|
136
137
|
|
|
137
138
|
for(let project in $.config.projects){
|
|
138
139
|
if($.config.projects[project])
|
|
139
|
-
client.publish(mqtt_prefix+"/"+project,"active");
|
|
140
|
+
client.publish(mqtt_prefix+"/"+project,"active",{qos:2,retain:true});
|
|
140
141
|
else
|
|
141
|
-
client.publish(mqtt_prefix+"/"+project,"deactive");
|
|
142
|
+
client.publish(mqtt_prefix+"/"+project,"deactive",{qos:2,retain:true});
|
|
142
143
|
};
|
|
143
144
|
})
|
|
144
145
|
console.log(`MQTT connected to: ${$.config.mqtt.host}:${$.config.mqtt.port}`);
|