> ## Documentation Index
> Fetch the complete documentation index at: https://launchpad.anxlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure ANX OS Firmware Settings and Options

> Customize ANX OS firmware behavior: set Wi-Fi credentials, configure the serial console, adjust power modes, and tune the real-time scheduler.

ANX OS reads a `config.json` file from the root of the device's LittleFS flash file system at boot time. Every configurable aspect of the firmware — network credentials, BLE identity, power behavior, and OTA preferences — lives in this single file. You can write or update `config.json` using the ANX CLI either by pushing a complete file, reading back the current state, or setting individual keys without touching the rest of the configuration.

## config.json Structure

Below is a complete `config.json` showing every supported section and a representative value for each field. All sections are optional; omitted sections fall back to their factory defaults.

```json config.json theme={null}
{
  "device": {
    "name": "my-anx-device",
    "log_level": "info"
  },
  "wifi": {
    "ssid": "MyNetwork",
    "password": "MyPassword",
    "mode": "station"
  },
  "ble": {
    "enabled": true,
    "device_name": "ANX-Device"
  },
  "power": {
    "mode": "balanced",
    "sleep_timeout_ms": 30000
  },
  "ota": {
    "channel": "stable",
    "auto_check": true,
    "check_interval_hours": 24
  }
}
```

## Configuration Reference

<Accordion title="device — Identity and Logging">
  The `device` section controls how the module identifies itself and how verbose its log output is.

  | Field       | Type   | Values                                   | Default        | Description                                                                                                                                                                                     |
  | ----------- | ------ | ---------------------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `name`      | string | Any alphanumeric string, hyphens allowed | `"anx-device"` | Human-readable label shown in `anx device info` and in BLE advertisements when no explicit BLE name is set.                                                                                     |
  | `log_level` | string | `"debug"`, `"info"`, `"warn"`, `"error"` | `"info"`       | Controls the minimum severity of messages written to the serial console. Set to `"debug"` for verbose output during development and `"warn"` or `"error"` in production to reduce UART traffic. |

  **Example:**

  ```json theme={null}
  "device": {
    "name": "workshop-sensor-01",
    "log_level": "debug"
  }
  ```
</Accordion>

<Accordion title="wifi — Wireless Network Settings">
  The `wifi` section configures how ANX OS connects to or hosts a wireless network. Wi-Fi must be configured here before OTA updates or any network-dependent SDK calls will work.

  | Field      | Type   | Values                          | Default     | Description                                                                                                                                                          |
  | ---------- | ------ | ------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `ssid`     | string | Any valid SSID (up to 32 chars) | `""`        | The name of the Wi-Fi network to connect to (station mode) or broadcast (AP mode).                                                                                   |
  | `password` | string | WPA2/WPA3 passphrase            | `""`        | Network passphrase. Leave empty for open networks.                                                                                                                   |
  | `mode`     | string | `"station"`, `"ap"`, `"off"`    | `"station"` | `station` joins an existing network. `ap` creates a hosted access point using the provided SSID and password. `off` disables the Wi-Fi radio entirely to save power. |

  **Example — joining a home network:**

  ```json theme={null}
  "wifi": {
    "ssid": "HomeNetwork",
    "password": "SuperSecret99",
    "mode": "station"
  }
  ```

  **Example — hosting an access point:**

  ```json theme={null}
  "wifi": {
    "ssid": "ANX-Setup",
    "password": "configure-me",
    "mode": "ap"
  }
  ```
</Accordion>

<Accordion title="ble — Bluetooth Low Energy Settings">
  The `ble` section controls the Bluetooth 5.0 stack. BLE and Wi-Fi can operate simultaneously without additional configuration.

  | Field         | Type    | Values                    | Default        | Description                                                                                    |
  | ------------- | ------- | ------------------------- | -------------- | ---------------------------------------------------------------------------------------------- |
  | `enabled`     | boolean | `true`, `false`           | `true`         | Enables or disables the BLE radio. Set to `false` to save power when BLE is not needed.        |
  | `device_name` | string  | Any string up to 29 chars | `"ANX-Device"` | The GAP device name broadcast in BLE advertisements. Visible to scanning phones and computers. |

  **Example:**

  ```json theme={null}
  "ble": {
    "enabled": true,
    "device_name": "TemperatureSensor-Kitchen"
  }
  ```
</Accordion>

<Accordion title="power — Power Mode and Sleep Behavior">
  The `power` section lets you trade off between compute performance and battery life. All modes are fully compatible with both Wi-Fi and BLE.

  | Field              | Type    | Values                                       | Default      | Description                                                                                                                                                                                                            |
  | ------------------ | ------- | -------------------------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `mode`             | string  | `"performance"`, `"balanced"`, `"low-power"` | `"balanced"` | Sets the CPU frequency and peripheral clock gating strategy. `performance` runs the CPU at maximum frequency. `balanced` dynamically scales frequency with load. `low-power` aggressively clocks down idle subsystems. |
  | `sleep_timeout_ms` | integer | Milliseconds ≥ 0                             | `30000`      | Time in milliseconds of inactivity before the module enters light sleep. Set to `0` to disable automatic sleep entirely.                                                                                               |

  **Example — battery-powered sensor:**

  ```json theme={null}
  "power": {
    "mode": "low-power",
    "sleep_timeout_ms": 5000
  }
  ```
</Accordion>

<Accordion title="ota — Over-the-Air Update Preferences">
  The `ota` section controls which firmware release channel the device tracks and whether it checks for updates automatically in the background.

  | Field                  | Type    | Values                            | Default    | Description                                                                                                     |
  | ---------------------- | ------- | --------------------------------- | ---------- | --------------------------------------------------------------------------------------------------------------- |
  | `channel`              | string  | `"stable"`, `"beta"`, `"nightly"` | `"stable"` | The release channel the OTA engine polls when checking for updates. Use `"stable"` for production devices.      |
  | `auto_check`           | boolean | `true`, `false`                   | `true`     | When `true`, the device checks for updates in the background at the interval defined by `check_interval_hours`. |
  | `check_interval_hours` | integer | Hours ≥ 1                         | `24`       | How often the device contacts the ANX update server when `auto_check` is enabled.                               |

  **Example — stable channel, daily check:**

  ```json theme={null}
  "ota": {
    "channel": "stable",
    "auto_check": true,
    "check_interval_hours": 24
  }
  ```
</Accordion>

## Writing Config to Your Device

Push a local `config.json` file to the device's flash file system with the `anx config write` command:

```bash theme={null}
anx config write config.json
```

To read back the configuration currently stored on the device:

```bash theme={null}
anx config read
```

The CLI prints the live `config.json` content to stdout, which you can redirect to a local file for editing:

```bash theme={null}
anx config read > config.json
```

## Setting Individual Values

You can update a single configuration field without editing or re-uploading the entire file using dot-notation keys:

```bash theme={null}
anx config set wifi.ssid "HomeNetwork"
anx config set wifi.password "Secret123"
```

This is useful for quickly rotating credentials or toggling a flag during development without replacing the whole configuration. Chain multiple `set` calls to update several fields at once:

```bash theme={null}
anx config set device.log_level "debug"
anx config set power.mode "low-power"
anx config set ota.check_interval_hours 12
```

<Note>
  Configuration changes written via `anx config write` or `anx config set` take effect on the **next reboot**. Apply them immediately by running `anx device reboot` after making your changes.
</Note>
