Skip to main content

Application Settings Configuration

The app.config.yaml or app.config.json files can be used to configure application settings for logging and reboot configuration. You can also add custom developer application settings.

Either an app.config.yaml or app.config.json file can be used to set application configuration settings and custom developer settings. The filenames are case sensitive.

You can you one or the other, or both. If both application configuration files are used, the values in app.config.yaml are applied first and then any values in app.config.json are applied next. (Any settings provided in both will be overridden by the JSON file.)

Remember to set Copy to Output Directory to Copy always in the properties pane of any configuration files.

Lifecycle Configuration - Automatic Reboot

If you need Meadow to relaunch your app should it fail, the Lifecycle settings allow you to configure that behavior.

First, set RestartOnAppFailure to true. Then, you can optionally configure a delay, in seconds, before restart using the AppFailureRestartDelaySeconds setting.

For example, to configure Meadow to wait 15 seconds after a failure before rebooting your application, here is the configuration in YAML.

Lifecycle:
RestartOnAppFailure: true
AppFailureRestartDelaySeconds: 15

And here is the same configuration in JSON.

{
"Lifecycle": {
"RestartOnAppFailure": true,
"AppFailureRestartDelaySeconds": 15
}
}

Logging Configuration

Logging configuration allows you to customize the level of data your Meadow application will log to its output channel.

The log level default aligns with the .NET options: Trace, Debug, Information, Warning, and Error.

Logging:
LogLevel:
Default: "Trace"
{
"Logging": {
"LogLevel": {
"Default": "Trace"
}
}
}

Enable Meadow.Cloud features and Over-the-Air (OtA) updates

To allow Meadow.Cloud basic features (Logging, Events and Command + Control) and over-the-air (OtA) updates to your Meadow application, add the following configuration to your application's app.config.yaml or app.config.json file.

# Meadow.Cloud configuration.
MeadowCloud:

# Enable Logging, Events, Command + Control
Enabled: true

# Enable Over-the-air Updates
EnableUpdates: true

# Enable Health Metrics
EnableHealthMetrics: true

# How often to send metrics to Meadow.Cloud
HealthMetricsIntervalMinutes: 15
{
"MeadowCloud": {
"Enabled": true,
"EnableUpdates": true,
"EnableHealthMetrics": true,
"HealthMetricsIntervalMinutes": 15
}
}

You can learn more about enabling and responding to OtA updates in your Meadow application from the Over-the-Air Updates documentation.

Custom Developer Application Settings

You can also configure custom application settings that can then be retrieved at runtime through a strongly-typed system.

First, you need your settings added to the app.config.yaml or app.config.json file. You can name the container object whatever you want.

BlinkyApp:
DoAwesomeThings: true
TimeInSecondsBeforeAwesome: 3
{
"BlinkyApp": {
"DoAwesomeThings": true,
"TimeInSecondsBeforeAwesome": 3
}
}

Make sure your configuration file is set to copy to the output directory.

With the configuration settings included, you'll need a settings class to handle the setting retrieval and parsing. This is simplified by inheriting from the ConfigurableObject class, with a class name that matches the settings object name with Settings added. For the BlinkyApp example here, we need a class named BlinkyAppSettings.

public class BlinkyAppSettings : ConfigurableObject
{
public bool DoAwesomeThings => GetConfiguredBool(nameof(DoAwesomeThings), true);
public int TimeInSecondsBeforeAwesome => GetConfiguredInt(nameof(TimeInSecondsBeforeAwesome), 60);
}

Then within your Meadow app, you can retrieve your settings by creating an instance of your settings class. After the settings object is created, you can access your custom values.

Here's an example of doing that in the app's Initialize and Run overrides.

public class MeadowApp : App<F7FeatherV2>
{
MyCustomSettings customSettings;

public override Task Initialize()
{
customSettings = new MyCustomSettings();

return base.Initialize();
}

public override Task Run()
{
Console.WriteLine($"{nameof(customSettings.DoAwesomeThings)}: {customSettings.DoAwesomeThings}");
Console.WriteLine($"{nameof(customSettings.TimeInSecondsBeforeAwesome)}: {customSettings.TimeInSecondsBeforeAwesome}");

return base.Run();
}
}

Sample Apps

For an example of configuration in use, see the Config Files sample App in the Meadow.Core.Samples repo.

Photo showing a Meadow hooked up to an LCD displaying the date, time, indoor and outdoor temperature and a weather icon.

Weather Station Using Public Web Service Using Meadow
Learn how to connect your Meadow to your local network and get current weather conditions from a free public weather web service.

Video showing a vertical LED matrix showing the current date and then the current time when a button is pressed.

Build a WIFI Connected Clock Using Meadow
Build this nifty clock with Meadow getting the date and time from an NTP server via WIFI and room temperature with an LM35 Analog sensor.

Video showing a Meadow connected to a multi-line character display showing the date, time, indoor and outdoor temperatures, and a weather description.

Make a Meadow indoor/outdoor temperature/weather desk clock
Build this nifty clock for your desk that gives you time and date, along with room and outdoor temperature using a REST service.