Forráskód Böngészése

fix send heartbeat

dujunchen 1 hete
szülő
commit
c41afb903e

+ 2 - 2
internal/app/ami/action/call.go

@@ -46,7 +46,7 @@ func Dial(src, dst, dialrule, callerID, callerName string, callType string) {
 	lfshook.NewLogger().Info(res)
 }
 
-// ChanSpy
+// PACU ChanSpy
 func ChanSpy(src, dst string, whisper, bargein bool) {
 	lfshook.NewLogger().Infof("chan spy src:%s dst:%s", src, dst)
 
@@ -70,7 +70,7 @@ func ChanSpy(src, dst string, whisper, bargein bool) {
 		"CallerID":    dst,
 		"Async":       "true",
 	}
-	lfshook.NewLogger().Infof("ChanSpy action %+v", action)
+	lfshook.NewLogger().Infof("PACU ChanSpy action %+v", action)
 	_, _, err := AminInstance.Send(action)
 	if err != nil {
 		lfshook.NewLogger().Errorf("%+v", err)

+ 2 - 2
internal/app/stc/broadcast/stc-broadcast.go

@@ -287,7 +287,7 @@ func AlarmHandle(data []byte) {
 	switch handler {
 	case 0x01: //answer(ICP+Alarm+PACU)
 		//NotifyPaiu(exten, "answer")
-		err := action.RedirectInQueue(exten, "0402", "ani-rule", "1") // 1车ICP接听
+		err := action.RedirectInQueue(exten, "0402", "ani-rule", "1") // 1车ICP接听PAIU
 		if err != nil {
 			lfshook.NewLogger().Logger.Infof("================ICP Answer PAD====ERR============ : %+v", err.Error())
 		}
@@ -297,7 +297,7 @@ func AlarmHandle(data []byte) {
 
 	case 0x04: //answer(ICP+Alarm+PACU)
 
-		err := action.RedirectInQueue(exten, "0401", "ano-rule", "1") // 1车OCC接听
+		err := action.RedirectInQueue(exten, "0401", "ano-rule", "1") // 1车OCC接听PAIU
 		if err != nil {
 			//lfshook.NewLogger().Info(err)
 			lfshook.NewLogger().Logger.Infof("================ICP Answer PAD====ERR============ : %+v", err.Error())

+ 3 - 0
internal/app/stc/data/msgdata.go

@@ -33,6 +33,9 @@ func (p *Protocol) Encode() ([]byte, error) {
 	var buf bytes.Buffer // 写入协议开始符
 	buf.Write(p.StartBytes[:])
 
+	//init src and dst ID
+	p.SourceID = 0x02
+	p.DestinationID = 0x01
 	// 写入源设备号、目的设备号和消息号
 	binary.Write(&buf, binary.BigEndian, p.SourceID)
 	binary.Write(&buf, binary.BigEndian, p.DestinationID)

+ 7 - 0
internal/app/stc/index.go

@@ -104,7 +104,12 @@ func controlTCPConn(network, address string, c syscall.RawConn) error {
 
 func Sendheartbeat(ctx context.Context, conn net.Conn) {
 	var count uint8
+
 	protocol := msgdata.NewProtocol()
+	protocol.MessageID = 0x21
+	protocol.DataLength = 0x04
+	protocol.Data = make([]byte, 4)
+
 	// 初始化协议...
 	ticker := time.NewTicker(2 * time.Second)
 	defer ticker.Stop()
@@ -117,6 +122,7 @@ func Sendheartbeat(ctx context.Context, conn net.Conn) {
 
 		case <-ticker.C:
 			count++
+			protocol.Data[0] = count
 			// 编码并发送数据...
 			encoded, err := protocol.Encode()
 			if err != nil {
@@ -130,6 +136,7 @@ func Sendheartbeat(ctx context.Context, conn net.Conn) {
 					conn.Close()
 					return // 触发重连
 				}
+				//lfshook.NewLogger().Logger.Infof("Sendheartbeat===send ======%x", encoded)
 			}
 		}
 	}