Updated on 2024-12-02 GMT+08:00

Platform Responding to a Request for Time Synchronization

Function

This API is used by the platform to send a response to the device. The device sending parameter device_send_time is carried. server_recv_time indicates the time when the platform receives the device request. server_send_time indicates the time when the platform sends a response to the device.

Assume that the time when the device receives the response is device_recv_time. The device calculates the accurate time as follows:

(server_recv_time + server_send_time + device_recv_time - device_send_time) / 2

Topic

Downstream: $oc/devices/{device_id}/sys/events/down

Parameters

Parameter

Mandatory/Optional

Type

Description

object_device_id

Optional

String

Explanation:

  • For gateway child device: The value is the child device ID in the topic.
  • For directly connected device: The value is the same that of device_id in the topic.

services

Optional

List<ServiceEvent>

Explanation:

List of services that an event is about.

ServiceEvent structure

Parameter

Mandatory/Optional

Type

Description

service_id

Mandatory

String

Explanation:

System field.

Value range:

Fixed at $time_sync.

event_type

Mandatory

String

Explanation:

System field.

Value range:

Fixed at time_sync_response.

event_time

Optional

String

Explanation:

Event time. UTC time format: yyyyMMdd'T'HHmmss'Z'.

paras

Mandatory

Object

Explanation:

Event parameters in JSON format.

paras structure

Parameter

Mandatory/Optional

Type

Description

device_send_time

Mandatory

long

Explanation:

Timestamp when the device sends the request. The timestamp is the number of milliseconds since 00:00:00 on January 1, 1970 in Greenwich Mean Time (GMT).

server_recv_time

Mandatory

long

Explanation:

Timestamp when the platform receives the request.

server_send_time

Mandatory

long

Explanation:

Timestamp when the platform sends the response.

Example

Topic: $oc/devices/{device_id}/sys/events/down  
Data format:
{ 
    "object_device_id": "{object_device_id}", 
    "services": [{ 
        "service_id": "$time_sync", 
        "event_type": "time_sync_response", 
        "event_time": "20151212T121212Z",
         "paras": { 
            "device_send_time": 1582685678789,
            "server_recv_time": 1582685696152,
            "server_send_time": 1582685708109
         } 
    }] 
}