日志只有returns个最新元素
Logbook only returns the latest element
尝试使用 Datalogger 和 Logbook 时,我在查询设备 Logbook 时只获取最新读数,而我希望获得保存的读数数组。
我正在尝试构建一个 1-Wire 读取应用程序来测试平台,我已经定义了一个订阅 API 非常类似于 /Meas/Temp
:
paths:
/OneWireTemp/Subscription:
post:
description: |
Subscribe to periodic temperature readings.
responses:
200:
description: Operation completed successfully
x-std-errors:
description: See common error codes http://developer.suunto.com/api/std-errors#subscribe
x-notification:
schema:
$ref: "#/definitions/TempMeasurement"
delete:
description: |
Unsubscribe to periodic temperature readings.
responses:
200:
description: Operation completed successfully
x-std-errors:
description: See common error codes http://developer.suunto.com/api/std-errors#unsubscribe
definitions:
TempMeasurement:
required:
- Timestamp
- Measurement
properties:
Timestamp:
description: Relative time of temperature reading
type: integer
format: uint32
x-unit: millisecond
Measurement:
description: Temperature reading
type: integer
format: int16
x-unit: celsius
我在设备端开始记录:
bool OneWireTempService::startDataLogger() {
WB_RES::DataEntry entry;
// Must match the subscription API path (without the /Subscription)
entry.path = "/OneWireTemp";
WB_RES::DataLoggerConfig dataLoggerConfig;
WB_RES::DataEntry entries[] = {entry};
dataLoggerConfig.dataEntries.dataEntry =
wb::MakeArray<WB_RES::DataEntry>(entries, 1);
wb::Result configureResult =
asyncPut(WB_RES::LOCAL::MEM_DATALOGGER_CONFIG(),
AsyncRequestOptions::Empty, dataLoggerConfig);
if (!wb::RETURN_OK(configureResult)) {
DebugLogger::error("Datalogger configuring failed: %u", configureResult);
return false;
}
wb::Result stateResult = asyncPut(
WB_RES::LOCAL::MEM_DATALOGGER_STATE(), AsyncRequestOptions::Empty,
WB_RES::DataLoggerStateValues::Type::DATALOGGER_LOGGING);
if (!wb::RETURN_OK(stateResult)) {
DebugLogger::error("Datalogger enabling failed: %u", stateResult);
return false;
}
return true;
}
我这样更新订阅:
WB_RES::TempMeasurement tempMeasurement;
tempMeasurement.measurement = mTempReading;
tempMeasurement.timestamp = currentTime;
updateResource(WB_RES::LOCAL::ONEWIRETEMP(), ResponseOptions::Empty,
tempMeasurement);
现在在 Android 端,我使用 MDS 库连接到设备,MDS/Logbook/{Serial}/Entries
returns 一段时间后的日志:{"elements": [{"Id": 2, "ModificationTimestamp": 1613406975, "Size": null}]}
.
现在查询MDS/Logbook/{Serial}/ById/2/Data
时,我只得到最新的测量值:{"OneWireTemp":{"Measurement":2536,"Timestamp":2794239193}}
。读数甚至不在数组中。
这是通过将结果包装在数组中解决的,然后数据记录器似乎明白日志中可以有多个条目:
paths:
/OneWireTemp/Subscription:
post:
description: |
Subscribe to periodic temperature readings.
responses:
200:
description: Operation completed successfully
x-std-errors:
description: See common error codes http://developer.suunto.com/api/std-errors#subscribe
x-notification:
schema:
$ref: "#/definitions/OneWireTempMeasurements"
delete:
description: |
Unsubscribe to periodic temperature readings.
responses:
200:
description: Operation completed successfully
x-std-errors:
description: See common error codes http://developer.suunto.com/api/std-errors#unsubscribe
definitions:
OneWireTempMeasurements:
required:
- Measurements
properties:
Measurements:
description: Wrapper array
type: array
items:
$ref: '#/definitions/OneWireTempMeasurement'
OneWireTempMeasurement:
required:
- Timestamp
- Measurement
properties:
Timestamp:
description: Relative time of temperature reading
type: integer
format: uint32
x-unit: millisecond
Measurement:
description: Temperature reading in celsius
type: integer
format: int16
x-unit: celsius
尝试使用 Datalogger 和 Logbook 时,我在查询设备 Logbook 时只获取最新读数,而我希望获得保存的读数数组。
我正在尝试构建一个 1-Wire 读取应用程序来测试平台,我已经定义了一个订阅 API 非常类似于 /Meas/Temp
:
paths:
/OneWireTemp/Subscription:
post:
description: |
Subscribe to periodic temperature readings.
responses:
200:
description: Operation completed successfully
x-std-errors:
description: See common error codes http://developer.suunto.com/api/std-errors#subscribe
x-notification:
schema:
$ref: "#/definitions/TempMeasurement"
delete:
description: |
Unsubscribe to periodic temperature readings.
responses:
200:
description: Operation completed successfully
x-std-errors:
description: See common error codes http://developer.suunto.com/api/std-errors#unsubscribe
definitions:
TempMeasurement:
required:
- Timestamp
- Measurement
properties:
Timestamp:
description: Relative time of temperature reading
type: integer
format: uint32
x-unit: millisecond
Measurement:
description: Temperature reading
type: integer
format: int16
x-unit: celsius
我在设备端开始记录:
bool OneWireTempService::startDataLogger() {
WB_RES::DataEntry entry;
// Must match the subscription API path (without the /Subscription)
entry.path = "/OneWireTemp";
WB_RES::DataLoggerConfig dataLoggerConfig;
WB_RES::DataEntry entries[] = {entry};
dataLoggerConfig.dataEntries.dataEntry =
wb::MakeArray<WB_RES::DataEntry>(entries, 1);
wb::Result configureResult =
asyncPut(WB_RES::LOCAL::MEM_DATALOGGER_CONFIG(),
AsyncRequestOptions::Empty, dataLoggerConfig);
if (!wb::RETURN_OK(configureResult)) {
DebugLogger::error("Datalogger configuring failed: %u", configureResult);
return false;
}
wb::Result stateResult = asyncPut(
WB_RES::LOCAL::MEM_DATALOGGER_STATE(), AsyncRequestOptions::Empty,
WB_RES::DataLoggerStateValues::Type::DATALOGGER_LOGGING);
if (!wb::RETURN_OK(stateResult)) {
DebugLogger::error("Datalogger enabling failed: %u", stateResult);
return false;
}
return true;
}
我这样更新订阅:
WB_RES::TempMeasurement tempMeasurement;
tempMeasurement.measurement = mTempReading;
tempMeasurement.timestamp = currentTime;
updateResource(WB_RES::LOCAL::ONEWIRETEMP(), ResponseOptions::Empty,
tempMeasurement);
现在在 Android 端,我使用 MDS 库连接到设备,MDS/Logbook/{Serial}/Entries
returns 一段时间后的日志:{"elements": [{"Id": 2, "ModificationTimestamp": 1613406975, "Size": null}]}
.
现在查询MDS/Logbook/{Serial}/ById/2/Data
时,我只得到最新的测量值:{"OneWireTemp":{"Measurement":2536,"Timestamp":2794239193}}
。读数甚至不在数组中。
这是通过将结果包装在数组中解决的,然后数据记录器似乎明白日志中可以有多个条目:
paths:
/OneWireTemp/Subscription:
post:
description: |
Subscribe to periodic temperature readings.
responses:
200:
description: Operation completed successfully
x-std-errors:
description: See common error codes http://developer.suunto.com/api/std-errors#subscribe
x-notification:
schema:
$ref: "#/definitions/OneWireTempMeasurements"
delete:
description: |
Unsubscribe to periodic temperature readings.
responses:
200:
description: Operation completed successfully
x-std-errors:
description: See common error codes http://developer.suunto.com/api/std-errors#unsubscribe
definitions:
OneWireTempMeasurements:
required:
- Measurements
properties:
Measurements:
description: Wrapper array
type: array
items:
$ref: '#/definitions/OneWireTempMeasurement'
OneWireTempMeasurement:
required:
- Timestamp
- Measurement
properties:
Timestamp:
description: Relative time of temperature reading
type: integer
format: uint32
x-unit: millisecond
Measurement:
description: Temperature reading in celsius
type: integer
format: int16
x-unit: celsius