mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
优化
This commit is contained in:
@@ -80,15 +80,17 @@ func (hhs *HookTcpService) hook() {
|
||||
hhs.Send("fail")
|
||||
}
|
||||
} else {
|
||||
hexData := hex.EncodeToString(buf[:n])
|
||||
global.Log.Infof("TCP协议 设备%s, 接受消息%s", etoken.DeviceId, hexData)
|
||||
ts := time.Now().Format("2006-01-02 15:04:05.000")
|
||||
data := &netbase.DeviceEventInfo{
|
||||
DeviceId: etoken.DeviceId,
|
||||
DeviceAuth: etoken,
|
||||
Type: message.RowMes,
|
||||
}
|
||||
|
||||
hexData := hex.EncodeToString(buf[:n])
|
||||
global.Log.Infof("TCP协议 设备%s, 接受消息%s", etoken.DeviceId, hexData)
|
||||
ts := time.Now().Format("2006-01-02 15:04:05.000")
|
||||
data.Type = message.RowMes
|
||||
data.Datas = fmt.Sprintf(`{"ts": "%s","rowdata": "%s"}`, ts, hexData)
|
||||
|
||||
// etoken中添加设备标识
|
||||
hhs.HookService.MessageCh <- data
|
||||
}
|
||||
@@ -121,3 +123,8 @@ func (hhs *HookTcpService) SendBytes(msg []byte) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func isHex(str string) bool {
|
||||
_, err := hex.DecodeString(str)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user