I'm looking to integrate logging to the EEPROM in my custom movesense firmware. Reading the docs on the logging service, I've verified that I have the logging system configured with my custom whiteboard objects, and that logging is enabled (logging state is set to 3), with the following code:
WB_RES::DataLoggerConfig dConfig;
WB_RES::DataEntry dEntry, dEntry1;
WB_RES::DataLoggerStateValues::Type dlstate = WB_RES::DataLoggerStateValues::Type::DATALOGGER_LOGGING;
dEntry.path = "/App/Object1";
dEntry1.path = "/App/Object2";
dConfig.dataEntries.dataEntry = {dEntry, dEntry1};
result = asyncPut(WB_RES::LOCAL::MEM_DATALOGGER_CONFIG(), AsyncRequestOptions::Empty, dConfig);
if(!wb::RETURN_OKC(result))
DebugLogger::info("asyncPut::datalogger config threw error: %u", result);
result = asyncPut(WB_RES::LOCAL::MEM_DATALOGGER_STATE(), AsyncRequestOptions::Empty, dlstate);
if(!wb::RETURN_OKC(result))
DebugLogger::info("asyncPut::datalogger start threw error: %u", result);
The whiteboard object paths I have configured in the yaml file are:
paths: /App/Object1/Subscription:
<blah, post/delete actions defined>
paths: /App/Object2/Subscription:
<blah, post/delete actions defined>
First off, is this correct, in getting the movesense firmware to log these whiteboard objects? What is the relationship between the whiteboard path defined in the yaml file to the data entry path that we configure in the code? Do they have to match exactly?
Second, if I have the above correct, then are will the entries be automatically logged when I post a notification to the subscribed consumers (currently done in the onNotify() method), or will I have to create a specific wb::LogEntry object, and populate that, and then do an asyncPost to the MEM_LOGBOOK_ENTRIES() target, like so:
wb::LogEntry foo;
result = asyncPost(WB_RES::LOCAL::MEM_LOGBOOK_ENTRIES(), AsyncRequestOptions::Empty, foo);
If that is the case, are they any helper functions to help populate the wb::LogEntry object, since it looks like you need an id, timestamp, and then the whiteboard data object? Or do we have to generate those on our own?
Your basic idea is correct, but there are some details that are a bit off.
First the division of the two components, DataLogger and Logbook:
The DataLogger works by subscribing to the paths given in /Mem/DataLogger/Config and then storing the notifications of those subscriptions (there is no need to do anything with the /Logbook/Entries).
Simple flow:
--- Logging happens here ---
However there are some details wrong in your code. The result of the Config and State PUT operation comes in the onPutResult() callback. So to be sure that the configuration is correct you must trigger state change after you get status = 200 in the callback of the /Config PUT.
Also there are some limitations on what can be logged. mainly:
To see how the notification value objects are stored into the EEPROM see the /generated/sbem-code/sbem_definitions.cpp. If your type does not appear there, then something in your service yaml is preventing the serialization.
To try out the DataLogger & Logbook API's please see the DataLoggerSample Android app in movesense-mobile-lib repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With