kappanhang/audiostream.go

30 lines
666 B
Go
Raw Normal View History

2020-10-18 10:33:47 +02:00
package main
import (
"encoding/binary"
"github.com/nonoo/kappanhang/log"
)
type audioStream struct {
2020-10-18 11:01:53 +02:00
common streamCommon
2020-10-18 10:33:47 +02:00
}
2020-10-18 13:19:52 +02:00
func (s *audioStream) sendDisconnect() {
s.common.sendDisconnect()
}
func (s *audioStream) start() {
2020-10-18 11:17:40 +02:00
s.common.open("audio", 50003)
2020-10-18 10:33:47 +02:00
2020-10-18 11:01:53 +02:00
s.common.sendPkt3()
2020-10-18 10:33:47 +02:00
// Expecting a Pkt4 answer.
// Example answer from radio: 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x8c, 0x7d, 0x45, 0x7a, 0x1d, 0xf6, 0xe9, 0x0b
2020-10-18 11:01:53 +02:00
r := s.common.expect(16, []byte{0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00})
s.common.remoteSID = binary.BigEndian.Uint32(r[8:12])
s.common.sendPkt6()
2020-10-18 10:33:47 +02:00
2020-10-18 11:01:53 +02:00
log.Debugf("got remote session id %.8x", s.common.remoteSID)
2020-10-18 10:33:47 +02:00
}