SDK Interconnection

2023-10-23
No Rating

Overview

The Edge SDK offers interfaces to interact with cloud servers connected to docks via the Cloud API. This allows for the transmission of custom small data sending and receiving to and from cloud servers.

Note: When using this interface, the bandwidth for both uplink and downlink data transmissions should be limited to less than 0.5Mb/S.

Custom Small Data Channel

ESDK uses the custom small data channel to communicate with the cloud through the ESDK Interconnectionopen in new window protocol.

Send Custom Data to the Cloud

Interface prototype:

ErrorCode CloudAPI_SendCustomEventsMessage(const uint8_t* data, uint32_t len);

This interface allows for sending data up to 256 bytes. When using this interface, data is internally encapsulated following the Cloud API protocol format.

The cloud receives the data defined in the Cloud API protocol is as follows:

Topic: thing/product/{pid}/events

Direction: up

Method: custom_data_transmission_from_esdk

Data:

ColumnNameTypeconstraintDescription
valuedata contenttext{"length":"less than 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
}

Receive Custom Data from the Cloud

Interface prototype:

using CloudAPICustomServicesMessageHandler = std::function<void(const uint8_t* data, uint32_t len)>; ErrorCode CloudAPI_RegisterCustomServicesMessageHandler(
CloudAPICustomServicesMessageHandler handler)

Register a callback function via this interface to manage incoming data from the cloud. Ensure that the data is handled asynchronously within the callback function. Synchronous handling might block message reception. Instead, move data to a buffer queue for asynchronous processing.

The cloud sends messages in the following format using the Cloud API:

Topic: thing/product/{pid}/services

Direction: down

Method: custom_data_transmission_to_esdk

Data:

ColumnNameTypeconstraintDescription
valuedata contenttext{"length":"less than 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:

ColumnNameTypeconstraintDescription
resultreturn codeint

Example:

{
	"bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
	"data": {
		"result": 0
	},
	"method": "custom_data_transmission_to_esdk",
	"tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
	"timestamp": 1689740550047
}
If you have any comments or confusion about our documentation, you can click here to give feedback and we will get back to you as soon as possible.