CoAP connection FAQ
This topic describes common issues and their solutions when a device uses the C Link SDK V3.x to connect to IoT Platform over the Constrained Application Protocol (CoAP).
Does the CoAP protocol allow connections over UDP?
CoAP over UDP is not supported. IoT Platform currently supports only Datagram Transport Layer Security (DTLS) connections for CoAP.
What is the URI for connecting to IoT Platform over CoAP?
When you call IOT_CoAP_Init, you can set the p_url parameter in iotx_coap_config_t.
If p_url is NULL, the SDK automatically uses the URL configured in IOTX_ONLINE_DTLS_SERVER_URL.
#define IOTX_ONLINE_DTLS_SERVER_URL "coaps://%s.iot-as-coap.cn-shanghai.aliyuncs.com:5684"For more information about CoAP connection details, such as the address and port, see CoAP connection and communication.
Does the IOT_CoAP_DeviceNameAuth function block and wait for a specified time?
The current version is non-blocking and asynchronous. This interface does not block to wait for a result. Instead, the result is processed in IOT_CoAP_Yield.
The IOT_CoAP_Yield function is semi-blocking. Each call waits for 2 seconds. If data is available, it is received and processed. If no data is available, the call times out after 2 seconds.
The default wait time is 2,000 milliseconds. To change this, modify the COAP_WAIT_TIME_MS macro.
What is the purpose of the IOTX_DEVICE_ID field when a CoAP client submits an authentication request?
This field is for custom information, such as a device serial number (SN). You can use this field to include any device information that must be sent to the cloud.
What error occurs if the data sent to the cloud is not in JSON format?
In addition to JSON, the platform also supports Concise Binary Object Representation (CBOR) format. Devices must use a supported format to communicate with the cloud to avoid parsing errors.
What causes coap_malloc to return NULL when the IOT_CoAP_Init method is called?
Check whether the coap_malloc function is implemented for your platform. After you port the platform, you must implement all hal-related underlying functions yourself.
Does the CoAP protocol support downlink data?
The HTTP and CoAP protocols do not currently support downlink data. Use the Message Queuing Telemetry Transport (MQTT) protocol, which supports both uplink and downlink data.