The Settings module configures Bluetooth LE parameters and reports diagnostic information about the board.
Functions communicating with this module are defined in the settings.h header file.
The battery data provided by the Settings module reports both charge percentange and voltage, encapsulated by the MblMwBatteryState struct. Unlike the battery gatt servive, this battery data can be utilized with MetaWear features such as the logger.
var battSignal = MetaWear.mbl_mw_settings_get_battery_state_data_signal(device.board, ); MetaWear.mbl_mw_datasignal_read(battSignal);
The disconnect event is a type of MblMwEvent that is fired when the Bluetooth connection is terminated.
var disEvent = MetaWear.mbl_mw_settings_get_disconnect_event(device.board);
The default transmission power is 0db on the MetaWear. This is the Bluetooth radio signal strength when transmitting and can be changed with mbl_mw_settings_set_tx_power.
Valid values are: 4, 0, -4, -8, -12, -16, -20, -30:
Advertising parameters control how the Bluetooth radio sends its advertising data. You can modify the device name, timeout, tx power, and scan response. If you have set an timeout, you can manually begin another advertisement cycle by calling mbl_mw_settings_start_advertising.
MetaWear.mbl_mw_settings_set_ad_interval(device.board, 417, 180); MetaWear.mbl_mw_settings_start_advertising(device.board);
The advertised name of the device (default = MetaWear) can be changed with mbl_mw_settings_set_device_name.
let name = "METACOOL" MetaWear.mbl_mw_settings_set_device_name(device.board, name, name.length);
Connection parameters control how BTLE devices communicate with each other. Modifying the connection parameters are all handled at the same time by calling mbl_mw_settings_set_connection_parameters.
Connection interval = how often devices talk - min is 7.5ms, it increases in steps of 1.25ms - recommend setting min and max to same @ 7.5ms for performance.
Slave latency = metawear can choose not to answer when central asks for an update (i.e metawear can sleep longer - doesn’t affect transfer speeds).
Connection supervision timeout = determines timeout from last data exchange (tells central how long to wait to attempt to reconnect to a lost conn - if your metawear goes in and out of range often, it is better to have a short timeout)
Changing connection parameters is not guaranteed to work; Apple only accepts 15ms for example and will often default to 30ms.
A more detailed explanation of about BTLE connection parameters can be found on this post from the Nordic Developer Zone forums.
MetaWear.mbl_mw_settings_set_connection_parameters(device.board, 10.0, 1024.0, 0, 6000);
MMS 3V Regulator¶
The MMS (MetaMotion) board has a 3V regulator that can be turned on and off for IOs.
It is automatically turned on to power the coin vibration motor (if there is one attached), the ambient light sensor, and the LED.
However, if you have an external peripheral on the IOs that needs 3V power (such as a buzzer or UV sensor), you can use this function to turn on the power:
And to turn it off: