-
Notifications
You must be signed in to change notification settings - Fork 26
/
sync.go
69 lines (65 loc) · 2.13 KB
/
sync.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package dmr
import (
"bytes"
)
// Table 9.2: SYNC Patterns
const (
SyncPatternBSSourcedVoice uint8 = iota
SyncPatternBSSourcedData
SyncPatternMSSourcedVoice
SyncPatternMSSourcedData
SyncPatternMSSourcedRC
SyncPatternDirectVoiceTS1
SyncPatternDirectDataTS1
SyncPatternDirectVoiceTS2
SyncPatternDirectDataTS2
SyncPatternUnknown
)
var (
bsSourcedVoice = []byte{0x75, 0x5f, 0xd7, 0xdf, 0x75, 0xf7}
bsSourcedData = []byte{0xdf, 0xf5, 0x7d, 0x75, 0xdf, 0x5d}
msSourcedVoice = []byte{0x7f, 0x7d, 0x5d, 0xd5, 0x7d, 0xfd}
msSourcedData = []byte{0xd5, 0xd7, 0xf7, 0x7f, 0xd7, 0x57}
msSourcedRC = []byte{0x77, 0xd5, 0x5f, 0x7d, 0xfd, 0x77}
directVoiceTS1 = []byte{0x5d, 0x57, 0x7f, 0x77, 0x57, 0xff}
directDataTS1 = []byte{0xf7, 0xfd, 0xd5, 0xdd, 0xfd, 0x55}
directVoiceTS2 = []byte{0x7d, 0xff, 0xd5, 0xf5, 0x5d, 0x5f}
directDataTS2 = []byte{0xd7, 0x55, 0x7f, 0x5f, 0xf7, 0xf5}
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",
}
)
func SyncPattern(bits []byte) uint8 {
var b = BitsToBytes(bits)
switch {
case bytes.Equal(b, bsSourcedVoice):
return SyncPatternBSSourcedVoice
case bytes.Equal(b, bsSourcedData):
return SyncPatternBSSourcedData
case bytes.Equal(b, msSourcedVoice):
return SyncPatternMSSourcedVoice
case bytes.Equal(b, msSourcedData):
return SyncPatternMSSourcedData
case bytes.Equal(b, msSourcedRC):
return SyncPatternMSSourcedRC
case bytes.Equal(b, directVoiceTS1):
return SyncPatternDirectVoiceTS1
case bytes.Equal(b, directDataTS1):
return SyncPatternDirectDataTS1
case bytes.Equal(b, directVoiceTS2):
return SyncPatternDirectVoiceTS2
case bytes.Equal(b, directDataTS2):
return SyncPatternDirectDataTS2
default:
return SyncPatternUnknown
}
}