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

时间:2019-04-29 13:28:33

标签: movesense

我希望使用定制的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回调函数中收到了whiteboard :: ByteStream对象,但我不知道如何从中获取正确的偏移量信息。

我发现许多方法似乎与ByteStream.h中字节数的不同方面有关(长度,fullSize,已传输,payloadSize和serializationLength),但我只是无法使其正常工作。

基本上,我想在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;
}

1 个答案:

答案 0 :(得分:0)

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

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,然后您将获得下一个条目。

可能有点晦涩难懂,但请执行另一个asyncGet操作,直到获得HTTP_OK或HTTP错误代码为止。

另外,请注意,您需要解码数据,可以在in this answer

中找到python脚本。