def reset(device): libmetawear.mbl_mw_logging_stop(device.board) libmetawear.mbl_mw_logging_clear_entries(device.board) libmetawear.mbl_mw_macro_erase_all(device.board) libmetawear.mbl_mw_debug_reset_after_gc(device.board) print("Erase logger and clear all entries") sleep(1.0) libmetawear.mbl_mw_debug_disconnect(device.board) sleep(1.0)
def reset(device) -> None: """ This function resets your device if its stuck in a bad state :param device: :return None: """ # Stops data logging libmetawear.mbl_mw_logging_stop(device.board) # Clear the logger of saved entries libmetawear.mbl_mw_logging_clear_entries(device.board) # Remove all macros on the flash memory libmetawear.mbl_mw_macro_erase_all(device.board) # Restarts the board after performing garbage collection libmetawear.mbl_mw_debug_reset_after_gc(device.board) libmetawear.mbl_mw_debug_disconnect(device.board) device.disconnect()
for x in range(0, result['length']): wrapper = DataHandler(result['signals'].contents[x]) libmetawear.mbl_mw_anonymous_datasignal_subscribe( result['signals'].contents[x], wrapper.data_handler_fn) handlers.append(wrapper) def progress_update_handler(left, total): if (left == 0): dl_event.set() def unknown_entry_handler(id, epoch, data, length): print("unknown entry = " + str(id)) print("Downloading log") progress_update_fn = FnVoid_UInt_UInt(progress_update_handler) unknown_entry_fn = FnVoid_UByte_Long_UByteP_UByte(unknown_entry_handler) download_handler = LogDownloadHandler( received_progress_update=progress_update_fn, received_unknown_entry=unknown_entry_fn, received_unhandled_entry=cast(None, FnVoid_DataP)) libmetawear.mbl_mw_logging_download(metawear.board, 10, byref(download_handler)) dl_event.wait() print("Download completed") libmetawear.mbl_mw_macro_erase_all(metawear.board) libmetawear.mbl_mw_debug_reset_after_gc(metawear.board) libmetawear.mbl_mw_debug_disconnect(metawear.board) sleep(1.0)