Volt Docs

Reference

SmsQueue

Outgoing-SMS queue fed by MQTT: receives 'id|number|text' messages on a topic, validates them and hands them out one at a time (ESP32).

Connects over
GPIO pins
Made by
local

Use it

main.volt
hardware {
    device smsqueue: SmsQueue(led: 16)
}

every 1s {
    let value: bool = smsqueue.next()
    log("smsqueue", "next={value}")
}

The SmsQueue is wired to ordinary GPIOs: give each of its pins (led) as a named argument. The compiler checks every pin can do its job.

Methods

  • smsqueue.subscribe(topic: string) -> bool

    Subscribe to the topic that carries outgoing SMS; call once after mqtt.connect (re-subscribed automatically on reconnect)

  • smsqueue.next() -> bool

    Take the next queued message; false if none. Its fields are then read with id(), number(), text(), is_valid(), error(), is_duplicate()

  • smsqueue.id() -> string

    Message id of the current message

  • smsqueue.number() -> string

    Destination number of the current message (+ and 5-15 digits)

  • smsqueue.text() -> string

    SMS text of the current message (printable ASCII, max 160 chars)

  • smsqueue.is_valid() -> bool

    true if the current message passed validation

  • smsqueue.error() -> string

    Why the current message was rejected (empty when valid)

  • smsqueue.is_duplicate() -> bool

    true if the current message id was already sent since boot (server redelivery)

  • smsqueue.mark_sent()

    Remember the current message id as sent, for duplicate detection

  • smsqueue.pending() -> int

    Messages waiting in the queue

  • smsqueue.dropped() -> int

    Messages dropped since boot (queue full, or no usable id)

  • smsqueue.led(on: int)

    Activity LED on (1) or off (0)

Wiring

PinConnect to
LEDActivity LED via 330 ohm to GND

Specifications

Queue
8 messages
Payload
id|number|text, id 1-32 chars [A-Za-z0-9_-]
Chip
ESP32 only (uses FreeRTOS queues)

Tips

  • Messages are buffered in RAM only: the server must redeliver anything not acknowledged within its timeout.
  • Text longer than 160 chars or numbers with letters are rejected, not truncated.