Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ruizeng opened this issue Jan 14, 2016 · 0 comments
Open

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

ruizeng opened this issue Jan 14, 2016 · 0 comments
Assignees

Comments

@ruizeng
Copy link
Member

ruizeng commented Jan 14, 2016

背景

之前的框架层只实现了对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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants