Skip to content

Instantly share code, notes, and snippets.

@jtuttas
Created April 6, 2018 09:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtuttas/3fdfef30d094947308504305ffd61a8a to your computer and use it in GitHub Desktop.
Save jtuttas/3fdfef30d094947308504305ffd61a8a to your computer and use it in GitHub Desktop.
MQTT mit der Powershell
Add-Type -Path 'C:\Users\jtutt\OneDrive\bin\NuGet\M2Mqtt.4.3.0.0\lib\net45\M2Mqtt.Net.dll'
$MqttClient = [uPLibrary.Networking.M2Mqtt.MqttClient]("service.joerg-tuttas.de")
#
# Verbinden
$mqttclient.Connect([guid]::NewGuid())
Register-ObjectEvent -inputObject $MqttClient -EventName MqttMsgPublishReceived -Action {Write-host "Event Found Topic: $($args[1].topic) Message $([System.Text.Encoding]::ASCII.GetString($args[1].Message))"}
$mqttClient.Subscribe("esp32/temp",0)
$MqttClient.Publish("esp32/temp", [System.Text.Encoding]::UTF8.GetBytes("{temp:17}"))
@jtuttas
Copy link
Author

jtuttas commented Apr 6, 2018

Die dll ist zu installieren über

nuget install M2Mqtt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment