Logging

Logging functions in the logging.h header file control the on-board logger. These functions go hand in hand with the data signal logger outlined in the Data Signal section. After you have setup the signal loggers, start the logger by calling mbl_mw_logging_start.

#include "metawear/core/logging.h"

void start_logging(MblMwMetaWearBoard* board) {
    mbl_mw_logging_start(board);
}

Downloading Data

When you are ready to retrieve the data, execute mbl_mw_logging_download. You will need to pass in a MblMwLogDownloadHandler struct to handle notifications from the logger.

#include "metawear/core/logging.h"

void download_log_data(MblMwMetaWearBoard* board) {
    static auto progress_update = [](uint32_t entries_left, uint32_t total_entries)-> void {
        printf("download progress= %d / %d\n", entries_left, total_entries);
        if (!entries_left) {
            printf("download complete\n");
        }
    };
    static auto unknown_entry = [](uint8_t id, int64_t epoch, const uint8_t* data, uint8_t length) -> void {
        printf("received unknown log entry: id= %d\n", id);
    };

    static MblMwLogDownloadHandler download_handler = { progress_update, unknown_entry };
    // start a log download and send 100 progress notifications
    mbl_mw_logging_download(board, 100, &download_handler);
}