SDK v3 Log Download Logic

Hi,
We have a problem adopting log download logic with the v3 changes.
In v2, we used "downloadLogAndStopLoggingAsync" result to batch process data after all entries are downloaded.
In v3, the equivalent seems to be mbl_mw_logging_download and mbl_mw_logger_subscribe. However, the mbl_mw_logger_subscribe callback gives us one entry at a time. Is there a way to know the last log entry is received so we can trigger a task complete source?

Thanks!

Comments

  • Hi Eric,

    We did use it as an template, but to be more specific to our problem using the example code.

    mbl_mw_logger_subscribe(temperatureSignal, bridge(obj: self)) { (context, data) in
    let _self: DeviceViewController = bridge(ptr: context!)
    _self.didGetTemperature(timestamp: data!.pointee.timestamp, entry: data!.pointee.valueAs())
    }

    The Startup example print the data once as it is invoked, but in our case, we are adding the data to array, and need to batch process the array after the whole log is received.
    We need to know if it's the last data in the mbl_mw_logger_subscribe callback to begin analysis, but we can't find a clear way to achieve this.

    Hope this explains our problem more clearly.

    Thanks!

  • Wrap your code with the proper tags so it renders correctly on the forum.

    The example code also tells you when the download has finished. This is implemented in the aforementioned doDownload function.
    https://github.com/mbientlab/MetaWear-SDK-iOS-macOS-tvOS/blob/master/StarterProject/Shared/DeviceViewController.swift#L56-#L70

  • I think I understand now, but I want to confirm is the execution order to received_progress_update is always after the relative mbl_mw_logger_subscribe callbacks? i.e Progress with entriesLeft == 0 would be called after the last subscribe data callback?

    Thank you for answering.

  • @rlin said:
    I think I understand now, but I want to confirm is the execution order to received_progress_update is always after the relative mbl_mw_logger_subscribe callbacks? i.e Progress with entriesLeft == 0 would be called after the last subscribe data callback?

    Thank you for answering.

    Yes

This discussion has been closed.