Browse Source

改用tabpage的高级设置,及改为数据绑定方式

master
lihua 5 years ago
parent
commit
14e0bab78e
  1. 20
      LoRaMoteConf.json
  2. 335
      LoRaMoteMock.go
  3. 34
      model.go

20
LoRaMoteConf.json

@ -3,15 +3,15 @@
"configs": { "configs": {
"mote1": { "mote1": {
"otaa": true, "otaa": true,
"gatewayId": "0102030405060708", "gatewayEui": "0102030405060708",
"appEui": "0102030405060708", "appEui": "0102030405060708",
"devEui": "b92fd5d497cfcdbd", "devEui": "b92fd5d497cfcdbd",
"devAddr": "00530747", "devAddr": "013adb35",
"appKey": "fe80c1f94e6cc62d5d6f72630b43c177", "appKey": "fe80c1f94e6cc62d5d6f72630b43c177",
"nwkSKey": "4f862983a453cc50336284fd3c62aba5", "nwkSKey": "75153208348c4cca9b30d44c889fd52c",
"appSKey": "2bc9217655160b2c1229b5ecb469242f", "appSKey": "3cd17c408b5496756bcd122c9b0b318f",
"fCnt": 513, "fCnt": 7,
"fPort": 1, "fPort": 2,
"freq": 470.3, "freq": 470.3,
"dr": 0, "dr": 0,
"chan": 0, "chan": 0,
@ -28,17 +28,17 @@
}, },
"mote2": { "mote2": {
"otaa": false, "otaa": false,
"gatewayId": "0102030405060708", "gatewayEui": "0102030405060708",
"appEui": "0102030405060708", "appEui": "0102030405060708",
"devEui": "6ef1881ba5541419", "devEui": "6ef1881ba5541419",
"devAddr": "00c18699", "devAddr": "00c18699",
"appKey": "", "appKey": "fe80c1f94e6cc62d5d6f72630b43c177",
"nwkSKey": "33998df974421457437d986eff739ffa", "nwkSKey": "33998df974421457437d986eff739ffa",
"appSKey": "33998df974421457437d986eff739ffa", "appSKey": "33998df974421457437d986eff739ffa",
"fCnt": 1293, "fCnt": 1295,
"fPort": 1, "fPort": 1,
"freq": 470.3, "freq": 470.3,
"dr": 0, "dr": 1,
"chan": 0, "chan": 0,
"lsnr": 7, "lsnr": 7,
"rssi": -50, "rssi": -50,

335
LoRaMoteMock.go

@ -68,8 +68,7 @@ func main() {
PushButton{Text:"断开连接", AssignTo:&mw.disconnect, Enabled:false, OnClicked: mw.Disconnect}, PushButton{Text:"断开连接", AssignTo:&mw.disconnect, Enabled:false, OnClicked: mw.Disconnect},
CheckBox{Text:"开启SSL/TLS",AssignTo:&mw.ssl,OnClicked:mw.SSL}, CheckBox{Text:"开启SSL/TLS",AssignTo:&mw.ssl,OnClicked:mw.SSL},
PushButton{Text:"证书配置",Enabled:false,AssignTo:&mw.caConf,OnClicked: mw.ConnectConfig}, PushButton{Text:"证书配置",Enabled:false,AssignTo:&mw.caConf,OnClicked: mw.ConnectConfig},
PushButton{Text:"终端基本配置",OnClicked: mw.MoteConfig}, PushButton{Text:"终端配置",OnClicked: mw.MoteConfig},
PushButton{Text:"终端高级配置",OnClicked: mw.MoteAdvancedConfig},
PushButton{Text:"清空数据",OnClicked: mw.Clean}, PushButton{Text:"清空数据",OnClicked: mw.Clean},
}, },
}, },
@ -166,7 +165,15 @@ func main() {
_ = mw.username.SetText(mw.connConf.Username) _ = mw.username.SetText(mw.connConf.Username)
_ = mw.password.SetText(mw.connConf.Password) _ = mw.password.SetText(mw.connConf.Password)
} }
//default
mw.currentMoteConf.AppEui = "0102030405060708" mw.currentMoteConf.AppEui = "0102030405060708"
mw.currentMoteConf.MType = uint8(lorawan.UnconfirmedDataUp)
mw.currentMoteConf.FPort = 1
mw.currentMoteConf.Freq = 470.3
mw.currentMoteConf.RSSI = -50
mw.currentMoteConf.LSNR = 7
mw.currentMoteConf.FCtrl.ADR = true
mw.moteConfFileName = dir + "/LoRaMoteConf.json" mw.moteConfFileName = dir + "/LoRaMoteConf.json"
mw.motesConf.Configs = make(map[string]MoteConfig) mw.motesConf.Configs = make(map[string]MoteConfig)
data, err = ioutil.ReadFile(mw.moteConfFileName) data, err = ioutil.ReadFile(mw.moteConfFileName)
@ -182,11 +189,13 @@ func main() {
go mw.ConnectCheck() go mw.ConnectCheck()
mw.Run() mw.Run()
var confData bytes.Buffer if mw.motesConf.Current != "" {
mw.motesConf.Configs[mw.motesConf.Current] = mw.currentMoteConf var confData bytes.Buffer
d,_ := json.Marshal(&mw.motesConf) mw.motesConf.Configs[mw.motesConf.Current] = mw.currentMoteConf
_ = json.Indent(&confData, d, "", "\t") d,_ := json.Marshal(&mw.motesConf)
_ = ioutil.WriteFile(mw.moteConfFileName,confData.Bytes(),0644) _ = json.Indent(&confData, d, "", "\t")
_ = ioutil.WriteFile(mw.moteConfFileName,confData.Bytes(),0644)
}
} }
func (mw *MoteMainWindow) ConnectCheck() { func (mw *MoteMainWindow) ConnectCheck() {
@ -276,66 +285,107 @@ func (mw *MoteMainWindow) MoteConfig() {
var dlg *walk.Dialog var dlg *walk.Dialog
var name *walk.ComboBox var name *walk.ComboBox
var otaa *walk.CheckBox var otaa *walk.CheckBox
var gatewayId,appEUI,devEUI,devAddr,appKey,appSKey,nwkSKey *walk.LineEdit
var fCnt *walk.NumberEdit
var acceptPB, cancelPB *walk.PushButton var acceptPB, cancelPB *walk.PushButton
var db *walk.DataBinder
_ = Dialog{ _ = Dialog{
Title: "终端配置", Title: "终端配置",
Icon: mw.icon, Icon: mw.icon,
Layout: VBox{}, Layout: VBox{},
AssignTo: &dlg, AssignTo: &dlg,
DataBinder: DataBinder{
AssignTo:&db,
Name:"config",
DataSource: &mw.currentMoteConf,
ErrorPresenter: ToolTipErrorPresenter{},
},
DefaultButton: &acceptPB, DefaultButton: &acceptPB,
CancelButton: &cancelPB, CancelButton: &cancelPB,
MinSize: Size{400, 200}, MinSize: Size{400, 200},
Children: []Widget{ Children: []Widget{
Composite{ TabWidget{
Layout:Grid{Columns: 2}, Pages:[]TabPage{
Children:[]Widget{ {
Label{Text: "终端名称:"}, Title:"基础配置",
ComboBox{AssignTo: &name,Editable: true,OnCurrentIndexChanged: func() { Layout:Grid{Columns: 2},
mw.motesConf.Current = name.Text() Children:[]Widget{
mw.currentMoteConf = mw.motesConf.Configs[mw.motesConf.Current] Label{Text: "配置名称:"},
otaa.SetChecked(mw.currentMoteConf.OTAA) ComboBox{AssignTo: &name,Editable: true, OnCurrentIndexChanged: func() {
_ = gatewayId.SetText(mw.currentMoteConf.GatewayId) mw.motesConf.Current = name.Text()
_ = devEUI.SetText(mw.currentMoteConf.DevEui) mw.currentMoteConf = mw.motesConf.Configs[mw.motesConf.Current]
_ = devAddr.SetText(mw.currentMoteConf.DevAddr) _ = db.Reset()
_ = appKey.SetText(mw.currentMoteConf.AppKey) }},
_ = appSKey.SetText(mw.currentMoteConf.AppSKey) Label{Text:"入网方式:"},
_ = nwkSKey.SetText(mw.currentMoteConf.NwkSKey) CheckBox{AssignTo: &otaa,Text:"OTAA入网",Checked:Bind("OTAA"),OnCheckStateChanged: func() {
_ = fCnt.SetValue(float64(mw.currentMoteConf.FCnt)) mw.currentMoteConf.OTAA = otaa.Checked()
_ = db.Reset()
}}, }},
Label{Text:"入网方式:"}, Label{Text:"网关EUI:"},
CheckBox{AssignTo: &otaa,Text:"OTAA入网",OnClicked: func() { LineEdit{Text:Bind("GatewayEui")},
if otaa.Checked() { Label{Text:"应用EUI:",Visible:Bind("OTAA")},
appKey.SetEnabled(true) LineEdit{Text:Bind("AppEui"),Visible:Bind("OTAA")},
devAddr.SetEnabled(false) Label{Text:"终端EUI:"},
appSKey.SetEnabled(false) LineEdit{Text:Bind("DevEui")},
nwkSKey.SetEnabled(false) Label{Text:"应用秘钥:",Visible:Bind("OTAA")},
_ = devAddr.SetText("") LineEdit{Text:Bind("AppKey"),Visible:Bind("OTAA")},
}else{ Label{Text:"终端地址:"},
appKey.SetEnabled(false) LineEdit{Text:Bind("DevAddr"),ReadOnly:Bind("OTAA")},
devAddr.SetEnabled(true) Label{Text:"网络会话秘钥:"},
appSKey.SetEnabled(true) LineEdit{Text:Bind("NwkSKey"),ReadOnly:Bind("OTAA")},
nwkSKey.SetEnabled(true) Label{Text:"应用会话秘钥:"},
} LineEdit{Text:Bind("AppSKey"),ReadOnly:Bind("OTAA")},
}}, Label{Text:"上行计数:"},
Label{Text:"网关ID:"}, NumberEdit{Value:Bind("FCnt")},
LineEdit{AssignTo:&gatewayId}, },
Label{Text:"应用EUI:"}, },
LineEdit{AssignTo:&appEUI,Text:"0102030405060708"}, {
Label{Text:"终端EUI:"}, Title:"高级配置",
LineEdit{AssignTo:&devEUI}, Layout:Grid{Columns: 2},
Label{Text:"终端地址:"}, Children:[]Widget{
LineEdit{AssignTo:&devAddr}, Label{Text:"消息类型:"},
Label{Text:"应用秘钥:"}, ComboBox{Model:[]struct {
LineEdit{AssignTo:&appKey,Enabled:false}, Id uint8
Label{Text:"网络会话秘钥:"}, Name string
LineEdit{AssignTo:&nwkSKey}, }{
Label{Text:"应用会话秘钥:"}, {2,"UnconfirmedDataUp"},
LineEdit{AssignTo:&appSKey}, {4,"ConfirmedDataUp"},
Label{Text:"上行计数:"}, },BindingMember: "Id", DisplayMember: "Name", Value: Bind("MType")},
NumberEdit{AssignTo:&fCnt}, Label{Text:"扩频因子:"},
ComboBox{Model:[]struct{
Id uint8
Name string
}{
{0,"SF12"},
{1,"SF11"},
{2,"SF10"},
{3,"SF9"},
{4,"SF8"},
{5,"SF7"},
},BindingMember: "Id", DisplayMember: "Name",Value:Bind("DR")},
Label{Text:"端口:"},
NumberEdit{Value:Bind("FPort")},
Label{Text:"频率:"},
NumberEdit{Decimals:2,Value:Bind("Freq")},
Label{Text:"信道:"},
NumberEdit{Value:Bind("Chan")},
Label{Text:"信号强度:"},
NumberEdit{Value:Bind("RSSI")},
Label{Text:"信噪比:"},
NumberEdit{Value:Bind("LSNR")},
Label{Text:"帧控制:"},
GroupBox{
Title:"FCtrl",
Layout:Grid{Columns: 3},
Children:[]Widget{
CheckBox{Text:"adr",Checked:Bind("FCtrl.ADR")},
CheckBox{Text:"req",Checked:Bind("FCtrl.ADRACKReq")},
CheckBox{Text:"ack",Checked:Bind("FCtrl.ACK")},
CheckBox{Text:"fPending",Checked:Bind("FCtrl.FPending")},
CheckBox{Text:"classB",Checked:Bind("FCtrl.ClassB")},
},
},
},
},
}, },
}, },
Composite{ Composite{
@ -346,29 +396,22 @@ func (mw *MoteMainWindow) MoteConfig() {
AssignTo: &acceptPB, AssignTo: &acceptPB,
Text: "确定", Text: "确定",
OnClicked: func() { OnClicked: func() {
mw.currentMoteConf.OTAA = otaa.Checked()
mw.currentMoteConf.GatewayId = gatewayId.Text()
mw.currentMoteConf.AppEui = appEUI.Text()
mw.currentMoteConf.DevEui = devEUI.Text()
mw.currentMoteConf.DevAddr = devAddr.Text()
mw.currentMoteConf.AppKey = appKey.Text()
mw.currentMoteConf.AppSKey = appSKey.Text()
mw.currentMoteConf.NwkSKey = nwkSKey.Text()
mw.currentMoteConf.FCnt = uint32(fCnt.Value())
mw.motesConf.Current = name.Text() mw.motesConf.Current = name.Text()
if mw.motesConf.Current == "" {
_,ok := mw.motesConf.Configs[mw.motesConf.Current] msg := "配置名称不能为空"
if !ok { walk.MsgBox(mw, "错误", msg, walk.MsgBoxIconError)
//default return
mw.currentMoteConf.FPort = 1 }
mw.currentMoteConf.Freq = 470.3 _ = db.Submit()
mw.currentMoteConf.RSSI = -50 v,ok := mw.motesConf.Configs[mw.motesConf.Current]
mw.currentMoteConf.LSNR = 7 if ok {
mw.currentMoteConf.FCtrl.ADR = true if mw.currentMoteConf.OTAA && v.OTAA != mw.currentMoteConf.OTAA {
mw.currentMoteConf.DevAddr = ""
mw.currentMoteConf.NwkSKey = ""
mw.currentMoteConf.AppSKey = ""
}
} }
mw.motesConf.Configs[mw.motesConf.Current] = mw.currentMoteConf mw.motesConf.Configs[mw.motesConf.Current] = mw.currentMoteConf
var confData bytes.Buffer var confData bytes.Buffer
d,_ := json.Marshal(&mw.motesConf) d,_ := json.Marshal(&mw.motesConf)
_ = json.Indent(&confData, d, "", "\t") _ = json.Indent(&confData, d, "", "\t")
@ -391,132 +434,6 @@ func (mw *MoteMainWindow) MoteConfig() {
} }
_ = name.SetModel(names) _ = name.SetModel(names)
_ = name.SetText(mw.motesConf.Current) _ = name.SetText(mw.motesConf.Current)
otaa.SetChecked(mw.currentMoteConf.OTAA)
_ = gatewayId.SetText(mw.currentMoteConf.GatewayId)
_ = appEUI.SetText(mw.currentMoteConf.AppEui)
_ = devEUI.SetText(mw.currentMoteConf.DevEui)
_ = devAddr.SetText(mw.currentMoteConf.DevAddr)
_ = appKey.SetText(mw.currentMoteConf.AppKey)
_ = appSKey.SetText(mw.currentMoteConf.AppSKey)
_ = nwkSKey.SetText(mw.currentMoteConf.NwkSKey)
_ = fCnt.SetValue(float64(mw.currentMoteConf.FCnt))
dlg.Run()
}
func (mw *MoteMainWindow) MoteAdvancedConfig() {
if mw.motesConf.Current == "" || len(mw.motesConf.Configs) <= 0 {
msg := "请先配置终端基础配置"
walk.MsgBox(mw, "错误", msg, walk.MsgBoxIconError)
return
}
var dlg *walk.Dialog
var mType,sf *walk.ComboBox
var fPort,freq,ch,lsnr,rssi *walk.NumberEdit
var adr,req,ack,fPending,classB *walk.CheckBox
var acceptPB, cancelPB *walk.PushButton
_ = Dialog{
Title: "终端高级配置",
Icon: mw.icon,
Layout: VBox{},
AssignTo: &dlg,
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
MinSize: Size{400, 200},
Children: []Widget{
Composite{
Layout:Grid{Columns: 2},
Children:[]Widget{
Label{Text:"消息类型:"},
ComboBox{AssignTo:&mType,Model:[]string{"UnconfirmedDataUp","ConfirmedDataUp"},Value:"UnconfirmedDataUp"},
Label{Text:"扩频因子:"},
ComboBox{AssignTo:&sf,Model:[]string{"SF12","SF11","SF10","SF9","SF8","SF7"},Value:"SF12"},
Label{Text:"端口:"},
NumberEdit{AssignTo:&fPort},
Label{Text:"频率:"},
NumberEdit{AssignTo:&freq,Decimals:2},
Label{Text:"信道:"},
NumberEdit{AssignTo:&ch},
Label{Text:"信号强度:"},
NumberEdit{AssignTo:&rssi},
Label{Text:"信噪比:"},
NumberEdit{AssignTo:&lsnr},
Label{Text:"帧控制:"},
GroupBox{
Title:"FCtrl",
Layout:Grid{Columns: 3},
Children:[]Widget{
CheckBox{AssignTo:&adr,Text:"adr"},
CheckBox{AssignTo:&req,Text:"req"},
CheckBox{AssignTo:&ack,Text:"ack"},
CheckBox{AssignTo:&fPending,Text:"fPending"},
CheckBox{AssignTo:&classB,Text:"classB"},
},
},
},
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
PushButton{
AssignTo: &acceptPB,
Text: "确定",
OnClicked: func() {
switch mType.CurrentIndex() {
case 0:
mw.currentMoteConf.MType = uint8(lorawan.UnconfirmedDataUp)
case 1:
mw.currentMoteConf.MType = uint8(lorawan.ConfirmedDataUp)
}
mw.currentMoteConf.DR = uint8(sf.CurrentIndex())
mw.currentMoteConf.FPort = uint8(fPort.Value())
mw.currentMoteConf.Freq = freq.Value()
mw.currentMoteConf.Chan = uint8(ch.Value())
mw.currentMoteConf.RSSI = int16(rssi.Value())
mw.currentMoteConf.LSNR = lsnr.Value()
mw.currentMoteConf.FCtrl.ADR = adr.Checked()
mw.currentMoteConf.FCtrl.ADRACKReq = req.Checked()
mw.currentMoteConf.FCtrl.ACK = ack.Checked()
mw.currentMoteConf.FCtrl.FPending = fPending.Checked()
mw.currentMoteConf.FCtrl.ClassB = classB.Checked()
mw.motesConf.Configs[mw.motesConf.Current] = mw.currentMoteConf
var confData bytes.Buffer
d,_ := json.Marshal(&mw.motesConf)
_ = json.Indent(&confData, d, "", "\t")
_ = ioutil.WriteFile(mw.moteConfFileName,confData.Bytes(),0644)
dlg.Accept()
},
},
PushButton{
AssignTo: &cancelPB,
Text: "取消",
OnClicked: func() { dlg.Cancel() },
},
},
},
},
}.Create(mw)
switch lorawan.MType(mw.currentMoteConf.MType) {
case lorawan.UnconfirmedDataUp:
_ = mType.SetCurrentIndex(0)
case lorawan.ConfirmedDataUp:
_ = mType.SetCurrentIndex(1)
}
_ = sf.SetCurrentIndex(int(mw.currentMoteConf.DR))
_ = fPort.SetValue(float64(mw.currentMoteConf.FPort))
_ = freq.SetValue(mw.currentMoteConf.Freq)
_ = ch.SetValue(float64(mw.currentMoteConf.Chan))
_ = rssi.SetValue(float64(mw.currentMoteConf.RSSI))
_ = lsnr.SetValue(mw.currentMoteConf.LSNR)
adr.SetChecked(mw.currentMoteConf.FCtrl.ADR)
req.SetChecked(mw.currentMoteConf.FCtrl.ADRACKReq)
ack.SetChecked(mw.currentMoteConf.FCtrl.ACK )
fPending.SetChecked(mw.currentMoteConf.FCtrl.FPending )
classB.SetChecked(mw.currentMoteConf.FCtrl.ClassB)
dlg.Run() dlg.Run()
} }
@ -737,7 +654,7 @@ func (mw *MoteMainWindow) sendMsg() error{
} }
if mw.currentMoteConf.OTAA && mw.currentMoteConf.DevAddr == ""{ if mw.currentMoteConf.OTAA && mw.currentMoteConf.DevAddr == ""{
mw.currentMoteConf.devNonce = lorawan.DevNonce(rand.Uint32()) mw.currentMoteConf.devNonce = lorawan.DevNonce(rand.Uint32())
packet,phy,err := BuildJoin(mw.currentMoteConf.GatewayId,mw.currentMoteConf.AppEui, packet,phy,err := BuildJoin(mw.currentMoteConf.GatewayEui,mw.currentMoteConf.AppEui,
mw.currentMoteConf.DevEui,mw.currentMoteConf.AppKey,mw.currentMoteConf.DR, mw.currentMoteConf.DevEui,mw.currentMoteConf.AppKey,mw.currentMoteConf.DR,
mw.currentMoteConf.Chan,mw.currentMoteConf.Freq,mw.currentMoteConf.LSNR, mw.currentMoteConf.Chan,mw.currentMoteConf.Freq,mw.currentMoteConf.LSNR,
mw.currentMoteConf.RSSI, mw.currentMoteConf.devNonce) mw.currentMoteConf.RSSI, mw.currentMoteConf.devNonce)
@ -754,7 +671,7 @@ func (mw *MoteMainWindow) sendMsg() error{
Direction:"uplink", Direction:"uplink",
DevEUI:mw.currentMoteConf.DevEui, DevEUI:mw.currentMoteConf.DevEui,
MType:phy.MHDR.MType.String(), MType:phy.MHDR.MType.String(),
GatewayID:mw.currentMoteConf.GatewayId, GatewayID:mw.currentMoteConf.GatewayEui,
Rssi:packet.Payload.RXPK[0].RSSI, Rssi:packet.Payload.RXPK[0].RSSI,
LoRaSNR:packet.Payload.RXPK[0].LSNR, LoRaSNR:packet.Payload.RXPK[0].LSNR,
Frequency:packet.Payload.RXPK[0].Freq, Frequency:packet.Payload.RXPK[0].Freq,
@ -766,7 +683,7 @@ func (mw *MoteMainWindow) sendMsg() error{
_ = mw.tv.SetSelectedIndexes([]int{}) _ = mw.tv.SetSelectedIndexes([]int{})
frames,_:= packet.GetUplinkFrames(true,false) frames,_:= packet.GetUplinkFrames(true,false)
for j := range frames { for j := range frames {
mw.PushData(mw.currentMoteConf.GatewayId,"up",&frames[j]) mw.PushData(mw.currentMoteConf.GatewayEui,"up",&frames[j])
} }
fmt.Println("push join ") fmt.Println("push join ")
for cnt := 0;mw.currentMoteConf.DevAddr == "" && cnt < 5;cnt ++ { for cnt := 0;mw.currentMoteConf.DevAddr == "" && cnt < 5;cnt ++ {
@ -795,7 +712,7 @@ func (mw *MoteMainWindow) sendMsg() error{
if mw.currentMoteConf.FPort == 0 { if mw.currentMoteConf.FPort == 0 {
key = mw.currentMoteConf.NwkSKey key = mw.currentMoteConf.NwkSKey
} }
packet,phy,err := BuildUpData(mw.currentMoteConf.GatewayId,mw.currentMoteConf.DevAddr,key, packet,phy,err := BuildUpData(mw.currentMoteConf.GatewayEui,mw.currentMoteConf.DevAddr,key,
mw.currentMoteConf.NwkSKey,mw.currentMoteConf.FCnt,mw.currentMoteConf.FPort, mw.currentMoteConf.NwkSKey,mw.currentMoteConf.FCnt,mw.currentMoteConf.FPort,
mw.currentMoteConf.DR,mw.currentMoteConf.Chan,mw.currentMoteConf.Freq,mw.currentMoteConf.LSNR, mw.currentMoteConf.DR,mw.currentMoteConf.Chan,mw.currentMoteConf.Freq,mw.currentMoteConf.LSNR,
lorawan.MType(mw.currentMoteConf.MType),mw.currentMoteConf.FCtrl,mw.currentMoteConf.RSSI,bmsg) lorawan.MType(mw.currentMoteConf.MType),mw.currentMoteConf.FCtrl,mw.currentMoteConf.RSSI,bmsg)
@ -813,7 +730,7 @@ func (mw *MoteMainWindow) sendMsg() error{
DevEUI:mw.currentMoteConf.DevEui, DevEUI:mw.currentMoteConf.DevEui,
DevAddr:mw.currentMoteConf.DevAddr, DevAddr:mw.currentMoteConf.DevAddr,
MType:phy.MHDR.MType.String(), MType:phy.MHDR.MType.String(),
GatewayID:mw.currentMoteConf.GatewayId, GatewayID:mw.currentMoteConf.GatewayEui,
Rssi:packet.Payload.RXPK[0].RSSI, Rssi:packet.Payload.RXPK[0].RSSI,
LoRaSNR:packet.Payload.RXPK[0].LSNR, LoRaSNR:packet.Payload.RXPK[0].LSNR,
Frequency:packet.Payload.RXPK[0].Freq, Frequency:packet.Payload.RXPK[0].Freq,
@ -829,7 +746,7 @@ func (mw *MoteMainWindow) sendMsg() error{
_ = mw.tv.SetSelectedIndexes([]int{}) _ = mw.tv.SetSelectedIndexes([]int{})
frames,_:= packet.GetUplinkFrames(true,false) frames,_:= packet.GetUplinkFrames(true,false)
for j := range frames { for j := range frames {
mw.PushData(mw.currentMoteConf.GatewayId,"up",&frames[j]) mw.PushData(mw.currentMoteConf.GatewayEui,"up",&frames[j])
} }
mw.currentMoteConf.FCnt ++ mw.currentMoteConf.FCnt ++
return nil return nil

34
model.go

@ -17,23 +17,23 @@ type ConnectConfig struct {
} }
type MoteConfig struct { type MoteConfig struct {
OTAA bool `json:"otaa"` OTAA bool `json:"otaa"`
GatewayId string `json:"gatewayId"` GatewayEui string `json:"gatewayEui"`
AppEui string `json:"appEui"` AppEui string `json:"appEui"`
DevEui string `json:"devEui"` DevEui string `json:"devEui"`
DevAddr string `json:"devAddr"` DevAddr string `json:"devAddr"`
AppKey string `json:"appKey"` AppKey string `json:"appKey"`
NwkSKey string `json:"nwkSKey"` NwkSKey string `json:"nwkSKey"`
AppSKey string `json:"appSKey"` AppSKey string `json:"appSKey"`
FCnt uint32 `json:"fCnt"` FCnt uint32 `json:"fCnt"`
FPort uint8 `json:"fPort"` FPort uint8 `json:"fPort"`
Freq float64 `json:"freq"` Freq float64 `json:"freq"`
DR uint8 `json:"dr"` DR uint8 `json:"dr"`
Chan uint8 `json:"chan"` Chan uint8 `json:"chan"`
LSNR float64 `json:"lsnr"` LSNR float64 `json:"lsnr"`
RSSI int16 `json:"rssi"` RSSI int16 `json:"rssi"`
MType uint8 `json:"mType"` MType uint8 `json:"mType"`
FCtrl lorawan.FCtrl `json:"fCtrl"` FCtrl lorawan.FCtrl `json:"fCtrl"`
devNonce lorawan.DevNonce devNonce lorawan.DevNonce
} }

Loading…
Cancel
Save