These dmrgo docs are built from main and can describe changes that no release has yet. No release of dmrgo has these docs.

  1. DMRHub
  2. dmrgo
  3. State machines
  4. csbk.Preambles

csbk.Preambles

On this page

This page describes the Pre_CSBK state machine of package csbk: it follows the Pre_CSBKs on a channel and reports the CSBK or data that they announce.

What it does

csbk.Preambles follows the Pre_CSBKs of one logical channel. A Pre_CSBK with CSBK Blocks to Follow n announces n more blocks: more Pre_CSBKs, then a CSBK or a data message, and it carries the target and source addresses of that message. The Preambles reports the first Pre_CSBK of a transfer. It then joins the CSBK, MBC header or data header that follows when that burst has the same target and source addresses, or it reports that the announced transfer did not come. A repeater can send more Pre_CSBKs than the radio did, each with CSBK Blocks to Follow 1, and each one moves the end of the transfer later. (ETSI TS 102 361-2 clause 7.1.2.5, Table 7.7, and clause 7.2.7)

The Preambles does no I/O. Each method takes the time now on a monotonic clock that the caller picks, and appends outputs to a slice of the caller.

When to use it

Use a Preambles in a monitor, a bridge or a gateway that must have the parties of a CSBK or a data message before it comes, or that must join a CSBK with the Pre_CSBKs before it. For example, a bridge can hold a slot for the parties of the Pre_CSBKs, and a monitor can show a CSBK with the addresses that its Pre_CSBKs carry.

A data.Receiver already starts a data call at a Pre_CSBK, so a data receiver alone does not need a Preambles. A bs.Repeater has its own Pre_CSBK handling for the slot it repeats.

Config

csbk.NewPreambles takes a *csbk.PreamblesConfig. A nil config is the zero config, which is the usual choice. The only field is the scratch burst that Burst decodes into, which machines on one goroutine can share.

Field Type Default Description
Scratch *layer2.Burst layer2.NewBurst() Scratch, when set, is the Burst that Burst decodes into, as for RequesterConfig.Scratch.

States and transitions

States of Preambles, from Preambles.State:

State Meaning Seen in tests
PreamblesIdle PreamblesIdle follows no announced transfer. yes, first state
PreamblesAnnounced PreamblesAnnounced waits for the CSBK or data that Pre_CSBKs announced. yes

Transitions seen in tests:

From Method call To
PreamblesIdle Burst PreamblesAnnounced
PreamblesAnnounced Burst, Lost, Reset, Tick PreamblesIdle

Transitions of Preambles

These inputs move the state:

  • In idle, a Pre_CSBK starts a transfer and appends OutputAnnounced.
  • While a transfer is announced, a Pre_CSBK with the same target, source, group flag and data flag moves the end of the transfer later and appends nothing. A Pre_CSBK with other parties appends OutputExpired for the old transfer and OutputAnnounced for the new one.
  • While a transfer is announced, the next CSBK that is not a Pre_CSBK, MBC header or data header ends the transfer and returns to idle. When the burst has the target and source addresses of the Pre_CSBKs, the Preambles appends OutputJoined. When it has other addresses, or does not carry both, the Preambles appends OutputExpired for the transfer and gives no output for the burst itself; feed the burst to your other machines as usual. An MBC header gives its addresses only for the grant payloads.
  • When one burst interval has passed after the last announced block, Tick appends OutputExpired and returns to idle.
  • Reset returns to idle without an output.

Other bursts, voice included, do not change the state. Lost does not end the transfer, because the announced burst can still come after a short loss of signal.

Inputs and outputs

Every method that takes dst appends at most csbk.MaxOutputs outputs, and does not allocate when dst has that room.

Method Takes Returns
Burst a raw burst and its layer2.Hint dst with the outputs
Decoded a burst that the caller decoded, or nil dst with the outputs
Tick the time now dst with OutputExpired when the transfer did not come
Deadline nothing the time of the next Tick, and false when no transfer is announced
Lost the time now dst; it runs the timer as Tick does
State, Reset nothing the state, or nothing

Feed every burst of the logical channel to Burst, or to Decoded when you decode the burst once for several machines. Pass now as the start of the received burst, because the end of the transfer counts from it. A nil raw burst only runs the timer. A CSBK whose CRC fails is dropped.

Each csbk.Output has the Call of the Pre_CSBKs, with Group set for a talkgroup target:

  • OutputAnnounced: the first Pre_CSBK of a transfer. Data reports that data follows, and Until is the time of the last announced block.
  • OutputJoined: the CSBK, MBC header or data header after the Pre_CSBKs. Data reports a data header, and CSBK holds the CSBK when one came.
  • OutputExpired: a transfer that did not come by Until, that a Pre_CSBK of other parties replaced, or that a CSBK, MBC header or data header of other parties followed.

Timers

Timer Config field Value
Time per announced block, from the start of the Pre_CSBK none 60ms
Wait after the last announced block before OutputExpired none 60ms

A Pre_CSBK at time t with CSBK Blocks to Follow n sets Until to t plus n burst intervals. The most Pre_CSBKs before one CSBK is 255, the 8 bits of CSBK Blocks to Follow.

Worked example

This example uses a csbk.Requester to make a Motorola call alert with 2 Pre_CSBKs, and feeds its three bursts to a Preambles.

func ExamplePreambles() {
    q, _ := csbk.NewRequester(&csbk.RequesterConfig{Slot: enums.Slot1, Source: layer2.SyncSourceMS})
    _ = q.RequestCallAlert(0, 3002068, 3002198, &csbk.RequestOptions{Preambles: 2})
    p, err := csbk.NewPreambles(nil)
    if err != nil {
        fmt.Println(err)
        return
    }
    out := make([]csbk.Output, 0, csbk.MaxOutputs)
    for range 3 {
        at, _ := q.Deadline()
        sent := q.Tick(at, nil)
        out = p.Burst(at, &sent[0].Burst, layer2.Hint{}, out[:0])
        for i := range out {
            fmt.Println(out[i].Kind, "to", out[i].Call.Target, "until", out[i].Until)
        }
    }
}

Output:

Announced to 3002068 until 120ms
Joined to 3002068 until 0s

The first Pre_CSBK announces two more blocks, so Until is the time of the call alert. The second Pre_CSBK has the same parties and appends nothing. The call alert joins the transfer.

Errors

The doc comments of Preambles and its methods name no error.

No config is out of range, so NewPreambles returns a nil error; it returns one only to have the shape of the other constructors. The other methods return no error. A burst that does not decode, or a CSBK whose CRC fails, is dropped.

Edit this page on GitHub