更新proto
This commit is contained in:
@@ -207,16 +207,20 @@ func (c *ChirpStackListener) handleUpEvent(event *UpEvent) {
|
||||
return
|
||||
}
|
||||
|
||||
// 3.3 检查是否是采集响应
|
||||
if instruction.Method != proto.MethodType_COLLECT {
|
||||
c.logger.Infof("收到一个非采集响应的上行指令 (Method: %s),无需处理。", instruction.Method.String())
|
||||
// 3.3 使用 type switch 从 oneof payload 中提取 CollectResult
|
||||
var collectResp *proto.CollectResult
|
||||
switch p := instruction.GetPayload().(type) {
|
||||
case *proto.Instruction_CollectResult:
|
||||
collectResp = p.CollectResult
|
||||
default:
|
||||
// 如果上行的数据不是采集结果,记录日志并忽略
|
||||
c.logger.Infof("收到一个非采集响应的上行指令 (Type: %T),无需处理。", p)
|
||||
return
|
||||
}
|
||||
|
||||
// 3.4 解包内层 CollectResult
|
||||
var collectResp proto.CollectResult
|
||||
if err := instruction.Data.UnmarshalTo(&collectResp); err != nil {
|
||||
c.logger.Errorf("解包数据信息失败: %v", err)
|
||||
// 检查 collectResp 是否为 nil,虽然在 type switch 成功的情况下不太可能
|
||||
if collectResp == nil {
|
||||
c.logger.Errorf("从 Instruction 中提取的 CollectResult 为 nil")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user