IoT边缘 IoTEdge-接口函数:edge.h回调函数说明

时间:2025-01-26 10:36:38

edge.h回调函数说明

  1. 模块影子数据回调

    函数描述:

    typedef  EDGE_RETCODE (FN_SHADOW_ARRIVED)(const char* shadow, unsigned int shadow_len);

    函数功能:

    当下发模块配置时,通过此函数通知到用户,用户应用的配置也通过此函数通知。

    表2 参数说明

    参数名称

    类型

    参数描述

    示例

    shadow

    char*

    模块影子数据(json字符串),第三方应用下发用户的配置数据

    {

    “config”:”test”

    }

    shadow_len

    unsigned int

    影子数据的长度

    -

  2. 命令下发回调

    函数描述:

    typedef EDGE_RETCODE (FN_COMMAND_ARRIVED)(const char* command_name, const char* device_id, const char* service_id, const char* request_id, const char* body, unsigned int body_len);

    函数功能:

    此函数声明用户命令下发通知,设备命令下发即使用此函数声明。

    表3 参数说明

    参数名称

    类型

    参数描述

    command_name

    char*

    设备命令名称,在设备关联的产品模型中定义。

    device_id

    char*

    命令对应的目标设备ID,命令下发对应的最终目标设备

    service_id

    char*

    设备的服务ID,在设备关联的产品模型中定义

    request_id

    char*

    {request_id}用于唯一标识这次请求,响应该命令时需要带上。

    body

    char*

    json字符串,设备命令的执行参数,具体字段在设备关联的产品模型中定义

    body_len

    unsigned int

    -

  3. 消息下发回调

    函数描述:

    typedef  EDGE_RETCODE (FN_MESSAGE_ARRIVED)(const char* message_id, const char* message_name, const char* device_id, const char* body, unsigned int body_len);

    函数功能:

    此函数声明用于消息下发通知,平台使用此接口承接平台下发给设备的自定义格式的数据。

    表4 参数说明

    参数名称

    类型

    参数描述

    message_id

    char*

    消息名称

    message_name

    char*

    消息的唯一标识

    device_id

    char*

    命令对应的目标设备ID,命令下发对应的最终目标设备

    body

    char*

    消息内容。

    body_len

    unsigned int

    消息长度

  4. 事件下发回调

    函数描述:

    typedef  EDGE_RETCODE (FN_DEVICE_EVENT_ARRIVED)(const char* device_id, const char* body, unsigned int body_len);

    函数功能:

    此函数声明用于事件下发通知,平台使用此接口承接平台下发给设备的自定义格式的数据。

    表5 参数说明

    参数名称

    类型

    参数描述

    示例

    device_id

    char*

    命令对应的目标设备ID,命令下发对应的最终目标设备

    -

    body

    char*

    事件内容。

    {

    "object_device_id":"deviceId",

    "services":[

    {

    "service_id":"serviceTest",

    "event_id":"eventTest",

    "event_type":"eventTypeTest",

    "event_time":"time",

    "paras":{

    "test":"test"

    }

    }

    ]

    }

    body_len

    unsigned int

    消息长度

    -

  5. 子设备添加回调

    函数描述:

    typedef  EDGE_RETCODE (FN_SUB_DEVICE_ADD_ARRIVED)(const char* addSubDeviceInfo, unsigned int body_len);

    函数功能:

    此函数声明用于通知子设备添加,使用此接口承接平台添加成功子设备的通知。

    表6 参数说明

    参数名称

    类型

    参数描述

    示例

    addSubDeviceInfo

    char*

    添加成功的子设备信息,具体格式见示例

    {"devices":

    [{"parent_device_id":"c6b39067b03421a48",

    "node_id": "subdevice11",

    "device_id":"2bb77-063ad2f5a6cc",

    "name": "subDevice11",

    "description": null,

    "product_id":"c6b3b34663d3ea42f6",

    "fw_version": null,

    "sw_version": null,

    "status": "ONLINE"

    }],"version":1}

    body_len

    unsigned int

    长度

    -

  6. 子设备删除回调

    函数描述:

    typedef  EDGE_RETCODE (FN_SUB_DEVICE_DELETED_ARRIVED)(const char* deleteSubDeviceInfo, unsigned int body_len);

    函数功能:

    此函数声明用于通知子设备删除,使用此接口承接平台删除成功子设备的通知。

    表7 参数说明

    参数名称

    类型

    参数描述

    示例

    deleteSubDeviceInfo

    char*

    删除成功的子设备信息,具体格式见示例

    {"devices":

    [{"parent_device_id":"c6b39067b03421a48",

    "node_id": "subdevice11",

    "device_id":"2bb77-063ad2f5a6cc",

    "name": "subDevice11",

    "description": null,

    "product_id":"c6b3b34663d3ea42f6",

    "fw_version": null,

    "sw_version": null,

    "status": "ONLINE"

    }],"version":1}

    body_len

    unsigned int

    长度

    -

  7. 子设备扫描回调

    函数描述:

    typedef  EDGE_RETCODE (FN_START_SCAN_ARRIVED)(const char* protocol, const char* channel, const char* parentDeviceId,const char* scan_setting, unsigned int body_len);

    函数功能:

    此函数声明用于通知网关扫描子设备。

    表8 参数说明

    参数名称

    类型

    参数描述

    protocol

    char*

    协议

    channel

    char*

    通道信息

    parentDeviceId

    char*

    父设备ID

    scan_setting

    char*

    扫描设备

    body_len

    unsigned int

    配置长度

  8. 子设备属性设置回调

    函数描述:

    typedef  EDGE_RETCODE (FN_DEVICE_PROPERTIES_SET_ARRIVED)(ST_PROPERTY_SET* sub_device_property_set);

    函数功能:

    此函数声明用于接收平台对子设备的属性设置。

    表9 参数说明

    参数名称

    类型

    参数描述

    示例

    sub_device_property_set

    ST_PROPERTY_SET*

    属性设置

    参见edge.h

  9. 子设备属性获取回调

    函数描述:

    typedef  EDGE_RETCODE (FN_DEVICE_PROPERTIES_GET_ARRIVED)(ST_PROPERTY_GET* sub_device_property_get);

    函数功能:

    此函数声明用于接收平台获取子设备的属性。

    表10 参数说明

    参数名称

    类型

    参数描述

    示例

    sub_device_property_get

    ST_PROPERTY_GET*

    属性设置

    参见edge.h

  10. 子设备影子回调

    函数描述:

    typedef  EDGE_RETCODE (FN_DEVICE_SHADOW_ARRIVED)(ST_DEVICE_SHADOW* sub_device_shadow);

    函数功能:

    此函数声明用于接收平台设置子设备的影子。

    表11 参数说明

    参数名称

    类型

    参数描述

    示例

    sub_device_property_get

    ST_DEVICE_SHADOW*

    属性设置

    参见edge.h

  11. 自定义topic 消息通知 回调

    函数描述:

    typedef  EDGE_RETCODE (FN_CUSTOMIZED_MESSAGE_ARRIVED)(const char* topic, const char* payload, unsigned int len);

    函数功能:

    此函数声明用于接收平台设置子设备的影子。

    表12 参数说明

    参数名称

    类型

    参数描述

    topic

    char*

    自定义topic

    payload

    char*

    消息内容

    len

    unsigned int

    消息长度

support.huaweicloud.com/devg-iotedge/iotedge_devg_0055.html