Documentation ¶
Overview ¶
Package dmr implements various protocols for interfacing Digital Mobile Radio repeaters and base stations.
Index ¶
- Constants
- Variables
- func BitsToBytes(bits []byte) []byte
- func BuildMessageData(msg string, ddFormat uint8, nullTerminated bool) ([]byte, error)
- func BytesToBits(data []byte) []byte
- func ParseEMBBitsFromSync(sync []byte) ([]byte, error)
- func ParseEmbeddedSignallingLCFromSyncBits(sync []byte) ([]byte, error)
- func ParseMessageData(data []byte, ddFormat uint8, nullTerminated bool) (string, error)
- func SyncPattern(bits []byte) uint8
- type ConfirmedData
- type ControlBlock
- type ControlBlockData
- type DataBlock
- type DataFragment
- type DataHeader
- type DataHeaderData
- type EMB
- type EmbeddedSignallingLC
- type NegativeAcknowledgeResponse
- type OutboundActivation
- type Packet
- type PacketFunc
- type Preamble
- type ProprietaryData
- type Repeater
- type ResponseData
- type ShortDataDefinedData
- type ShortDataRawData
- type UDTData
- type UnconfirmedData
- type UnitToUnitVoiceServiceAnswerResponse
- type UnitToUnitVoiceServiceRequest
Constants ¶
const ( PayloadBits = 98 + 10 + 48 + 10 + 98 InfoHalfBits = 98 InfoBits = 2 * InfoHalfBits InfoSize = 12 // After BPTC(196, 96) decoding SlotTypeHalfBits = 10 SlotTypeBits = 2 * SlotTypeHalfBits SignalBits = 48 SyncOffsetBits = InfoHalfBits + SlotTypeHalfBits SyncBits = SignalBits VoiceHalfBits = 108 VoiceBits = 2 * VoiceHalfBits EMBHalfBits = 8 EMBBits = 2 * EMBHalfBits EMBSignallingLCFragmentBits = 32 )
Various sizes of information chunks.
const ( B00000000 = iota B00000001 B00000010 B00000011 B00000100 B00000101 B00000110 B00000111 B00001000 B00001001 B00001010 B00001011 B00001100 B00001101 B00001110 B00001111 B00010000 B00010001 B00010010 B00010011 B00010100 B00010101 B00010110 B00010111 B00011000 B00011001 B00011010 B00011011 B00011100 B00011101 B00011110 B00011111 B00100000 B00100001 B00100010 B00100011 B00100100 B00100101 B00100110 B00100111 B00101000 B00101001 B00101010 B00101011 B00101100 B00101101 B00101110 B00101111 B00110000 B00110001 B00110010 B00110011 B00110100 B00110101 B00110110 B00110111 B00111000 B00111001 B00111010 B00111011 B00111100 B00111101 B00111110 B00111111 B01000000 B01000001 B01000010 B01000011 B01000100 B01000101 B01000110 B01000111 B01001000 B01001001 B01001010 B01001011 B01001100 B01001101 B01001110 B01001111 B01010000 B01010001 B01010010 B01010011 B01010100 B01010101 B01010110 B01010111 B01011000 B01011001 B01011010 B01011011 B01011100 B01011101 B01011110 B01011111 B01100000 B01100001 B01100010 B01100011 B01100100 B01100101 B01100110 B01100111 B01101000 B01101001 B01101010 B01101011 B01101100 B01101101 B01101110 B01101111 B01110000 B01110001 B01110010 B01110011 B01110100 B01110101 B01110110 B01110111 B01111000 B01111001 B01111010 B01111011 B01111100 B01111101 B01111110 B01111111 B10000000 B10000001 B10000010 B10000011 B10000100 B10000101 B10000110 B10000111 B10001000 B10001001 B10001010 B10001011 B10001100 B10001101 B10001110 B10001111 B10010000 B10010001 B10010010 B10010011 B10010100 B10010101 B10010110 B10010111 B10011000 B10011001 B10011010 B10011011 B10011100 B10011101 B10011110 B10011111 B10100000 B10100001 B10100010 B10100011 B10100100 B10100101 B10100110 B10100111 B10101000 B10101001 B10101010 B10101011 B10101100 B10101101 B10101110 B10101111 B10110000 B10110001 B10110010 B10110011 B10110100 B10110101 B10110110 B10110111 B10111000 B10111001 B10111010 B10111011 B10111100 B10111101 B10111110 B10111111 B11000000 B11000001 B11000010 B11000011 B11000100 B11000101 B11000110 B11000111 B11001000 B11001001 B11001010 B11001011 B11001100 B11001101 B11001110 B11001111 B11010000 B11010001 B11010010 B11010011 B11010100 B11010101 B11010110 B11010111 B11011000 B11011001 B11011010 B11011011 B11011100 B11011101 B11011110 B11011111 B11100000 B11100001 B11100010 B11100011 B11100100 B11100101 B11100110 B11100111 B11101000 B11101001 B11101010 B11101011 B11101100 B11101101 B11101110 B11101111 B11110000 B11110001 B11110010 B11110011 B11110100 B11110101 B11110110 B11110111 B11111000 B11111001 B11111010 B11111011 B11111100 B11111101 B11111110 B11111111 )
Because Go doesn't have binary literals ("We've found hex and octal to be sufficient")
const ( OutboundActivationOpcode = B00111000 UnitToUnitVoiceServiceRequestOpcode = B00000100 UnitToUnitVoiceServiceAnswerResponseOpcode = B00000101 NegativeAcknowledgeResponseOpcode = B00100100 PreambleOpcode = B00111101 )
Control Block Opcode
const ( PacketFormatUDT uint8 = iota // 0b0000 PacketFormatResponse // 0b0001 PacketFormatUnconfirmedData // 0b0010 PacketFormatConfirmedData // 0b0011 PacketFormatShortDataDefined // 0b1101 PacketFormatShortDataRaw // 0b1110 PacketFormatProprietaryData // 0b1111 )
Data Header Packet Format
const ( ServiceAccessPointUDT uint8 = iota // 0b0000 ServiceAccessPointTCPIPHeaderCompression // 0b0010 ServiceAccessPointUDPIPHeaderCompression // 0b0011 ServiceAccessPointIPBasedPacketData // 0b0100 ServiceAccessPointARP // 0b0101 ServiceAccessPointProprietaryData // 0b1001 ServiceAccessPointShortData // 0b1010 )
Service Access Point
const ( ResponseTypeACK uint8 // Class 0b00, Type 0b001 ResponseTypeIllegalFormat // Class 0b01, Type 0b000 ResponseTypePacketCRCFailed // Class 0b01, Type 0b001 ResponseTypeMemoryFull // Class 0b01, Type 0b010 ResponseTypeRecvFSVNOutOfSeq // Class 0b01, Type 0b011 ResponseTypeUndeliverable // Class 0b01, Type 0b100 ResponseTypeRecvPktOutOfSeq // Class 0b01, Type 0b101 ResponseTypeDisallowed // Class 0b01, Type 0b110 ResponseTypeSelectiveACK // Class 0b10, Type 0b000 )
Response Data Header Response Type, encodes class and type
const ( UDTFormatBinary uint8 = iota UDTFormatMSAddress UDTFormat4BitBCD UDTFormatISO_7BitChars UDTFormatISO_8BitChars UDTFormatNMEALocation UDTFormatIPAddress UDTFormat16BitUnicodeChars UDTFormatCustomCodeD1 UDTFormatCustomCodeD2 )
UDP Response Header UDT Format
const ( DDFormatBinary uint8 = iota DDFormatBCD DDFormat7BitChar DDFormat8BitISO8859_1 DDFormat8BitISO8859_2 DDFormat8BitISO8859_3 DDFormat8BitISO8859_4 DDFormat8BitISO8859_5 DDFormat8BitISO8859_6 DDFormat8BitISO8859_7 DDFormat8BitISO8859_8 DDFormat8BitISO8859_9 DDFormat8BitISO8859_10 DDFormat8BitISO8859_11 DDFormat8BitISO8859_13 DDFormat8BitISO8859_14 DDFormat8BitISO8859_15 DDFormat8BitISO8859_16 DDFormatUTF8 DDFormatUTF16 DDFormatUTF16BE DDFormatUTF16LE DDFormatUTF32 DDFormatUTF32BE DDFormatUTF32LE )
UDT Response Header DD Format
const ( PrivacyIndicator uint8 = iota // Privacy Indicator information in a standalone burst VoiceLC // Indicates the beginning of voice transmission, carries addressing information TerminatorWithLC // Indicates the end of transmission, carries LC information CSBK // Carries a control block MultiBlockControl // Header for multi-block control MultiBlockControlContinuation // Follow-on blocks for multi-block control Data // Carries addressing and numbering of packet data blocks Rate12Data // Payload for rate 1/2 packet data Rate34Data // Payload for rate 3⁄4 packet data Idle // Fills channel when no info to transmit VoiceBurstA // Burst A marks the start of a superframe and always contains a voice SYNC pattern VoiceBurstB // Bursts B to F carry embedded signalling in place of the SYNC pattern VoiceBurstC // Bursts B to F carry embedded signalling in place of the SYNC pattern VoiceBurstD // Bursts B to F carry embedded signalling in place of the SYNC pattern VoiceBurstE // Bursts B to F carry embedded signalling in place of the SYNC pattern VoiceBurstF // Bursts B to F carry embedded signalling in place of the SYNC pattern IPSCSync UnknownSlotType )
Data Type information element definitions, DMR Air Interface (AI) protocol, Table 6.1
const ( CallTypePrivate uint8 = iota CallTypeGroup )
Call Type
const ( SyncPatternBSSourcedVoice uint8 = iota SyncPatternBSSourcedData SyncPatternMSSourcedVoice SyncPatternMSSourcedData SyncPatternMSSourcedRC SyncPatternDirectVoiceTS1 SyncPatternDirectDataTS1 SyncPatternDirectVoiceTS2 SyncPatternDirectDataTS2 SyncPatternUnknown )
Table 9.2: SYNC Patterns
const ( SingleFragment uint8 = iota FirstFragment LastFragment Continuation )
EMB LCSS fragments.
const (
// n_DFragMax, see DMR AI spec. page 163.
MaxPacketFragmentSize = 1500
)
Variables ¶
var ( Version = "0.2.1" // Version number SoftwareID = fmt.Sprintf("%s go-dmr %s", Version, runtime.GOOS) // Software identifier PackageID = fmt.Sprintf("%s/%s", SoftwareID, runtime.GOARCH) // Package identifier )
var CallTypeName = map[uint8]string{ CallTypePrivate: "private", CallTypeGroup: "group", }
var DDFormatName = map[uint8]string{ DDFormatBinary: "binary", DDFormatBCD: "BCD", DDFormat7BitChar: "7-bit characters", DDFormat8BitISO8859_1: "8-bit ISO 8859-1", DDFormat8BitISO8859_2: "8-bit ISO 8859-2", DDFormat8BitISO8859_3: "8-bit ISO 8859-3", DDFormat8BitISO8859_4: "8-bit ISO 8859-4", DDFormat8BitISO8859_5: "8-bit ISO 8859-5", DDFormat8BitISO8859_6: "8-bit ISO 8859-6", DDFormat8BitISO8859_7: "8-bit ISO 8859-7", DDFormat8BitISO8859_8: "8-bit ISO 8859-8", DDFormat8BitISO8859_9: "8-bit ISO 8859-9", DDFormat8BitISO8859_10: "8-bit ISO 8859-10", DDFormat8BitISO8859_11: "8-bit ISO 8859-11", DDFormat8BitISO8859_13: "8-bit ISO 8859-13", DDFormat8BitISO8859_14: "8-bit ISO 8859-14", DDFormat8BitISO8859_15: "8-bit ISO 8859-15", DDFormat8BitISO8859_16: "8-bit ISO 8859-16", DDFormatUTF8: "UTF-8", DDFormatUTF16: "UTF-16", DDFormatUTF16BE: "UTF-16 big endian", DDFormatUTF16LE: "UTF-16 little endian", DDFormatUTF32: "UTF-32", DDFormatUTF32BE: "UTF-32 big endian", DDFormatUTF32LE: "UTF-32 little endian", }
var DataTypeName = map[uint8]string{ PrivacyIndicator: "privacy indicator", VoiceLC: "voice LC", TerminatorWithLC: "terminator with LC", CSBK: "control block", MultiBlockControl: "multi-block control", MultiBlockControlContinuation: "multi-block control follow-on", Data: "data", Rate12Data: "rate ½ packet data", Rate34Data: "rate ¾ packet data", Idle: "idle", VoiceBurstA: "voice (burst A)", VoiceBurstB: "voice (burst B)", VoiceBurstC: "voice (burst C)", VoiceBurstD: "voice (burst D)", VoiceBurstE: "voice (burst E)", VoiceBurstF: "voice (burst F)", IPSCSync: "IPSC sync", UnknownSlotType: "uknown", }
var LCSSName = map[uint8]string{ SingleFragment: "single fragment", FirstFragment: "first fragment", LastFragment: "last fragment", Continuation: "continuation", }
LCSSName is a map of LCSS fragment type to string.
var ManufacturerName = map[uint8]string{
0x00: "Reserved",
0x01: "Reserved",
0x02: "Reserved",
0x03: "Reserved",
0x04: "Flyde Micro Ltd.",
0x05: "PROD-EL SPA",
0x06: "Trident Datacom DBA Trident Micro Systems",
0x07: "RADIODATA GmbH",
0x08: "HYT science tech",
0x09: "ASELSAN Elektronik Sanayi ve Ticaret A.S.",
0x0a: "Kirisun Communications Co. Ltd",
0x0b: "DMR Association Ltd.",
0x10: "Motorola Ltd.",
0x13: "EMC S.p.A. (Electronic Marketing Company)",
0x1c: "EMC S.p.A. (Electronic Marketing Company)",
0x20: "JVCKENWOOD Corporation",
0x33: "Radio Activity Srl",
0x3c: "Radio Activity Srl",
0x58: "Tait Electronics Ltd",
0x68: "HYT science tech",
0x77: "Vertex Standard",
}
http://www.etsi.org/images/files/DMRcodes/dmrs-mfid.xls
var ResponseTypeName = map[uint8]string{ ResponseTypeACK: "ACK", ResponseTypeIllegalFormat: "illegal format", ResponseTypePacketCRCFailed: "packet CRC failed", ResponseTypeMemoryFull: "memory full", ResponseTypeRecvFSVNOutOfSeq: "recv FSN out of sequence", ResponseTypeUndeliverable: "undeliverable", ResponseTypeRecvPktOutOfSeq: "recv PKT our of sequence", ResponseTypeDisallowed: "disallowed", ResponseTypeSelectiveACK: "selective ACK", }
var ServiceAccessPointName = map[uint8]string{ ServiceAccessPointUDT: "UDT", ServiceAccessPointTCPIPHeaderCompression: "TCP/IP header compression", ServiceAccessPointUDPIPHeaderCompression: "UDP/IP header compression", ServiceAccessPointIPBasedPacketData: "IP based packet data", ServiceAccessPointARP: "ARP", ServiceAccessPointProprietaryData: "proprietary data", ServiceAccessPointShortData: "short data", }
var ( SyncPatternName = map[uint8]string{ SyncPatternBSSourcedVoice: "bs sourced voice", SyncPatternBSSourcedData: "bs sourced data", SyncPatternMSSourcedVoice: "ms sourced voice", SyncPatternMSSourcedData: "ms sourced data", SyncPatternMSSourcedRC: "ms sourced rc", SyncPatternDirectVoiceTS1: "direct voice ts1", SyncPatternDirectDataTS1: "direct data ts1", SyncPatternDirectVoiceTS2: "direct voice ts2", SyncPatternDirectDataTS2: "direct data ts2", SyncPatternUnknown: "unknown", } )
var UDTFormatName = map[uint8]string{ UDTFormatBinary: "binary", UDTFormatMSAddress: "MS address", UDTFormat4BitBCD: "4-bit BCD", UDTFormatISO_7BitChars: "ISO 7-bit characters", UDTFormatISO_8BitChars: "ISO 8-bit characters", UDTFormatNMEALocation: "NMEA location", UDTFormatIPAddress: "IP address", UDTFormat16BitUnicodeChars: "16-bit Unicode characters", UDTFormatCustomCodeD1: "custom code D1", UDTFormatCustomCodeD2: "custom code D2", }
Functions ¶
func BitsToBytes ¶
BitsToBytes converts a byte slice of bits to a byte slice.
func BuildMessageData ¶
func BytesToBits ¶
BytesToBits converts a byte slice to a byte slice representing the individual data bits.
func ParseEMBBitsFromSync ¶
ParseEMBBitsFromSync extracts the embedded signalling bits from the SYNC bits.
func ParseEmbeddedSignallingLCFromSyncBits ¶
ParseEmbeddedSignallingLCFromSyncBits extracts the embedded signalling LC from the SYNC bits.
func ParseMessageData ¶
func SyncPattern ¶
Types ¶
type ConfirmedData ¶
type ConfirmedData struct { PadOctetCount uint8 FullMessage bool BlocksToFollow uint8 Resync bool SendSequenceNumber uint8 FragmentSequenceNumber uint8 }
func (ConfirmedData) String ¶
func (d ConfirmedData) String() string
func (ConfirmedData) Write ¶
func (d ConfirmedData) Write(data []byte) error
type ControlBlock ¶
type ControlBlock struct { CRC uint16 Last bool Opcode uint8 SrcID, DstID uint32 Data ControlBlockData }
func ParseControlBlock ¶
func ParseControlBlock(data []byte) (*ControlBlock, error)
func (*ControlBlock) Bytes ¶
func (cb *ControlBlock) Bytes() ([]byte, error)
func (*ControlBlock) String ¶
func (cb *ControlBlock) String() string
type ControlBlockData ¶
type DataBlock ¶
func ParseDataBlock ¶
type DataFragment ¶
func CombineDataBlocks ¶
func CombineDataBlocks(blocks []*DataBlock) (*DataFragment, error)
func (*DataFragment) DataBlocks ¶
func (df *DataFragment) DataBlocks(dataType uint8, confirm bool) ([]*DataBlock, error)
type DataHeader ¶
type DataHeader struct { PacketFormat uint8 DstIsGroup bool ResponseRequested bool HeaderCompression bool ServiceAccessPoint uint8 DstID uint32 SrcID uint32 CRC uint16 Data DataHeaderData }
func ParseDataHeader ¶
func ParseDataHeader(data []byte, proprietary bool) (*DataHeader, error)
func (*DataHeader) Bytes ¶
func (h *DataHeader) Bytes() ([]byte, error)
func (DataHeader) String ¶
func (h DataHeader) String() string
type DataHeaderData ¶
type EmbeddedSignallingLC ¶
EmbeddedSignallingLC contains the embedded signalling LC and checksum.
func DeinterleaveEmbeddedSignallingLC ¶
func DeinterleaveEmbeddedSignallingLC(bits []byte) (*EmbeddedSignallingLC, error)
DeinterleaveEmbeddedSignallingLC deinterleaves the embedded signalling LC bits.
func (*EmbeddedSignallingLC) Check ¶
func (eslc *EmbeddedSignallingLC) Check() bool
Check verifies the checksum in the embedded signalling LC.
func (*EmbeddedSignallingLC) Interleave ¶
func (eslc *EmbeddedSignallingLC) Interleave() []byte
Interleave packs the embedded signalling LC to interleaved bits.
type NegativeAcknowledgeResponse ¶
func (*NegativeAcknowledgeResponse) Parse ¶
func (d *NegativeAcknowledgeResponse) Parse(data []byte) error
func (*NegativeAcknowledgeResponse) String ¶
func (d *NegativeAcknowledgeResponse) String() string
func (*NegativeAcknowledgeResponse) Write ¶
func (d *NegativeAcknowledgeResponse) Write(data []byte) error
type OutboundActivation ¶
type OutboundActivation struct{}
func (*OutboundActivation) Parse ¶
func (d *OutboundActivation) Parse(data []byte) error
func (*OutboundActivation) String ¶
func (d *OutboundActivation) String() string
func (*OutboundActivation) Write ¶
func (d *OutboundActivation) Write(data []byte) error
type Packet ¶
type Packet struct { // 0 for slot 1, 1 for slot 2 Timeslot uint8 // Starts at zero for each incoming transmission, wraps back to zero when 256 is reached Sequence uint8 // Source and destination DMR ID SrcID uint32 DstID uint32 // 3 bytes registered DMR-ID for public repeaters, 4 bytes for private repeaters RepeaterID uint32 // Random or incremented number which stays the same from PTT-press to PTT-release which identifies a stream StreamID uint32 // Data Type or Slot type DataType uint8 // 0 for group call, 1 for unit to unit CallType uint8 // The on-air DMR data with possible FEC fixes to the AMBE data and/or Slot Type and/or EMB, etc Data []byte // 34 bytes Bits []byte // 264 bits }
Packet represents a frame transported by the Air Interface
func (*Packet) SlotTypeBits ¶
SlotTypeBits returns the SloT Type bits
type PacketFunc ¶
PacketFunc is a callback function that handles DMR packets
type ProprietaryData ¶
type ProprietaryData struct {
ManufacturerID uint8
}
func (ProprietaryData) String ¶
func (d ProprietaryData) String() string
func (ProprietaryData) Write ¶
func (d ProprietaryData) Write(data []byte) error
type Repeater ¶
type Repeater interface { Active() bool Close() error ListenAndServe() error Send(*Packet) error GetPacketFunc() PacketFunc SetPacketFunc(PacketFunc) }
Repeater implements a repeater station.
type ResponseData ¶
type ResponseData struct { BlocksToFollow uint8 ClassType uint8 // See ResponseType map above Status uint8 }
func (ResponseData) String ¶
func (d ResponseData) String() string
func (ResponseData) Write ¶
func (d ResponseData) Write(data []byte) error
type ShortDataDefinedData ¶
type ShortDataDefinedData struct { AppendedBlocks uint8 DDFormat uint8 Resync bool FullMessage bool BitPadding uint8 }
func (ShortDataDefinedData) String ¶
func (d ShortDataDefinedData) String() string
func (ShortDataDefinedData) Write ¶
func (d ShortDataDefinedData) Write(data []byte) error
type ShortDataRawData ¶
type ShortDataRawData struct { AppendedBlocks uint8 SrcPort uint8 DstPort uint8 Resync bool FullMessage bool BitPadding uint8 }
func (ShortDataRawData) String ¶
func (d ShortDataRawData) String() string
func (ShortDataRawData) Write ¶
func (d ShortDataRawData) Write(data []byte) error
type UDTData ¶
type UnconfirmedData ¶
type UnconfirmedData struct { PadOctetCount uint8 FullMessage bool BlocksToFollow uint8 FragmentSequenceNumber uint8 }
func (UnconfirmedData) String ¶
func (d UnconfirmedData) String() string
func (UnconfirmedData) Write ¶
func (d UnconfirmedData) Write(data []byte) error
type UnitToUnitVoiceServiceAnswerResponse ¶
func (*UnitToUnitVoiceServiceAnswerResponse) Parse ¶
func (d *UnitToUnitVoiceServiceAnswerResponse) Parse(data []byte) error
func (*UnitToUnitVoiceServiceAnswerResponse) String ¶
func (d *UnitToUnitVoiceServiceAnswerResponse) String() string
func (*UnitToUnitVoiceServiceAnswerResponse) Write ¶
func (d *UnitToUnitVoiceServiceAnswerResponse) Write(data []byte) error
type UnitToUnitVoiceServiceRequest ¶
type UnitToUnitVoiceServiceRequest struct {
Options uint8
}
func (*UnitToUnitVoiceServiceRequest) Parse ¶
func (d *UnitToUnitVoiceServiceRequest) Parse(data []byte) error
func (*UnitToUnitVoiceServiceRequest) String ¶
func (d *UnitToUnitVoiceServiceRequest) String() string
func (*UnitToUnitVoiceServiceRequest) Write ¶
func (d *UnitToUnitVoiceServiceRequest) Write(data []byte) error
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
crc
|
|
crc16
Package crc16 implements the 16-bit cyclic redundancy check, or CRC-16, checksum.
|
Package crc16 implements the 16-bit cyclic redundancy check, or CRC-16, checksum. |
quadres_16_7
Package quadres_16_7 implements the quadratic residue (16, 7, 6) parity check.
|
Package quadres_16_7 implements the quadratic residue (16, 7, 6) parity check. |
Package homebrew implements the Home Brew DMR IPSC protocol
|
Package homebrew implements the Home Brew DMR IPSC protocol |
Package ipsc implements the Motorola IP Site Connect protocol.
|
Package ipsc implements the Motorola IP Site Connect protocol. |
Package vbptc implements the Variable length BPTC for embedded signalling
|
Package vbptc implements the Variable length BPTC for embedded signalling |