edgeport - v1.0.3
    Preparing search index...

    Function encodeSubscribe

    • Encodes a SUBSCRIBE packet.

      Begins with the packet identifier, then a list of (topic filter, requested-QoS) pairs. The fixed-header flags nibble is the spec-mandated 0x2.

      Parameters

      • packetId: number

        A non-zero packet identifier the matching SUBACK will echo.

      • subscriptions: Subscription[]

        One or more topic filters with their requested maximum QoS.

      Returns Uint8Array

      The SUBSCRIBE bytes.

      If no subscriptions are supplied.

      1.0.0

      import { encodeSubscribe } from 'edgeport/mqtt';

      const bytes = encodeSubscribe(1, [{ topicFilter: 'sensors/+/temp', qos: 1 }]);