start mqtt client (based on paho.mqtt.c), basically works

This commit is contained in:
2026-03-13 23:56:55 +03:00
parent 767bb2b382
commit feb86b15f8
114 changed files with 37878 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
#include "pidigest.h"
#include "pihttpclient.h"
#include "piliterals.h"
#include "pimqttclient.h"
#include "pip.h"
#include "piunits.h"
#include "pivaluetree_conversions.h"
@@ -18,8 +19,32 @@ inline PIByteArray SMBusTypeInfo_genHash(PIString n) {
return piSerialize(c.shorthash(n.removeAll(" "), PIString("SMBusDataHashKey").toByteArray()));
}
PIKbdListener kbd;
int main(int argc, char * argv[]) {
PIMQTT::Client cl;
cl.setConnectTimeout(2_s);
CONNECTL(&cl, connected, [&cl] {
piCout << "connected";
cl.subscribe("/zigbee2mqtt");
cl.subscribe("/zigbee2mqtt/+");
cl.unsubscribe("/zigbee2mqtt");
cl.publish("/zigbee2mqtt/abc", "hello from PIP"_a.toAscii());
});
CONNECTL(&cl, disconnected, [&cl](PIMQTT::Error code) {
piCout << "disconnected code" << (int)code;
cl.connect("localhost", "PIP");
});
CONNECTL(&cl, received, [](const PIMQTT::Message & message) { piCout << "received" << message.topic << message.payload.size(); });
cl.connect("localhost", "PIP");
kbd.enableExitCapture('Q');
WAIT_FOR_EXIT
piCout << "exiting ...";
return 0;
PICrypt _crypt;
// auto ba = PIFile::readAll("logo.png");
PIString str = "hello!"_a;