diff --git a/controlstream.go b/controlstream.go index 75cb571..c41b98d 100644 --- a/controlstream.go +++ b/controlstream.go @@ -174,7 +174,7 @@ func (s *controlStream) handleRead(r []byte) error { } } case 80: - if bytes.Equal(r[:6], []byte{0x50, 0x00, 0x00, 0x00, 0x00, 0x00}) && bytes.Equal(r[48:51], []byte{0xff, 0xff, 0xff}) { + if bytes.Equal(r[:6], []byte{0x50, 0x00, 0x00, 0x00, 0x00, 0x00}) { // Example answer from radio: 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, // 0x86, 0x1f, 0x2f, 0xcc, 0x03, 0x03, 0x89, 0x29, // 0x00, 0x00, 0x00, 0x40, 0x02, 0x03, 0x00, 0x52, @@ -186,7 +186,12 @@ func (s *controlStream) handleRead(r []byte) error { // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - return errors.New("auth failed") + if bytes.Equal(r[48:51], []byte{0xff, 0xff, 0xff}) { + return errors.New("auth failed") + } + if bytes.Equal(r[48:51], []byte{0x00, 0x00, 0x00}) && r[64] == 0x01 { + return errors.New("got radio disconnected") + } } case 144: if !s.serialAndAudioStreamOpened && bytes.Equal(r[:6], []byte{0x90, 0x00, 0x00, 0x00, 0x00, 0x00}) && r[96] == 1 {