MetaWear C++ API  0.18.0
C++ implementation of the MetaWear protocol
metawearboard.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <stdint.h>
9 
11 #include "metawearboard_fwd.h"
12 #include "model.h"
13 #include "module.h"
14 
17 
19 const int32_t MBL_MW_MODULE_TYPE_NA = -1;
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
30 typedef struct {
31  const char* manufacturer;
32  const char* model_number;
33  const char* serial_number;
34  const char* firmware_revision;
35  const char* hardware_revision;
37 
38 typedef struct {
39  const char* name;
40  const uint8_t* extra;
41  uint8_t extra_len;
42  uint8_t present;
43  uint8_t implementation;
44  uint8_t revision;
46 
64 METAWEAR_API void mbl_mw_metawearboard_set_time_for_response(MblMwMetaWearBoard* board, uint16_t response_time_ms);
83 
109 
117 
124 METAWEAR_API uint8_t* mbl_mw_metawearboard_serialize(const MblMwMetaWearBoard* board, uint32_t* size);
132 METAWEAR_API int32_t mbl_mw_metawearboard_deserialize(MblMwMetaWearBoard* board, uint8_t* state, uint32_t size);
133 
142 
146 typedef struct {
147  void *context;
148  void (*on_dfu_started)(void *context);
149  void (*on_dfu_cancelled)(void *context);
150  void (*on_transfer_percentage)(void *context, int32_t percentage);
151  void (*on_successful_file_transferred)(void *context);
152  void (*on_error)(void *context, const char *errorMessage);
154 
161 METAWEAR_API void mbl_mw_metawearboard_perform_dfu(MblMwMetaWearBoard *board, const MblMwDfuDelegate *delegate, const char *filename);
162 
163 #ifdef __cplusplus
164 }
165 #endif
METAWEAR_API MblMwMetaWearBoard * mbl_mw_metawearboard_create(const MblMwBtleConnection *connection)
Creates an instance of the MblMwMetaWearBoard struct.
METAWEAR_API const MblMwDeviceInformation * mbl_mw_metawearboard_get_device_information(const MblMwMetaWearBoard *board)
Retrieves supported characteristics from the Device Information service.
METAWEAR_API void mbl_mw_metawearboard_tear_down(MblMwMetaWearBoard *board)
Removes all data processors and timers from the MetaWear board.
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 l...
Definition: metawearboard.h:38
struct MblMwMetaWearBoard MblMwMetaWearBoard
Software representation of a physical MetaWear board.
Definition: metawearboard_fwd.h:17
METAWEAR_API int32_t mbl_mw_metawearboard_deserialize(MblMwMetaWearBoard *board, uint8_t *state, uint32_t size)
Deserializes API state.
METAWEAR_API int32_t mbl_mw_metawearboard_is_initialized(const MblMwMetaWearBoard *board)
Checks if the board is initialized.
METAWEAR_API MblMwModel mbl_mw_metawearboard_get_model(const MblMwMetaWearBoard *board)
Determines the board model of the currently connected device.
METAWEAR_API int32_t mbl_mw_metawearboard_lookup_module(const MblMwMetaWearBoard *board, MblMwModule module)
Checks module type i.e.
const char * hardware_revision
Revision of the hardware on the device, characteristic 0x2A27.
Definition: metawearboard.h:35
MblMwModel
Available MetaWear models.
Definition: model.h:11
METAWEAR_API MblMwModuleInfo * mbl_mw_metawearboard_get_module_info(const MblMwMetaWearBoard *board, uint32_t *size)
Returns information about the onboard modules.
Macros for identifying exported functions.
METAWEAR_API const char * mbl_mw_metawearboard_get_model_name(const MblMwMetaWearBoard *board)
Determines the board model of the currently connected device.
Forward declarations for the MblMwMetaWearBoard type.
const char * model_number
Model number assigned by MbientLab, characteristic 0x2A24.
Definition: metawearboard.h:32
METAWEAR_API void mbl_mw_metawearboard_free(MblMwMetaWearBoard *board)
Frees the memory allocated for the struct.
void(* MblMwFnBoardPtrInt)(void *context, MblMwMetaWearBoard *board, int32_t value)
Definition for callback functions that accept an MblMwMetaWearBoard pointer and an int32...
Definition: metawearboard_fwd.h:26
Forward declaration for the MblMwAnonymousDataSignal type.
Platform agnostic wrappers for Bluetooth Low Energy communication.
const int32_t MBL_MW_MODULE_TYPE_NA
Constant signifying a module is not available.
Definition: metawearboard.h:19
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.
MblMwModule
Sensors or peripherals supported by the firmware.
Definition: module.h:12
const char * firmware_revision
Revision of the firmware on the device, characteristic 0x2A26.
Definition: metawearboard.h:34
METAWEAR_API void mbl_mw_metawearboard_initialize(MblMwMetaWearBoard *board, void *context, MblMwFnBoardPtrInt initialized)
Initialize the API&#39;s internal state.
Wrapper class containing functions for receiving callbacks throughout the DFU process.
Definition: metawearboard.h:146
Wrapper class holding characteristics under the Device Information GATT service.
Definition: metawearboard.h:30
const char * serial_number
Device&#39;s serial number, characteristic 0x2A25.
Definition: metawearboard.h:33
Wrapper class containing functions for communicating with the MetaWear through a Bluetooth Low Energy...
Definition: btle_connection.h:49
const char * manufacturer
Device&#39;s manufacturer name, characteristic 0x2A29.
Definition: metawearboard.h:31
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.
#define METAWEAR_API
Indicates the function should be exported to the symbol table.
Definition: dllmarker.h:27
METAWEAR_API uint8_t * mbl_mw_metawearboard_serialize(const MblMwMetaWearBoard *board, uint32_t *size)
Serializes the API state.
void(* MblMwFnAnonSignalArray)(void *context, MblMwMetaWearBoard *board, MblMwAnonymousDataSignal **anonymous_signals, uint32_t size)
Definition for callback functions that accept an MblMwMetaWearBoard pointer, MblMwAnonymousDataSignal...
Definition: anonymous_datasignal_fwd.h:27