.. highlight:: csharp IMetaWearBoard ============== The `IMetaWearBoard `_ interface is a software representation of the MbientLab sensor boards and is the central class of the MetaWear API. Initialization -------------- Before using any API features, first call `InitializeAsync `_ to initialize the object state. This function will also establish the Bluetooth LE connection and must be called after each disconnection. :: await metawear.InitializeAsync(); Console.WriteLine("Board initialized"); Unexpected Disconnects ^^^^^^^^^^^^^^^^^^^^^^ Sometimes the BLE connection will unexepectedly drop i.e. the BLE connection was not closed by the API. You can add a handler for such events by settng the `OnUnexpectedDisconnect `_ property. :: metawear.OnUnexpectedDisconnect = () => Console.WriteLine("Unexpectedly lost connection"); Model ----- Despite the name, the ``IMetaWearBoard`` interface communicates with all MetaSensor boards, not just MetaWear boards. Because of this, the interface provides a `Model `_ property that determines exactly which board the interface is currently connected to. :: Console.WriteLine("Board model: " + metawear.Model); GATT Characteristics -------------------- Some GATT characetristics (battery level, device information) can be read from the MetaWearBoard interface using `ReadBatteryLevelAsync `_ and `ReadDeviceInformationAsync `_ respectively. :: var deviceInfo = await board.ReadDeviceInformationAsync(); Console.WriteLine("Device Information: " + deviceInfo); Modules ------- MetaWear modules, represented by the `IModule `_ interface, are sensors, peripherals, or on-board firmware features. To interact with the underlying MetaWear modules, retrieve a reference to the desired interface with the `GetModule `_ method. A null pointer will be returned if any of the following conditions are true: * Requested module is not supported on the board * Board is in MetaBoot mode * Has not yet connected :: using MbientLab.MetaWear.Peripheral; ILed led; if ((led = metawear.GetModule()) == null) { Console.WriteLine("LED module is present on this board"); } Tear Down --------- When you are done using your board, call `TearDown `_ to remove resources allocated by the firmware and API such as routes, loggers, and data processors. this method does not reset the board so any configuration changes are preserved.