MetaWear C# SDK  1.0.0
C# API for MbientLab's sensor platform
Public Member Functions | Properties | List of all members
MbientLab.MetaWear.IMetaWearBoard Interface Reference

Software representation of all MbientLab sensor boards. More...

Public Member Functions

Task InitializeAsync ()
 Connect to the remote device and perpares the internal API state to communicate with the modules. More...
 
Task DisconnectAsync ()
 Disconnects from the MetaWear device More...
 
Task< DeviceInformationReadDeviceInformationAsync ()
 Reads supported characteristics from the Device Information service More...
 
Task< byte > ReadBatteryLevelAsync ()
 Reads the battery level characteristic More...
 
GetModule< T > ()
 Retrieves a reference to the requested module if supported. More...
 
Task< IDictionary > GetModuleInfoAsync (IDictionary partial)
 Queries all info registers. If the task times out, you can run the task again using the partially completed result from the previous execution so the function does not need to query all modules again. More...
 
Task SerializeAsync ()
 Serialize object state and write the state to the local disk More...
 
Task DeserializeAsync ()
 Restore serialized state from the local disk if available More...
 
Task< IScheduledTaskScheduleAsync (uint period, ushort repititions, bool delay, Action commands)
 Schedule a task to be indefinitely executed on-board at fixed intervals for a specific number of repetitions More...
 
Task< IScheduledTaskScheduleAsync (uint period, bool delay, Action commands)
 Schedule a task to be indefinitely executed on-board at fixed intervals indefinitely More...
 
IScheduledTask LookupScheduledTask (byte id)
 Retrieves a scheduled task More...
 
Task< IList< IAnonymousRoute > > CreateAnonymousRoutesAsync ()
 Reads the current state of the board and creates anonymous routes based on what data is being logged More...
 
IObserver LookupObserver (uint id)
 Retrieves an observer More...
 
IRoute LookupRoute (uint id)
 Retrieves a route More...
 
void TearDown ()
 Removes all routes and resources allocated on the board (observers, data processors, timers, and loggers) More...
 

Properties

string MacAddress [get]
 Unique MAC address identifying the board More...
 
bool InMetaBootMode [get]
 True if the board is in MetaBoot (bootloader) mode.
More...
 
Model Model [get]
 Gets the model of the connected board, returns null if unable to determine More...
 
String ModelString [get]
 Gets the string representation of the board's model, null if unable to determine More...
 
Action OnUnexpectedDisconnect [get, set]
 Called when the connection is unexpectedly lost i.e. not requested by the API More...
 
int TimeForResponse [set]
 How long the API should wait (in milliseconds) before a required response is received More...
 
bool IsConnected [get]
 True if the board is currently connected to the host device More...
 

Detailed Description

Software representation of all MbientLab sensor boards.

Call InitializeAsync before using any other functions or reading the properties.

Member Function Documentation

◆ CreateAnonymousRoutesAsync()

Task<IList<IAnonymousRoute> > MbientLab.MetaWear.IMetaWearBoard.CreateAnonymousRoutesAsync ( )

Reads the current state of the board and creates anonymous routes based on what data is being logged

Returns
List of created anonymous route objects

◆ DeserializeAsync()

Task MbientLab.MetaWear.IMetaWearBoard.DeserializeAsync ( )

Restore serialized state from the local disk if available

Returns
Null when the object state is restored

◆ DisconnectAsync()

Task MbientLab.MetaWear.IMetaWearBoard.DisconnectAsync ( )

Disconnects from the MetaWear device

This method is only meaningful for non Windows 10 applications due to quirks with Win10's BLE stack. For consistent behavior across all platforms, use the IDebug.DisconnectAsync instead to terminate the connection

Returns
Null when the connection is closed

◆ GetModule< T >()

T MbientLab.MetaWear.IMetaWearBoard.GetModule< T > ( )

Retrieves a reference to the requested module if supported.

The API must be initialized before calling this function and it cannot be used if the board is in MetaBoot mode.

Template Parameters
TInterface derived from IModule to lookup
Returns
Reference to the requested module, null if the board is not connected, module not supported, or board is in MetaBoot mode
Type Constraints
T :class 
T :IModule 

◆ GetModuleInfoAsync()

Task<IDictionary> MbientLab.MetaWear.IMetaWearBoard.GetModuleInfoAsync ( IDictionary  partial)

Queries all info registers. If the task times out, you can run the task again using the partially completed result from the previous execution so the function does not need to query all modules again.

Parameters
partialResult of previously queried module info results, set to null to query all modules
Returns
Module information contained in a string indexed dictionary
Exceptions
TaskTimeoutExceptionIf the module responses take too long, partial result is included with this exception

◆ InitializeAsync()

Task MbientLab.MetaWear.IMetaWearBoard.InitializeAsync ( )

Connect to the remote device and perpares the internal API state to communicate with the modules.

Parameters
timeoutHow long to wait (in milliseconds) for initialization to complete
Returns
Null once the SDK is initialized
Exceptions
TimeoutExceptionIf initialization takes too long, timeout can be increased with the TimeForResponse property
InvalidOperationExceptionIf the host device failed to establish a connection

◆ LookupObserver()

IObserver MbientLab.MetaWear.IMetaWearBoard.LookupObserver ( uint  id)

Retrieves an observer

Parameters
idNumerical ID to look up
Returns
IObserver corresponding to the specified ID, null if none can be found

◆ LookupRoute()

IRoute MbientLab.MetaWear.IMetaWearBoard.LookupRoute ( uint  id)

Retrieves a route

Parameters
idNumerical ID to look up
Returns
IRoute corresponding to the specified ID, null if none can be found

◆ LookupScheduledTask()

IScheduledTask MbientLab.MetaWear.IMetaWearBoard.LookupScheduledTask ( byte  id)

Retrieves a scheduled task

Parameters
idNumerical ID to lookup
Returns
IScheduledTask corresonding to the specified ID, null if non can be found

◆ ReadBatteryLevelAsync()

Task<byte> MbientLab.MetaWear.IMetaWearBoard.ReadBatteryLevelAsync ( )

Reads the battery level characteristic

Returns
Value of the characteristic

◆ ReadDeviceInformationAsync()

Task<DeviceInformation> MbientLab.MetaWear.IMetaWearBoard.ReadDeviceInformationAsync ( )

Reads supported characteristics from the Device Information service

Returns
Object encapsulating the device information

◆ ScheduleAsync() [1/2]

Task<IScheduledTask> MbientLab.MetaWear.IMetaWearBoard.ScheduleAsync ( uint  period,
ushort  repititions,
bool  delay,
Action  commands 
)

Schedule a task to be indefinitely executed on-board at fixed intervals for a specific number of repetitions

Parameters
periodHow often to execute the task, in milliseconds
repititionsHow many times to execute the task
delayTrue if first execution should be delayed by one period
commandsMetaWear commands comprising the task
Returns
IScheduledTask object representing the newly scheduled task
Exceptions
TimeoutExceptionIf creating the timer or programming the commands timed out

◆ ScheduleAsync() [2/2]

Task<IScheduledTask> MbientLab.MetaWear.IMetaWearBoard.ScheduleAsync ( uint  period,
bool  delay,
Action  commands 
)

Schedule a task to be indefinitely executed on-board at fixed intervals indefinitely

Parameters
periodHow often to execute the task, in milliseconds
delayTrue if first execution should be delayed by one period
commandsMetaWear commands comprising the task
Returns
IScheduledTask object representing the newly scheduled task
Exceptions
TimeoutExceptionIf creating the timer or programming the commands timed out

◆ SerializeAsync()

Task MbientLab.MetaWear.IMetaWearBoard.SerializeAsync ( )

Serialize object state and write the state to the local disk

Returns
Null when the object state is saved

◆ TearDown()

void MbientLab.MetaWear.IMetaWearBoard.TearDown ( )

Removes all routes and resources allocated on the board (observers, data processors, timers, and loggers)

Property Documentation

◆ InMetaBootMode

bool MbientLab.MetaWear.IMetaWearBoard.InMetaBootMode
get

True if the board is in MetaBoot (bootloader) mode.

If it is, you will not be able to interact with the board except to update firmware

◆ IsConnected

bool MbientLab.MetaWear.IMetaWearBoard.IsConnected
get

True if the board is currently connected to the host device

◆ MacAddress

string MbientLab.MetaWear.IMetaWearBoard.MacAddress
get

Unique MAC address identifying the board

◆ Model

Model MbientLab.MetaWear.IMetaWearBoard.Model
get

Gets the model of the connected board, returns null if unable to determine

◆ ModelString

String MbientLab.MetaWear.IMetaWearBoard.ModelString
get

Gets the string representation of the board's model, null if unable to determine

◆ OnUnexpectedDisconnect

Action MbientLab.MetaWear.IMetaWearBoard.OnUnexpectedDisconnect
getset

Called when the connection is unexpectedly lost i.e. not requested by the API

◆ TimeForResponse

int MbientLab.MetaWear.IMetaWearBoard.TimeForResponse
set

How long the API should wait (in milliseconds) before a required response is received


The documentation for this interface was generated from the following file: