Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mqtt so we can remove the async-mqtt wrapper #102

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

## future release

* Upgrade `mqtt` to get rid of `async-mqtt` (https://github.com/Jalle19/eda-modbus-bridge/issues/95)

## 2.7.1

* Fix reading from unit type from wrong register (https://github.com/Jalle19/eda-modbus-bridge/issues/100)
Expand Down
4 changes: 2 additions & 2 deletions app/mqtt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const publishTopics = async (mqttClient, topicMap, publishOptions = {}) => {
const publishPromises = []

for (const [topic, value] of Object.entries(topicMap)) {
publishPromises.push(mqttClient.publish(topic, value, publishOptions))
publishPromises.push(mqttClient.publishAsync(topic, value, publishOptions))
}

await Promise.all(publishPromises)
Expand All @@ -126,7 +126,7 @@ export const subscribeToChanges = async (modbusClient, mqttClient) => {
for (const topicName of topicNames) {
logger.info(`Subscribing to topic(s) ${topicName}`)

await mqttClient.subscribe(topicName)
await mqttClient.subscribeAsync(topicName)
}
}

Expand Down
4 changes: 2 additions & 2 deletions eda-modbus-bridge.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from 'express'
import expressWinston from 'express-winston'
import MQTT from 'async-mqtt'
import mqtt from 'mqtt'
import yargs from 'yargs'
import ModbusRTU from 'modbus-serial'
import { getFlagStatus, root, setFlagStatus, setSetting, summary } from './app/http.mjs'
Expand Down Expand Up @@ -168,7 +168,7 @@ const argv = yargs(process.argv.slice(2))

do {
try {
mqttClient = await MQTT.connectAsync(argv.mqttBrokerUrl, clientOptions)
mqttClient = await mqtt.connectAsync(argv.mqttBrokerUrl, clientOptions)
connectedOnce = true
logger.info(`Successfully connected to MQTT broker at ${argv.mqttBrokerUrl}`)
} catch (e) {
Expand Down
Loading
Loading