|
@ -79,6 +79,10 @@ func main() { |
|
|
MinSize:Size{Width:maxWidth*3/5}, |
|
|
MinSize:Size{Width:maxWidth*3/5}, |
|
|
ColumnsOrderable: true, |
|
|
ColumnsOrderable: true, |
|
|
MultiSelection: true, |
|
|
MultiSelection: true, |
|
|
|
|
|
ContextMenuItems:[]MenuItem{ |
|
|
|
|
|
Action{Text:"查看终端数据", OnTriggered: mw.tvItemActivated}, |
|
|
|
|
|
Action{Text:"查看网关数据", OnTriggered: mw.tvItemGatewayActivated}, |
|
|
|
|
|
}, |
|
|
Columns: []TableViewColumn{ |
|
|
Columns: []TableViewColumn{ |
|
|
{Title: "序号"}, |
|
|
{Title: "序号"}, |
|
|
{Title: "数据方向"}, |
|
|
{Title: "数据方向"}, |
|
@ -613,6 +617,7 @@ func (mw *MoteMainWindow) HandleData(client paho.Client, message paho.Message){ |
|
|
var origData bytes.Buffer |
|
|
var origData bytes.Buffer |
|
|
jsonData,_ := phy.MarshalJSON() |
|
|
jsonData,_ := phy.MarshalJSON() |
|
|
_ = json.Indent(&origData, jsonData, "", " ") |
|
|
_ = json.Indent(&origData, jsonData, "", " ") |
|
|
|
|
|
d,_ := json.MarshalIndent(&downlinkFrame,""," ") |
|
|
dd := &Mote{ |
|
|
dd := &Mote{ |
|
|
Index: mw.model.Len() + 1, |
|
|
Index: mw.model.Len() + 1, |
|
|
Direction: "downlink", |
|
|
Direction: "downlink", |
|
@ -621,7 +626,8 @@ func (mw *MoteMainWindow) HandleData(client paho.Client, message paho.Message){ |
|
|
MType: phy.MHDR.MType.String(), |
|
|
MType: phy.MHDR.MType.String(), |
|
|
GatewayID: hex.EncodeToString(downlinkFrame.TxInfo.GatewayId), |
|
|
GatewayID: hex.EncodeToString(downlinkFrame.TxInfo.GatewayId), |
|
|
Time: time.Now().Format("2006-01-02 15:04:05"), |
|
|
Time: time.Now().Format("2006-01-02 15:04:05"), |
|
|
OrigData:origData.String(), |
|
|
MoteOrigData: origData.String(), |
|
|
|
|
|
GatewayOrigData: string(d), |
|
|
} |
|
|
} |
|
|
if phy.MHDR.MType == lorawan.ConfirmedDataDown || phy.MHDR.MType == lorawan.UnconfirmedDataDown { |
|
|
if phy.MHDR.MType == lorawan.ConfirmedDataDown || phy.MHDR.MType == lorawan.UnconfirmedDataDown { |
|
|
mpl := phy.MACPayload.(*lorawan.MACPayload) |
|
|
mpl := phy.MACPayload.(*lorawan.MACPayload) |
|
@ -717,9 +723,11 @@ func (mw *MoteMainWindow) sendMsg() error{ |
|
|
walk.MsgBox(mw, "错误", msg, walk.MsgBoxIconError) |
|
|
walk.MsgBox(mw, "错误", msg, walk.MsgBoxIconError) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
frames,_:= packet.GetUplinkFrames(true,false) |
|
|
var origData bytes.Buffer |
|
|
var origData bytes.Buffer |
|
|
jsonData,_ := phy.MarshalJSON() |
|
|
jsonData,_ := phy.MarshalJSON() |
|
|
_ = json.Indent(&origData, jsonData, "", " ") |
|
|
_ = json.Indent(&origData, jsonData, "", " ") |
|
|
|
|
|
d,_ := json.MarshalIndent(&frames[0],""," ") |
|
|
du := &Mote{ |
|
|
du := &Mote{ |
|
|
Index: mw.model.Len() + 1, |
|
|
Index: mw.model.Len() + 1, |
|
|
Direction: "uplink", |
|
|
Direction: "uplink", |
|
@ -730,12 +738,13 @@ func (mw *MoteMainWindow) sendMsg() error{ |
|
|
LoRaSNR: packet.Payload.RXPK[0].LSNR, |
|
|
LoRaSNR: packet.Payload.RXPK[0].LSNR, |
|
|
Frequency: packet.Payload.RXPK[0].Freq, |
|
|
Frequency: packet.Payload.RXPK[0].Freq, |
|
|
Time: time.Now().Format("2006-01-02 15:04:05"), |
|
|
Time: time.Now().Format("2006-01-02 15:04:05"), |
|
|
OrigData:origData.String(), |
|
|
MoteOrigData: origData.String(), |
|
|
|
|
|
GatewayOrigData:string(d), |
|
|
} |
|
|
} |
|
|
mw.model.Items = append(mw.model.Items, du) |
|
|
mw.model.Items = append(mw.model.Items, du) |
|
|
mw.model.PublishRowsReset() |
|
|
mw.model.PublishRowsReset() |
|
|
_ = mw.tv.SetSelectedIndexes([]int{}) |
|
|
_ = mw.tv.SetSelectedIndexes([]int{}) |
|
|
frames,_:= packet.GetUplinkFrames(true,false) |
|
|
|
|
|
for j := range frames { |
|
|
for j := range frames { |
|
|
mw.PushData(mw.currentMoteConf.GatewayEui,"up",&frames[j]) |
|
|
mw.PushData(mw.currentMoteConf.GatewayEui,"up",&frames[j]) |
|
|
} |
|
|
} |
|
@ -775,9 +784,11 @@ func (mw *MoteMainWindow) sendMsg() error{ |
|
|
walk.MsgBox(mw, "错误", msg, walk.MsgBoxIconError) |
|
|
walk.MsgBox(mw, "错误", msg, walk.MsgBoxIconError) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
frames,_:= packet.GetUplinkFrames(true,false) |
|
|
var origData bytes.Buffer |
|
|
var origData bytes.Buffer |
|
|
jsonData,_ := phy.MarshalJSON() |
|
|
jsonData,_ := phy.MarshalJSON() |
|
|
_ = json.Indent(&origData, jsonData, "", " ") |
|
|
_ = json.Indent(&origData, jsonData, "", " ") |
|
|
|
|
|
d,_ := json.MarshalIndent(&frames[0],""," ") |
|
|
du := &Mote{ |
|
|
du := &Mote{ |
|
|
Index: mw.model.Len() + 1, |
|
|
Index: mw.model.Len() + 1, |
|
|
Direction: "uplink", |
|
|
Direction: "uplink", |
|
@ -793,12 +804,12 @@ func (mw *MoteMainWindow) sendMsg() error{ |
|
|
HexData: hex.EncodeToString(bmsg), |
|
|
HexData: hex.EncodeToString(bmsg), |
|
|
AsciiData: BytesToString(bmsg), |
|
|
AsciiData: BytesToString(bmsg), |
|
|
Time: time.Now().Format("2006-01-02 15:04:05"), |
|
|
Time: time.Now().Format("2006-01-02 15:04:05"), |
|
|
OrigData:origData.String(), |
|
|
MoteOrigData: origData.String(), |
|
|
|
|
|
GatewayOrigData:string(d), |
|
|
} |
|
|
} |
|
|
mw.model.Items = append(mw.model.Items, du) |
|
|
mw.model.Items = append(mw.model.Items, du) |
|
|
mw.model.PublishRowsReset() |
|
|
mw.model.PublishRowsReset() |
|
|
_ = mw.tv.SetSelectedIndexes([]int{}) |
|
|
_ = mw.tv.SetSelectedIndexes([]int{}) |
|
|
frames,_:= packet.GetUplinkFrames(true,false) |
|
|
|
|
|
for j := range frames { |
|
|
for j := range frames { |
|
|
mw.PushData(mw.currentMoteConf.GatewayEui,"up",&frames[j]) |
|
|
mw.PushData(mw.currentMoteConf.GatewayEui,"up",&frames[j]) |
|
|
} |
|
|
} |
|
@ -849,7 +860,19 @@ func (mw *MoteMainWindow) TimeSend() { |
|
|
func (mw *MoteMainWindow) tvItemActivated() { |
|
|
func (mw *MoteMainWindow) tvItemActivated() { |
|
|
msg := "" |
|
|
msg := "" |
|
|
for _, i := range mw.tv.SelectedIndexes() { |
|
|
for _, i := range mw.tv.SelectedIndexes() { |
|
|
msg += mw.model.Items[i].OrigData + "\n" |
|
|
msg += mw.model.Items[i].MoteOrigData + "\n" |
|
|
|
|
|
} |
|
|
|
|
|
_ = mw.data.SetText(strings.Replace(msg, "\n", "\r\n", -1)) |
|
|
|
|
|
|
|
|
|
|
|
m := make(map[string]interface{}) |
|
|
|
|
|
if err := json.Unmarshal([]byte(msg), &m); err == nil { |
|
|
|
|
|
_ = mw.jsonView.SetModel(NewJSONModel(m)) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
func (mw *MoteMainWindow) tvItemGatewayActivated() { |
|
|
|
|
|
msg := "" |
|
|
|
|
|
for _, i := range mw.tv.SelectedIndexes() { |
|
|
|
|
|
msg += mw.model.Items[i].GatewayOrigData + "\n" |
|
|
} |
|
|
} |
|
|
_ = mw.data.SetText(strings.Replace(msg, "\n", "\r\n", -1)) |
|
|
_ = mw.data.SetText(strings.Replace(msg, "\n", "\r\n", -1)) |
|
|
|
|
|
|
|
|