SDK 互联互通
概述
Edge SDK 提供接口可以通过上云 API 与和机场建立连接的云端服务器进行小数据交互,即向云端服务器发送自定义小数据与接收来自云端服务器的自定义小数据。
注意: 使用该接口发送和接收数据上下行通道最大带宽不应超过 0.5Mb/S。

云端低速通道介绍
使用自定义小数据通道需要通过上云 API 协议 ESDK 互联互通与云端通信。
云端低速通道发送
接口原型:
ErrorCode CloudAPI_SendCustomEventsMessage(const uint8_t* data, uint32_t len);
该接口最大可以发送256字节的数据,使用该接口进行业务数据的发送,由接口内部进行上云 API 协议格式数据的封装。
在云端接收到的上云API数据协议定义如下:
Topic: thing/product/{pid}/events
Direction: up
Method: custom_data_transmission_from_esdk
Data:
Column | Name | Type | constraint | Description |
---|---|---|---|---|
value | 数据内容 | text | {"length":"小于 256"} |
Example:
{
"bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"data": {
"value": "hello world"
},
"gateway": "4TADKAQ000002J",
"method": "custom_data_transmission_from_esdk",
"tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"timestamp": 1689911315621
}
云端低速通道接收
接口原型:
using CloudAPICustomServicesMessageHandler = std::function<void(const uint8_t* data, uint32_t len)>; ErrorCode CloudAPI_RegisterCustomServicesMessageHandler(
CloudAPICustomServicesMessageHandler handler)
通过该接口注册接收云端数据回调处理函数,需要注意的是,在回调处理函数中,不应该采用同步方式处理消息,否则可能会堵塞消息的接收。应该将数据接收到缓存队列,在异步消费处理。
在云端通过上云API发送消息格式订阅如下:
Topic: thing/product/{pid}/services
Direction: down
Method: custom_data_transmission_to_esdk
Data:
Column | Name | Type | constraint | Description |
---|---|---|---|---|
value | 数据内容 | text | {"length":"小于 256"} |
Example:
{
"bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"data": {
"value": "hello world"
},
"method": "custom_data_transmission_to_esdk",
"tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"timestamp": 1689740550047
}
Topic: thing/product/{pid}/services_reply
Direction: up
Method: custom_data_transmission_to_esdk
Data:
Column | Name | Type | constraint | Description |
---|---|---|---|---|
result | 返回码 | int |
Example:
{
"bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"data": {
"result": 0
},
"method": "custom_data_transmission_to_esdk",
"tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"timestamp": 1689740550047
}