MetaWear C++ API  0.18.0
C++ implementation of the MetaWear protocol
Classes | Functions | Variables
metawearboard.h File Reference

Functions for communicating with an MblMwMetaWearBoard object. More...

#include <stdint.h>
#include "anonymous_datasignal_fwd.h"
#include "metawearboard_fwd.h"
#include "model.h"
#include "module.h"
#include "metawear/platform/btle_connection.h"
#include "metawear/platform/dllmarker.h"

Go to the source code of this file.

Classes

struct  MblMwDeviceInformation
 Wrapper class holding characteristics under the Device Information GATT service. More...
 
struct  MblMwModuleInfo
 
struct  MblMwDfuDelegate
 Wrapper class containing functions for receiving callbacks throughout the DFU process. More...
 

Functions

METAWEAR_API MblMwMetaWearBoardmbl_mw_metawearboard_create (const MblMwBtleConnection *connection)
 Creates an instance of the MblMwMetaWearBoard struct. More...
 
METAWEAR_API void mbl_mw_metawearboard_free (MblMwMetaWearBoard *board)
 Frees the memory allocated for the struct. More...
 
METAWEAR_API void mbl_mw_metawearboard_set_time_for_response (MblMwMetaWearBoard *board, uint16_t response_time_ms)
 Sets how long the API should wait before a required response is received. More...
 
METAWEAR_API void mbl_mw_metawearboard_initialize (MblMwMetaWearBoard *board, void *context, MblMwFnBoardPtrInt initialized)
 Initialize the API's internal state. More...
 
METAWEAR_API void mbl_mw_metawearboard_tear_down (MblMwMetaWearBoard *board)
 Removes all data processors and timers from the MetaWear board. More...
 
METAWEAR_API int32_t mbl_mw_metawearboard_is_initialized (const MblMwMetaWearBoard *board)
 Checks if the board is initialized. More...
 
METAWEAR_API int32_t mbl_mw_metawearboard_lookup_module (const MblMwMetaWearBoard *board, MblMwModule module)
 Checks module type i.e. More...
 
METAWEAR_API MblMwModel mbl_mw_metawearboard_get_model (const MblMwMetaWearBoard *board)
 Determines the board model of the currently connected device. More...
 
METAWEAR_API const char * mbl_mw_metawearboard_get_model_name (const MblMwMetaWearBoard *board)
 Determines the board model of the currently connected device. More...
 
METAWEAR_API const MblMwDeviceInformationmbl_mw_metawearboard_get_device_information (const MblMwMetaWearBoard *board)
 Retrieves supported characteristics from the Device Information service. More...
 
METAWEAR_API MblMwModuleInfombl_mw_metawearboard_get_module_info (const MblMwMetaWearBoard *board, uint32_t *size)
 Returns information about the onboard modules. More...
 
METAWEAR_API uint8_t * mbl_mw_metawearboard_serialize (const MblMwMetaWearBoard *board, uint32_t *size)
 Serializes the API state. More...
 
METAWEAR_API int32_t mbl_mw_metawearboard_deserialize (MblMwMetaWearBoard *board, uint8_t *state, uint32_t size)
 Deserializes API state. More...
 
METAWEAR_API void mbl_mw_metawearboard_create_anonymous_datasignals (MblMwMetaWearBoard *board, void *context, MblMwFnAnonSignalArray created)
 Reads the current state of the board and creates anonymous data signals based on what data is being logged, If this task failed, a null pointer will be passed into the anonymous_signals parameter. More...
 
METAWEAR_API void mbl_mw_metawearboard_perform_dfu (MblMwMetaWearBoard *board, const MblMwDfuDelegate *delegate, const char *filename)
 Starts the DFU process and updloads the given file to the device. More...
 

Variables

const int32_t MBL_MW_MODULE_TYPE_NA = -1
 Constant signifying a module is not available.
 

Detailed Description

Functions for communicating with an MblMwMetaWearBoard object.

Function Documentation

◆ mbl_mw_metawearboard_create()

METAWEAR_API MblMwMetaWearBoard* mbl_mw_metawearboard_create ( const MblMwBtleConnection connection)

Creates an instance of the MblMwMetaWearBoard struct.

Parameters
connectionConnection struct the new MblMwMetaWearBoard variable will use for btle communication
Returns
Pointer to the newly created struct

◆ mbl_mw_metawearboard_create_anonymous_datasignals()

METAWEAR_API void mbl_mw_metawearboard_create_anonymous_datasignals ( MblMwMetaWearBoard board,
void *  context,
MblMwFnAnonSignalArray  created 
)

Reads the current state of the board and creates anonymous data signals based on what data is being logged, If this task failed, a null pointer will be passed into the anonymous_signals parameter.

Parameters
boardCalling object
contextPointer to additional data for the callback function
createdCallback function to be executed once the task is completed.

◆ mbl_mw_metawearboard_deserialize()

