如何从google iot core中的modifyCloudToDeviceConfig获取设备确认时间

时间:2018-02-10 21:23:31

标签: google-cloud-messaging google-cloud-platform google-cloud-functions google-cloud-iot

我正在使用带有firebase功能的google iot核心。 当我请求client.projects.locations.registries.devices.modifyCloudToDeviceConfig时 我得到回应: -

    { status: 200,
  statusText: 'OK',
  headers: 
   { 'content-type': 'application/json; charset=UTF-8',
     vary: 'X-Origin, Referer, Origin,Accept-Encoding',
     date: 'Sat, 10 Feb 2018 20:18:19 GMT',
     server: 'ESF',
     'cache-control': 'private',
     'x-xss-protection': '1; mode=block',
     'x-frame-options': 'SAMEORIGIN',
     'x-content-type-options': 'nosniff',
     'alt-svc': 'hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"',
     'accept-ranges': 'none',
     connection: 'close' },
  config: 
   { adapter: [Function: httpAdapter],
     transformRequest: { '0': [Function: transformRequest] },
     transformResponse: { '0': [Function: transformResponse] },
     timeout: 0,
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     headers: 
      { Accept: 'application/json, text/plain, */*',
        'Content-Type': 'application/x-www-form-urlencoded',
        Authorization: 'Bearer ya29.c.ElxeBWp21IRsyESzVRbsSxiuArT6fpTZSfrgSI1RCk6DiHlU2GaLyTmOUd-4tZHOFCl2aAQJ5ZN4bQP3cBlzZ2AFl2Op8iArxnlcFv8l1OF-YZLdfom0hqnVcsH7OA',
        'User-Agent': 'google-api-nodejs-client/1.2.1' },
     method: 'post',
     url: 'https://cloudiot.googleapis.com/v1/projects/nodemcuiot-76b3f/locations/us-central1/registries/asset-tracker-registry/devices/esp32_21DF30:modifyCloudToDeviceConfig',
     paramsSerializer: [Function],
     data: undefined,
     params: 
      { version_to_update: 0,
        binary_data: 'eyJ0ZXN0IjoicXFzczExIn0=' } },
  request: 
   ClientRequest {
     domain: null,
     _events: 
      { socket: [Function],
        abort: [Function],
        aborted: [Function],
        error: [Function],
        timeout: [Function],
        prefinish: [Function: requestOnPrefinish] },
     _eventsCount: 6,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     upgrading: false,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: true,
     sendDate: false,
     _removedHeader: {},
     _contentLength: 0,
     _hasBody: true,
     _trailer: '',
     finished: true,
     _headerSent: true,
     socket: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 10,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'cloudiot.googleapis.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        destroyed: true,
        _bytesDispatched: 571,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        write: [Function: writeAfterFIN],
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1 },
     connection: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 10,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'cloudiot.googleapis.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        destroyed: true,
        _bytesDispatched: 571,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        write: [Function: writeAfterFIN],
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1 },
     _header: 'POST /v1/projects/nodemcuiot-76b3f/locations/u

如何从文档中提到的上述响应中获取deviceacktime https://cloud.google.com/iot/docs/reference/rest/v1/projects.locations.registries.devices/modifyCloudToDeviceConfig

它将使用deviceconfig进行响应,但我无法使用数据调试响应。

1 个答案:

答案 0 :(得分:1)

lastConfigAckTime来自设备元数据,而不是对modifyCloudToDeviceConfig的API调用。

Use the API explorer to experiment with retrieving your device。只需输入您的设备ID,例如projects/<your-project-id>/locations/<your-cloud-region>/registries/<your-registry-id>/devices/<your-device-id>

enter image description here

其他examples in various programming languages  可以在文档中找到。