Skip to content

[proposal]增加命令处理和事件上报接口 #28

Open
@ruizeng

Description

@ruizeng

背景

之前的框架层只实现了对status的上报和设置,并未实现命令和事件接口。鉴于目前还未实现完整的原语设计,所以先提供subdevice层的事件和命令接口封装。

修改建议

子设备核心框架逻辑都在framework/subdevice/目录下,文件功能如下:

  • pando_subdevice.c: 提供子设备核心协议处理及分发逻辑。
  • pando_object.c :提供对象注册和管理接口。

要实现命令和事件接口,大体方案如下:

1

新增pando_command.c pando_command.h,新增数据结构pando_command:

typedef struct {
    uint8_t no;
    uint8_t priority;
    void (*unpack)(PARAMS*);
}pando_command;

新增如下接口:

void register_pando_command(pando_command command);
pando_command* find_pando_command(uint8_t no);

暂不考虑优先级的处理。(已经预留)

2

新增pando_event.c pando_event.h,新增数据结构pando_event:

typedef struct {
    uint8_t no;
    uint8_t priority;
    void (*pack)(PARAMS*);
}pando_event;

新增如下接口:

void register_pando_event(pando_event event);
pando_event* find_pando_event(uint8_t no);

暂不考虑优先级的处理。(已经预留)

3

pando_subdevice增加接口report_event(uint8_t no),提供事件的主动上报功能。

4

事件和命令都通过链表进行管理,具体方法参考pando_object;

当pando_subdevice中decode_command解析出的命令不是通用指令时,就调用find_pando_command调用其unpack方法。(参考object状态设置部分)

当用户主动上报事件时,调用report_event方法,此方法调用find_pando_event先找到对应的event,调用其pack方法,打包好数据后上报(参考object状态上报部分)。

@tianlongqiang @leeshineSZ @LottesLiu @sw0813

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions