> Documentation index: https://openthread.io/reference/llms.txt

# Miscellaneous

This module includes platform abstractions for miscellaneous behaviors.

## Summary

| ### Enumerations ||
|---|---|
| `otPlatMcuPowerState{ OT_PLAT_MCU_POWER_STATE_ON = 0, OT_PLAT_MCU_POWER_STATE_LOW_POWER = 1, OT_PLAT_MCU_POWER_STATE_OFF = 2 }` | enumEnumeration of micro-controller's power states. |
| `otPlatResetReason` | enumEnumeration of possible reset reason codes. |

| ### Functions ||
|---|---|
| `otPlatAssertFail(const char *aFilename, int aLineNumber)` | `void` Provides a platform specific implementation for assert. |
| `otPlatGetBatteryLevel(otInstance *aInstance, uint8_t *aBatteryLevel)` | `otError` Gets the current battery level (percentage of remaining capacity). |
| `otPlatGetMcuPowerState(otInstance *aInstance)` | `otPlatMcuPowerState` Gets the current desired MCU power state. |
| `otPlatGetResetReason(otInstance *aInstance)` | `otPlatResetReason` Returns the reason for the last platform reset. |
| `otPlatGetSupplyVoltage(otInstance *aInstance, uint16_t *aSupplyVoltage)` | `otError` Gets the current supply voltage in millivolts (mV). |
| `otPlatLogCrashDump(void)` | `otError` Logs a crash dump using OpenThread logging APIs. |
| `otPlatReset(otInstance *aInstance)` | `void` Performs a software reset on the platform, if supported. |
| `otPlatResetToBootloader(otInstance *aInstance)` | `otError` Performs a hardware reset on the platform to launch bootloader mode, if supported. |
| `otPlatSetMcuPowerState(otInstance *aInstance, otPlatMcuPowerState aState)` | `otError` Sets the desired MCU power state. |
| `otPlatWakeHost(void)` | `void` Performs a platform specific operation to wake the host MCU. |

## Enumerations

### otPlatMcuPowerState

```
 otPlatMcuPowerState
```
Enumeration of micro-controller's power states.

These values are used for NCP configuration when `OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL` is enabled.

The power state specifies the desired power state of NCP's micro-controller (MCU) when the underlying platform's operating system enters idle mode (i.e., all active tasks/events are processed and the MCU can potentially enter a energy-saving power state).

The power state primarily determines how the host should interact with the NCP and whether the host needs an external trigger (a "poke") to NCP before it can communicate with the NCP or not.

After a reset, the MCU power state MUST be `OT_PLAT_POWER_STATE_ON`.

