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 Over-the-Air (OtA) updates
To allow 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.
Update:
Enabled: true
{
"Update": {
"Enabled": true
}
}
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.
![]() |
Weather Station Using Public Web Service Using Meadow
|
![]() |
Build a WIFI Connected Clock Using Meadow
|
![]() |
Make a Meadow indoor/outdoor temperature/weather desk clock
|