typedef struct _SmartPassProto_TSLIOTDispatchRainbowListRequest {
uint32_t update_time;
pb_callback_t list;
} SmartPassProto_TSLIOTDispatchRainbowListRequest;
结构体包含一个数组
//初始值
SmartPassProto_TSLIOTDispatchRainbowListRequest response = SmartPassProto_TSLIOTDispatchRainbowListRequest_init_zero;
//准备解析
pb_istream_t input = pb_istream_from_buffer(pst->data,pst->len);
//单独写一个解析函数
response.list.funcs.decode = &rainbow_decode_callback;
if (!pb_decode(&input , SmartPassProto_TSLIOTDispatchRainbowListRequest_fields, &response))
{
log(DEBUG, "Decode failed: %s\n", PB_GET_ERROR(&input));
return false;
}
log(DEBUG,"rainbow 住户表更新时间戳:%d\n" , response.update_time);
问题的关键来了!重写了函数response.list.funcs.decode在这个函数里面
需要明确是什么样子的数组!别人并不知道你就是U8类型的!!
也就是
typedef struct _SimpleMessage {
int32_t lucky_number;
bool success;
pb_callback_t dev_id;
pb_callback_t days;
/* @@protoc_insertion_point(struct:SimpleMessage) */
} SimpleMessage;
不能体现 pb_callback_t days; 重新来过!
开始吧
再来一次
syntax = "proto2";
message SimpleMessage {
required int32 lucky_number = 1;
required bool success = 2;
repeated int32 days=4;
}
message ArryInt {
required int32 data=4;
}
发现测试也不行 怀疑是数组mian的时候 转变成流的函数不对 不能用字符串那个函数
问题在new10表达