An event is an asynchronous notification from the MetaWear board represented in the C++ API by the MblMwEvent struct.

Recording Commands

The board can be programmed to execute MetaWear commands in response to an event firing.

An event can be many things such as a data filter (average the accelerometer signal), a disconnect (the board has disconnected from the Bluetooth link), or even a timer (10 seconds have passed).

To start recording commands, call mbl_mw_event_record_commands. While in a recording state, all MetaWear functions called will instead be recorded on the board and executed when the event is fired.

To stop recording, call eventEndRecord(). It returns a Task from Bolts.

In this example, when the board is put to sleep, the led blinks blue:

// LED Feedback to indicate success
metawear.flashLED(color: .blue, intensity: 1.0, _repeat: 10)

// Powerdown the board

// Reset it after a few seconds to let the flashing finish
metawear.timerCreate(period: MSEC_TO_FLASH, repetitions: 1, immediateFire: false).continueOnSuccessWith { timer in
    timer.eventEndRecord().continueOnSuccessWith { _ in