METAWEAR_API int32_t mbl_mw_metawearboard_deserialize ( MblMwMetaWearBoard board,
uint8_t *  state,
uint32_t  size 
)

Deserializes API state.

This function must be executed before calling mbl_mw_metawearboard_initialize.

Parameters
boardBoard to deserialize
stateByte array holding the the information state
sizeByte array size
Returns
MBL_MW_STATUS_OK if successful, MBL_MW_STATUS_ERROR_SERIALIZATION_FORMAT if failed

◆ mbl_mw_metawearboard_free()

METAWEAR_API void mbl_mw_metawearboard_free ( MblMwMetaWearBoard board)

Frees the memory allocated for the struct.

Parameters
boardPointer to the memory to free

◆ mbl_mw_metawearboard_get_device_information()

METAWEAR_API const MblMwDeviceInformation* mbl_mw_metawearboard_get_device_information ( const MblMwMetaWearBoard board)

Retrieves supported characteristics from the Device Information service.

The memory allocated by the function must be freed by calling mbl_mw_memory_free.

Returns
Struct holding the characteristics

◆ mbl_mw_metawearboard_get_model()

METAWEAR_API MblMwModel mbl_mw_metawearboard_get_model ( const MblMwMetaWearBoard board)

Determines the board model of the currently connected device.

Only call this function after the board has been initialized.

Returns
Board model, MBL_MW_MODEL_NA if unable to determine

◆ mbl_mw_metawearboard_get_model_name()

METAWEAR_API const char* mbl_mw_metawearboard_get_model_name ( const MblMwMetaWearBoard board)

Determines the board model of the currently connected device.

Only call this function after the board has been initialized.

Returns
Friendly name representing the board model

◆ mbl_mw_metawearboard_get_module_info()

METAWEAR_API MblMwModuleInfo* mbl_mw_metawearboard_get_module_info ( const MblMwMetaWearBoard board,
uint32_t *  size 
)

Returns information about the onboard modules.

Parameters
boardCalling object
sizePointer to where the size of the returned array will be written to
Returns
Array of info objects

◆ mbl_mw_metawearboard_initialize()

METAWEAR_API void mbl_mw_metawearboard_initialize ( MblMwMetaWearBoard board,
void *  context,
MblMwFnBoardPtrInt  initialized 
)

Initialize the API's internal state.

This function is non-blocking and will alert the caller when the operation is complete.

Parameters
boardBoard to initialize
contextPointer to additional data for the callback function
initializedCallback function to be executed when the board is initialized

◆ mbl_mw_metawearboard_is_initialized()

METAWEAR_API int32_t mbl_mw_metawearboard_is_initialized ( const MblMwMetaWearBoard board)

Checks if the board is initialized.

Parameters
boardBoard to check
Returns
Zero if not initialized, non-zero if it is

◆ mbl_mw_metawearboard_lookup_module()

METAWEAR_API int32_t mbl_mw_metawearboard_lookup_module ( const MblMwMetaWearBoard board,
MblMwModule  module 
)

Checks module type i.e.

what kind of accelerometer is being used

Parameters
boardBoard to check
moduleModule to lookup
Returns
Module type used by the board, MBL_MW_MODULE_TYPE_NA if module is not available
See also
MBL_MW_MODULE_ACC_TYPE_MMA8452Q
MBL_MW_MODULE_ACC_TYPE_BMI160

◆ mbl_mw_metawearboard_perform_dfu()

METAWEAR_API void mbl_mw_metawearboard_perform_dfu ( MblMwMetaWearBoard board,
const MblMwDfuDelegate delegate,
const char *  filename 
)

Starts the DFU process and updloads the given file to the device.

Parameters
boardCalling object
delegateStruct the function will forward DFU progress updates to
filenamePath to firmware bin file

◆ mbl_mw_metawearboard_serialize()

METAWEAR_API uint8_t* mbl_mw_metawearboard_serialize ( const MblMwMetaWearBoard board,
uint32_t *  size 
)

Serializes the API state.

The memory allocated by the function must be freed by calling mbl_mw_memory_free.

Parameters
boardBoard to serialize
sizePointer to where the size of the returned byte array will be written to
Returns
Byte array of the serialized state

◆ mbl_mw_metawearboard_set_time_for_response()

METAWEAR_API void mbl_mw_metawearboard_set_time_for_response ( MblMwMetaWearBoard board,
uint16_t  response_time_ms 
)

Sets how long the API should wait before a required response is received.

You should increase this value if operations such as API initialization, creating timer, loggers, and data processors, and recording commands consistently time out.

Parameters
boardBoard to configure
response_time_msHow long to wait for a response, from [0, 4000]ms. Use 0ms for indefinite timeout

◆ mbl_mw_metawearboard_tear_down()

METAWEAR_API void mbl_mw_metawearboard_tear_down ( MblMwMetaWearBoard board)

Removes all data processors and timers from the MetaWear board.

Parameters
boardBoard to tear down