MQTT 3.1.1/5.0 binary codec & embeddable broker (+/# wildcards, retained, Wills), industrial Modbus TCP registers, and mDNS/DNS-SD discovery.
Pure-Veko OASIS MQTT 3.1.1 & MQTT 5.0 wire codec and embeddable broker, industrial Modbus TCP MBAP/PDU simulator, and RFC 6762 / RFC 6763 mDNS & DNS-SD .local service discovery (iot_mqtt, iot_mqtt/modbus, iot_mqtt/mdns).
iot_mqtt provides zero-dependency binary telemetry and industrial edge protocols in pure Veko:
iot_mqtt:level = 4) and MQTT 5.0 (level = 5) binary framing: 1..4 byte Variable Byte Integer remaining-length codec, length-prefixed UTF-8 strings, and MQTT 5.0 Properties (Message-Expiry-Interval, Content-Type, Response-Topic, Correlation-Data, User-Property).CONNECT, CONNACK, PUBLISH (QoS 0/1/2, retain, dup), PUBACK, SUBSCRIBE, SUBACK, UNSUBSCRIBE, PINGREQ, PINGRESP, and DISCONNECT.topic-matches? supporting +, #, and §4.7.2 $SYS leading-$ isolation) plus an embeddable deterministic MqttBroker state machine (subscriptions, per-topic retained messages, QoS 1 in-flight ACK tracking, and Last Will delivery).iot_mqtt/modbus:0x01 Read Coils, 0x03 Read Holding Registers, 0x04 Read Input Registers, 0x05 Write Single Coil, 0x06 Write Single Register, 0x10 Write Multiple Registers, and 0x80 | fc exception responses, backed by an in-memory RegisterBank PLC server handler.iot_mqtt/mdns:.local multicast query and service announcement packet builder (PTR + SRV + TXT + A with RFC 1035 0xC0 label compression) and pointer-decompressing parser.veko pkg add iot_mqtt@1.0.0Import the modules in .vk source files:
use [
mqtt = iot_mqtt
modbus = iot_mqtt/modbus
mdns = iot_mqtt/mdns
]| Field | Width | Notes |
|---|---|---|
| `(pkt_type << 4) \ | flags` | 1 byte |
Remaining Length | 1..4 bytes | Variable Byte Integer (7 data bits + 0x80 continuation bit) |
Variable Header | Variable | Topic / Packet Identifier + MQTT 5.0 Properties (encode-props) |
Payload | Remaining bytes | Binary application payload or subscription filter list |
| Byte Offset | Field | Type | Notes |
|---|---|---|---|
0..2 | Transaction ID | uint16 BE | Echoed by server to correlate pipelined requests |
2..4 | Protocol ID | uint16 BE | Always 0x0000 for Modbus TCP |
4..6 | Length | uint16 BE | Byte count of Unit ID (1B) + PDU |
6 | Unit ID | uint8 | Slave / bridge unit identifier |
iot_mqttMqttProps, TopicSub, MqttPacket, RetainedMsg, BrokerSession, MqttBrokerencode-varint [val i64] bytes / decode-varint [raw bytes, off i64] mapencode-utf8 [s str] bytes / decode-utf8 [raw bytes, off i64] mapencode-props [props MqttProps] bytes / decode-props [raw bytes, off i64] mapencode-connect, encode-connack, encode-publish, encode-puback, encode-subscribe, encode-suback, encode-unsubscribe, encode-pingreq, encode-pingresp, encode-disconnectdecode-packet [wire bytes /level proto_level i64 = 5] MqttPacketdecode-packet-at [wire bytes, off i64 /level proto_level i64 = 5] maptopic-matches? [filter str, topic str] boolnew-broker [] MqttBrokerbroker-connect [mut b MqttBroker, conn MqttPacket] MqttPacketbroker-subscribe [mut b MqttBroker, client_id str, packet_id i64, subs block[TopicSub]] MqttPacketbroker-unsubscribe [mut b MqttBroker, client_id str, topics block[str]] i64broker-publish [mut b MqttBroker, pub_pkt MqttPacket] i64broker-puback [mut b MqttBroker, client_id str, packet_id i64] boolbroker-inflight-count [b MqttBroker, client_id str] i64broker-disconnect [mut b MqttBroker, client_id str /unexpected ungraceful bool = false /reason reason_code i64 = 0] i64broker-drain-client [mut b MqttBroker, client_id str] block[MqttPacket]iot_mqtt/modbusFC-READ-COILS, FC-READ-HOLDING-REGS, FC-READ-INPUT-REGS, FC-WRITE-SINGLE-COIL, FC-WRITE-SINGLE-REG, FC-WRITE-MULTI-REGS, EX-ILLEGAL-FUNCTION, EX-ILLEGAL-DATA-ADDR, EX-ILLEGAL-DATA-VALencode-read-coils, encode-read-holding-registers, encode-read-input-registers, encode-write-single-coil, encode-write-single-register, encode-write-multiple-registers, encode-exception-responsedecode-request [wire bytes] ModbusRequest / decode-response [wire bytes /expected-coils coil_cnt i64 = -1] ModbusResponsenew-register-bank [/coils nc i64 = 256 /holding nh i64 = 256 /input ni i64 = 256] RegisterBankbank-set-input, bank-set-holding, bank-get-holding, handle-modbus-tcp [mut bank RegisterBank, req_wire bytes] bytesiot_mqtt/mdnsMDNS-IPV4, MDNS-PORT, TYPE-A, TYPE-PTR, TYPE-TXT, TYPE-AAAA, TYPE-SRV, CLASS-IN, CLASS-FLUSHbuild-ptr-query [service_type str /unicast-response qu bool = false] bytesbuild-service-announcement [instance_name str, service_type str, host_target str, ipv4 str, port i64, txt_kv map[str] /ttl ttl_sec i64 = 120] bytesdecode-dns-name [wire bytes, start_off i64] mapparse-mdns-packet [wire bytes] MdnsPacketuse [mqtt = iot_mqtt, modbus = iot_mqtt/modbus]
// Encode an MQTT 5.0 PUBLISH with User Properties
pkt_wire = mqtt/encode-publish/qos/retain/packet-id/props 'factory/line-1/rpm' (bytes/from-str '1480') 1 true 9 (mqtt/MqttProps {
content_type = 'text/plain'
user_props = { 'unit' = 'rpm' }
})
pkt = mqtt/decode-packet pkt_wire
println pkt.topic
// Execute Modbus TCP Holding Register write + read against RegisterBank
mut plc = modbus/new-register-bank
_ = modbus/handle-modbus-tcp mut plc (modbus/encode-write-multiple-registers 1 1 0 [1480 725])
resp = modbus/decode-response (modbus/handle-modbus-tcp mut plc (modbus/encode-read-holding-registers 2 1 0 2))
println resp.registers // [1480 725]https://veko-lang.org/pkg/iot_mqtt/1.0.0.vkp5ebe400293532c843b80979d08c16c2517cd4737b2ccf9b219156bcdd63e70fce671c3cd326d1fc62e232e790059d1b646b76e572ab398b109a1775c0d163d1bed25519:27406074d8681da1d4e6420f5d887cac15c313334c249ac047ba9d4e2df72b70{"name":"iot_mqtt","version":"1.0.0","tier":6.0,"tier_label":"Tier 6: Local-First, IoT, Web & Media","category":"MQTT 5.0, Modbus TCP & mDNS","description":"MQTT 3.1.1/5.0 binary codec & embeddable broker (+/# wildcards, retained, Wills), industrial Modbus TCP registers, and mDNS/DNS-SD discovery.","modules":["iot_mqtt/mdns","iot_mqtt","iot_mqtt/modbus"],"homepage":"https://veko-lang.org/packages/iot_mqtt"}| Bundle Entry Path | Size | Leaf SHA-256 Digest |
|---|---|---|
| README.md | 6 KB | 80d5bd011d65557a7c4aea9ada578a17c55fde93aa9bc0dbb5d95c2c81e23d4a |
| examples/demo.vk | 7 KB | e31f53ac3f864ce579e49b60e09c0e9bc9ceb20fa6ba81bfe545c3a3cee57acc |
| mdns.vk | 11 KB | 610d9f7b9f2904234e016542d9a3b33078ba736d6f2caa5e4d1a545f688c3fe8 |
| mod.vk | 33 KB | f92327d2a01f5e63627a668193fa779f4d97de34cd6846a3e22ab957fa0a7fbe |
| modbus.vk | 14 KB | 276eb6ef3358153a15c1fbad7d565963fded41a602b3104cf5df78a8ae04b091 |