Closed RongAtRabbit closed 6 years ago
I think the reason is in
MACPayloadFromPayload;
if payload.FPort != nil { ==== >when payload.FPort== nil,it will init the mac.FPort = 0
mac.FPort = int32(*payload.FPort)
}
but in function :
// Payload converts the MACPayload to a lorawan.Payload
func (msg *Message_MacPayload) Payload() lorawan.Payload {
if m.FPort >= 0 { ====>this step will give port a value 0
fPort := uint8(m.FPort)
mac.FPort = &fPort
}
above change the port nil to value 0 MIC is calculated by port nil. but will validate by port value 0. so it cause the "Invalid MIC"
MACPayloadFromPayload
will indeed output an FPort of 0
for both situations (FPort=0 and FPort=nil). However, the Payload()
will only set the FPort if it is greater than 0 or set it to 0 if there is a FRMPayload. In other cases it will remain nil
:
if m.FPort > 0 {
fPort := uint8(m.FPort)
mac.FPort = &fPort
}
if len(m.FRMPayload) != 0 {
mac.FRMPayload = []lorawan.Payload{&lorawan.DataPayload{Bytes: m.FRMPayload}}
if mac.FPort == nil {
fPort := uint8(0)
mac.FPort = &fPort
}
}
Could you give a little more information about the device you are using for this? It would be very helpful to have the
This is a MIC VALID bug report for the backend
hdl.1 | WARN Could not handle uplink AppID=3AC7CB39D7CF0A57 DevID=0000000050000007 error=Uplink not valid: Invalid MIC