Updated on 2023-02-16 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

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

Parameters

Parameter

Mandatory or Optional

Type

Description

object_device_id

Optional

String

Indicates the device that the event is about. If this parameter is not carried, the device specified in the topic is considered to be the device involved.

services

Optional

List<ServiceEvent>

Indicates a list of services that the event is about.

ServiceEvent structure

Parameter

Mandatory or Optional

Type

Description

service_id

Mandatory

String

System field. The value is fixed to $time_sync.

event_type

Mandatory

String

System field. The value is fixed to time_sync_response.

event_time

Optional

String

Indicates the time when the event occurs.

paras

Mandatory

Object

Indicates the event parameters in JSON format.

paras structure

Parameter

Mandatory or Optional

Type

Description

device_send_time

Mandatory

long

Indicates the timestamp when the device sends the request. The timestamp is the number of milliseconds since 00:00:00 on January 1, 1970 in GMT.

server_recv_time

Mandatory

long

Indicates the timestamp when the platform receives the request.

server_send_time

Mandatory

long

Indicates the 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
         } 
    }] 
}