Merge pull request #2 from martinhpedersen/fixes

Some fixes
pull/3/head
tehmaze 6 years ago committed by GitHub
commit 68378f8fb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -284,7 +284,7 @@ func ParseControlBlock(data []byte) (*ControlBlock, error) {
cb.Data = &Preamble{}
break
default:
return nil, fmt.Errorf("dmr: unknown CSBK opcode %#02x (%#06b)", cb.Opcode, cb.Opcode)
return nil, fmt.Errorf("dmr: unknown CSBK opcode %02x (%06b)", cb.Opcode, cb.Opcode)
}
if err := cb.Data.Parse(data); err != nil {

@ -54,6 +54,7 @@ func ParseDataBlock(data []byte, dataType uint8, confirmed bool) (*DataBlock, er
return nil, fmt.Errorf("dmr: block CRC error (%#04x != %#04x)", crc, db.CRC)
}
} else {
db.Data = make([]byte, db.Length)
copy(db.Data, data[:db.Length])
}
@ -163,7 +164,7 @@ func (df *DataFragment) DataBlocks(dataType uint8, confirm bool) ([]*DataBlock,
store := int(block.Length)
if df.Stored-stored < store {
store = df.Stored - store
store = df.Stored - stored
}
copy(block.Data, df.Data[stored:stored+store])
stored += store

@ -222,7 +222,7 @@ func (h *DataHeader) Bytes() ([]byte, error) {
if h.HeaderCompression {
data[0] |= B00100000
}
data[1] = (h.ServiceAccessPoint & B00001111)
data[1] = (h.ServiceAccessPoint << 4) & B11110000
data[2] = uint8(h.DstID >> 16)
data[3] = uint8(h.DstID >> 8)
data[4] = uint8(h.DstID)
@ -350,7 +350,7 @@ type ResponseData struct {
}
func (d ResponseData) String() string {
return fmt.Sprintf("response, blocks %d, type %s (%#02b %#03b), status %d",
return fmt.Sprintf("response, blocks %d, type %s (%02b %03b), status %d",
d.BlocksToFollow, ResponseTypeName[d.ClassType], (d.ClassType >> 3), (d.ClassType & 0x07), d.Status)
}

@ -211,7 +211,7 @@ func TestDataHeaderShortDataDefined(t *testing.T) {
t.Fatalf("decode failed: appended blocks wrong")
case d.DDFormat != DDFormatUTF16:
t.Fatalf("decode failed: dd format wrong, expected UTF-16, got %d", DDFormatName[d.DDFormat])
t.Fatalf("decode failed: dd format wrong, expected UTF-16, got %s", DDFormatName[d.DDFormat])
case d.Resync:
t.Fatalf("decode failed: rsync bit wrong")

@ -254,7 +254,8 @@ func (h *Homebrew) WriteToPeerWithID(b []byte, id uint32) error {
}
func (h *Homebrew) checkRepeaterID(id []byte) bool {
return id != nil && bytes.Equal(id, h.id)
// BrandMeister release 20190421-185653 switched from upper case to lower case hex digits
return id != nil && bytes.EqualFold(id, h.id)
}
func (h *Homebrew) getPeer(id uint32) *Peer {

Loading…
Cancel
Save