在自定义固件中获取日志描述符



我希望在自定义Movesense固件中使用LogBook获取记录的数据。收到HTTP_CONTINUE时,如何为下一个 GET 调用获取正确的字节流偏移量?

我正在尝试实现 DataStorage.md 中所述的这些步骤:

### /Logbook usage ###
To get recording from the Movesense sensors EEPROM storage, you need to:
1. Do **GET** on  */Logbook/Entries*. This returns a list of LogEntry objects. If the status was HTTP_OK, the list is complete. If the result code is HTTP_CONTINUE, you must GET again with the parameter StartAfterId set to the Id of the last entry you received and you'll get the next entries.
2. Choose the Log that you are interested in and notice the Id of it.
3. Fetch the descriptors with **GET** to */Logbook/byId/<Id>/Descriptors*. This returns a bytestream with the similar HTTP_CONTINUE handling as above. However you **must** keep re-requesting the **GET** until you get error or HTTP_OK, or the Logbook service will stay "in the middle of the stream" (we hope to remove this limitation in the future).
4. Fetch the data with **GET** to */Logbook/byId/<Id>/Data*. This returns also a bytestream (just like the */Logbook/Descriptors* above). 
5. Convert the data using the converter tools or classes. (To Be Continued...)

步骤 3 和 4 的问题基本相同。我在 onGetResult 回调函数中收到一个白板::ByteStream 对象,但我不知道如何从中获取正确的偏移量信息。

我发现了许多不同的方法,似乎涉及 ByteStream.h 中字节数的不同方面(长度、全尺寸、传输、有效载荷大小和序列化长度(,但我就是无法让它正常工作。

基本上我想在onGetResult中做这样的事情:

if (resultCode == whiteboard::HTTP_CODE_CONTINUE) {
    const whiteboard::ByteStream &byteStream = rResultData.convertTo<const whiteboard::ByteStream &>();
    currentEntryOffset += byteStream.length();
    asyncGet(WB_RES::LOCAL::MEM_LOGBOOK_BYID_LOGID_DESCRIPTORS(), AsyncRequestOptions::Empty, currentEntryIdToFetch, currentEntryOffset);
    return;
}

基本思想是再次执行相同的调用。因此,如果您这样做:

asyncGet(WB_RES::LOCAL::MEM_LOGBOOK_BYID_LOGID_DESCRIPTORS(),AsyncRequestOptions::Empty, currentEntryIdToFetch);

并HTTP_CONTINUE获得响应,请执行以下操作:

asyncGet(WB_RES::LOCAL::MEM_LOGBOOK_BYID_LOGID_DESCRIPTORS(),AsyncRequestOptions::Empty, currentEntryIdToFetch);

直到您出现HTTP_CONTINUE或错误。

如果结果代码HTTP_CONTINUE,则必须再次 GET,并将参数 StartAfterId 设置为收到的最后一个条目的 ID,您将获得下一个条目。

可能有点神秘,但执行另一个异步获取完全相同的资源,直到您获得HTTP_OK或 http 错误代码。

另外,请注意,您需要解码数据,在此答案中可以找到python脚本

最新更新