| Properties ||
|---|---|
| `OT_PLAT_MCU_POWER_STATE_LOW_POWER` | NCP's MCU can enter low-power (energy-saving) state. When the NCP's desired power state is set to `LOW_POWER`, host is expected to "poke" the NCP (e.g., an external trigger like an interrupt) before it can communicate with the NCP (send a message to the NCP). The "poke" mechanism is determined by the platform code (based on NCP's interface to the host). While power state is set to `LOW_POWER`, NCP can still (at any time) send messages to host. Note that receiving a message from the NCP does NOT indicate that the NCP's power state has changed, i.e., host is expected to continue to "poke" when it wants to talk to the NCP until the power state is explicitly changed (by a successful call to `otPlatSetMcuPowerState()` changing the state to `ON`). > [!NOTE] > **Note:** The `LOW_POWER` power state only determines the MCU's power mode and is not related to radio's state (radio is managed by OpenThread core and device role, e.g., device being sleepy or not. <br /> |
| `OT_PLAT_MCU_POWER_STATE_OFF` | NCP is fully off. An NCP hardware reset (via a RESET pin) is required to bring the NCP back to `SPINEL_MCU_POWER_STATE_ON`. RAM is not retained after reset. |
| `OT_PLAT_MCU_POWER_STATE_ON` | NCP's MCU stays on and active all the time. When the NCP's desired power state is set to `ON`, host can send messages to NCP without requiring any "poke" or external triggers. > [!NOTE] > **Note:** The `ON` power state only determines the MCU's power mode and is not related to radio's state. <br /> |

### otPlatResetReason

```
 otPlatResetReason
```
Enumeration of possible reset reason codes.

These are in the same order as the Spinel reset reason codes.

## Functions

### otPlatAssertFail

```
void otPlatAssertFail(
  const char *aFilename,
  int aLineNumber
)
```
Provides a platform specific implementation for assert.


Details Parameters `[in] aFilename` The name of the file where the assert occurred. `[in] aLineNumber` The line number in the file where the assert occurred.

### otPlatGetBatteryLevel

```
otError otPlatGetBatteryLevel(
  otInstance *aInstance,
  uint8_t *aBatteryLevel
)
```
Gets the current battery level (percentage of remaining capacity).

This is an optional platform API. If the platform does not support reporting battery level (for example, if the device is mains-powered), it can return `OT_ERROR_NOT_IMPLEMENTED`.

The Thread specification defines the Battery Level TLV as the percentage of remaining battery capacity in the range `[0, 100]`. The OpenThread stack does not apply any checks on the returned value from this API and includes it as-is in the Battery Level TLV in Network Diagnostic responses.


Details Parameters `[in] aInstance` The OpenThread instance structure. `[out] aBatteryLevel` A pointer to a variable to output the battery level. Return Values `OT_ERROR_NONE` Successfully retrieved the battery level. `OT_ERROR_NOT_IMPLEMENTED` Platform does not support reporting battery level. `OT_ERROR_FAILED` Failed to get the battery level.

### otPlatGetMcuPowerState

```
otPlatMcuPowerState otPlatGetMcuPowerState(
  otInstance *aInstance
)
```
Gets the current desired MCU power state.

This is only applicable and used for NCP configuration when `OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL` is enabled.

After a reset, the power state MUST return `OT_PLAT_POWER_STATE_ON`. During operation, power state SHOULD only change through an explicit successful call to `otPlatSetMcuPowerState()`.


Details Parameters `[in] aInstance` A pointer to OpenThread instance. **Returns** The current power state.

### otPlatGetResetReason

```
otPlatResetReason otPlatGetResetReason(
  otInstance *aInstance
)
```
Returns the reason for the last platform reset.


Details Parameters `[in] aInstance` The OpenThread instance structure.

### otPlatGetSupplyVoltage

```
otError otPlatGetSupplyVoltage(
  otInstance *aInstance,
  uint16_t *aSupplyVoltage
)
```
Gets the current supply voltage in millivolts (mV).

This is an optional platform API. If the platform does not support reporting supply voltage, it can return `OT_ERROR_NOT_IMPLEMENTED`.


Details Parameters `[in] aInstance` The OpenThread instance structure. `[out] aSupplyVoltage` A pointer to a variable to output the supply voltage in millivolts (mV). Return Values `OT_ERROR_NONE` Successfully retrieved the supply voltage. `OT_ERROR_NOT_IMPLEMENTED` Platform does not support reporting supply voltage. `OT_ERROR_FAILED` Failed to get the supply voltage.

### otPlatLogCrashDump

```
otError otPlatLogCrashDump(
  void
)
```
Logs a crash dump using OpenThread logging APIs.


> [!NOTE]
> **Note:** This API is an optional logging platform API. It's up to the platform layer to implement it.

<br />

Details Return Values `OT_ERROR_NONE` Crash dump was logged successfully `OT_ERROR_NOT_CAPABLE` Platform is not capable of logging a crash dump

### otPlatReset

```
void otPlatReset(
  otInstance *aInstance
)
```
Performs a software reset on the platform, if supported.


Details Parameters `[in] aInstance` The OpenThread instance structure.

### otPlatResetToBootloader

```
otError otPlatResetToBootloader(
  otInstance *aInstance
)
```
Performs a hardware reset on the platform to launch bootloader mode, if supported.

Used when `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE` is enabled.


Details Parameters `[in] aInstance` The OpenThread instance structure. Return Values `OT_ERROR_NONE` Reset to bootloader successfully. `OT_ERROR_BUSY` Failed due to another operation is ongoing. `OT_ERROR_NOT_CAPABLE` Not capable of resetting to bootloader.

### otPlatSetMcuPowerState

```
otError otPlatSetMcuPowerState(
  otInstance *aInstance,
  otPlatMcuPowerState aState
)
```
Sets the desired MCU power state.

This is only applicable and used for NCP configuration when `OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL` is enabled.


Details Parameters `[in] aInstance` A pointer to OpenThread instance. `[in] aState` The new MCU power state. Return Values `OT_ERROR_NONE` The power state updated successfully. `OT_ERROR_FAILED` The given MCU power state is not supported by the platform.

### otPlatWakeHost

```
void otPlatWakeHost(
  void
)
```
Performs a platform specific operation to wake the host MCU.

This is used only for NCP configurations.

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources.md.txt).