0

我正在使用带有 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

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

它会用 deviceconfig 响应,但我无法用数据调试响应。

4

1 回答 1

1

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

使用 API 资源管理器尝试检索您的设备。只需输入您的设备 ID,例如projects/<your-project-id>/locations/<your-cloud-region>/registries/<your-registry-id>/devices/<your-device-id>

在此处输入图像描述

可以在文档中找到各种编程语言的其他示例。

于 2018-02-12T23:59:28.663 回答