Logger¶
Loggers record data from a data signal and are represented by the
MblMwDataLogger struct. Create an
MblMwDataLogger
object by calling
mbl_mw_datasignal_log with the data signal
you want to log. If successful, the callback function will be executed with a
MblMwDataLogger pointer and if creating the
logger failed, a null pointer will be returned.
#include "metawear/core/datasignal.h"
#include "metawear/core/logging_fwd.h"
#include "metawear/sensor/multichanneltemperature.h"
auto temp_signal = mbl_mw_multi_chnl_temp_get_temperature_data_signal(board, 0);
mbl_mw_datasignal_log(temp_signal, [](MblMwDataLogger* logger) -> void {
if (logger != nullptr) {
printf("logger ready\n");
} else {
printf("Failed to create the logger\n");
}
});
MblMwDataLogger objects only interact with the specific data signal, they do not control the logging features. Logging control functions are detailed in the Logging section.
ID¶
MblMwDataLogger objects are identified by a numerical id; you can retrieve the id by calling mbl_mw_logger_get_id. The id is used to retrieve existing loggers from the API with the mbl_mw_logger_lookup_id function.
Handling Data¶
Like a data signal, you can subscribe to an MblMwDataLogger to process the downloaded data. Call mbl_mw_logger_subscribe to attach a callback function to the MblMwDataLogger which handles all received data.
void logger_subscribe(MblMwDataLogger* temp_logger) {
mbl_mw_logger_subscribe(temp_logger, [](const MblMwData* data) -> void {
printf("temperature= %.3fC\n", *((float*) data->value));
});
}
Removal¶
When you no longer want to log the values from a data signal, call mbl_mw_logger_remove to remove the logger.