Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
kdudkov committed Nov 21, 2023
1 parent d589b05 commit 9b4f784
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
16 changes: 8 additions & 8 deletions pkg/cot/xmlevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ func (e *Event) AddGroup(group, role string) {
return
}

e.AddDetail().AddChild("__group", map[string]string{"name": group, "role": role}, "")
e.AddDetail().AddOrChangeChild("__group", map[string]string{"name": group, "role": role})
}

func (e *Event) AddCallsign(callsign, endpoint string, addDroid bool) {
if e == nil {
return
}

e.AddDetail().AddChild("contact", map[string]string{"callsign": callsign, "endpoint": endpoint}, "")
e.AddDetail().AddOrChangeChild("contact", map[string]string{"callsign": callsign, "endpoint": endpoint})

if addDroid {
e.AddDetail().AddChild("uid", map[string]string{"Droid": callsign}, "")
e.AddDetail().AddOrChangeChild("uid", map[string]string{"Droid": callsign})
}
}

Expand All @@ -67,15 +67,15 @@ func (e *Event) AddTrack(speed, course string) {
return
}

e.AddDetail().AddChild("track", map[string]string{"speed": speed, "course": course}, "")
e.AddDetail().AddOrChangeChild("track", map[string]string{"speed": speed, "course": course})
}

func (e *Event) AddVersion(device, platform, os, version string) {
if e == nil {
return
}

e.AddDetail().AddChild("takv", map[string]string{"device": device, "platform": platform, "os": os, "version": version}, "")
e.AddDetail().AddOrChangeChild("takv", map[string]string{"device": device, "platform": platform, "os": os, "version": version})
}

type Point struct {
Expand Down Expand Up @@ -109,22 +109,22 @@ func VersionSupportMsg(ver int8) *Event {
v := strconv.Itoa(int(ver))
ev := XmlBasicMsg("t-x-takp-v", "protouid", time.Minute)
ev.How = "m-g"
ev.AddDetail().AddChild("TakControl", nil, "").AddChild("TakProtocolSupport", map[string]string{"version": v}, "")
ev.AddDetail().AddOrChangeChild("TakControl", nil).AddOrChangeChild("TakProtocolSupport", map[string]string{"version": v})
return ev
}

func VersionReqMsg(ver int8) *Event {
v := strconv.Itoa(int(ver))
ev := XmlBasicMsg("t-x-takp-q", "protouid", time.Minute)
ev.How = "m-g"
ev.AddDetail().AddChild("TakControl", nil, "").AddChild("TakRequest", map[string]string{"version": v}, "")
ev.AddDetail().AddOrChangeChild("TakControl", nil).AddOrChangeChild("TakRequest", map[string]string{"version": v})
return ev
}

func ProtoChangeOkMsg() *Event {
ev := XmlBasicMsg("t-x-takp-r", "protouid", time.Minute)
ev.How = "m-g"
ev.AddDetail().AddChild("TakControl", nil, "").AddChild("TakResponse", map[string]string{"status": "true"}, "")
ev.AddDetail().AddOrChangeChild("TakControl", nil).AddOrChangeChild("TakResponse", map[string]string{"status": "true"})
return ev
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/model/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func MakeChatMessage(c *ChatMessage) *cotproto.TakMessage {
xd := cot.NewXmlDetails()
xd.AddPpLink(c.FromUid, "", "")

chat := xd.AddChild("__chat", map[string]string{"parent": c.Parent, "groupOwner": "false", "chatroom": c.Chatroom, "senderCallsign": c.From, "id": c.ToUid, "messageId": c.Id}, "")
chat.AddChild("chatgrp", map[string]string{"uid0": c.FromUid, "uid1": c.ToUid, "id": c.ToUid}, "")
chat := xd.AddOrChangeChild("__chat", map[string]string{"parent": c.Parent, "groupOwner": "false", "chatroom": c.Chatroom, "senderCallsign": c.From, "id": c.ToUid, "messageId": c.Id})
chat.AddOrChangeChild("chatgrp", map[string]string{"uid0": c.FromUid, "uid1": c.ToUid, "id": c.ToUid})

xd.AddChild("remarks", map[string]string{"source": "BAO.F.ATAK." + c.FromUid, "to": c.ToUid, "time": t}, html.EscapeString(c.Text))

Expand Down
10 changes: 3 additions & 7 deletions pkg/model/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (w *WebUnit) ToMsg() *cot.CotMessage {
Detail: &cotproto.Detail{
Contact: &cotproto.Contact{Callsign: w.Callsign},
PrecisionLocation: &cotproto.PrecisionLocation{
Geopointsrc: "DTED0",
Geopointsrc: "USER",
Altsrc: "USER",
},
},
Expand All @@ -130,13 +130,9 @@ func (w *WebUnit) ToMsg() *cot.CotMessage {

xd := cot.NewXmlDetails()
if w.ParentUid != "" {
m := map[string]string{"uid": w.ParentUid, "relation": "p-p"}
if w.ParentCallsign != "" {
m["parent_callsign"] = w.ParentCallsign
}
xd.AddChild("link", m, "")
xd.AddPpLink(w.ParentUid, "", w.ParentCallsign)
}
xd.AddChild("status", map[string]string{"readiness": "true"}, "")
xd.AddOrChangeChild("status", map[string]string{"readiness": "true"})
if w.Text != "" {
xd.AddChild("remarks", nil, w.Text)
}
Expand Down

0 comments on commit 9b4f784

Please sign in to comment.