# Factory Diagnostics - Platform

# Factory Diagnostics - Platform

This module includes the platform abstraction for diagnostics features.

## Summary

| ### Enumerations ||
|---|---|
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gabbbeb7e2f1443b8b172e6e8eee898d97{ https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ggabbbeb7e2f1443b8b172e6e8eee898d97ac1ed2be9ed3d03bf05ab7e38a22f7744 = 0, https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ggabbbeb7e2f1443b8b172e6e8eee898d97a0c62185726e6f91d917f42fc334fe2ea = 1 }` | enumDefines the gpio modes. |

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gab725003cfb10ba112b78ab1dc71e53eb)(const char *aFormat, va_list aArguments, void *aContext)` | typedef `void(*` Pointer to callback to output platform diag messages. |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga70284beb449e6a1fa956f08761122cc4(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `void` Processes the alarm event. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga79201e61064c699a3b226a7fd01ef265(uint8_t aChannel)` | `void` Sets the channel to use for factory diagnostics. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gac75fa764c1f6b3f8c53716ebcf795653(uint32_t aGpio, bool *aValue)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Gets the gpio value. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga7c7d806a19720119878dbe6f3a3238bc(uint32_t aGpio, https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gabbbeb7e2f1443b8b172e6e8eee898d97 *aMode)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Gets the gpio mode. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga7621fce816e5c6a5523df74e53f5fd66(uint32_t aGpio, bool aValue)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sets the gpio value. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gae653372a533fac70cc7abfd20f75b782(uint32_t aGpio, https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gabbbeb7e2f1443b8b172e6e8eee898d97 aMode)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sets the gpio mode. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga9dbb920bd0361e88c9a9b22cf18ee254(void)` | `bool` Indicates whether or not factory diagnostics mode is enabled. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gac43ce755f483330b1caaa62d45c87bd3(bool aMode)` | `void` Enables/disables the factory diagnostics mode. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gabb8e9d1f281cb3aeed12c09780dde722(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint8_t aArgsLength, char *aArgs[])` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Processes a factory diagnostics command line. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gae3626856da1b4b9333bac2af45caa98f(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint8_t aChannel, int16_t *aTargetPower, int16_t *aActualPower, uint8_t *aRawPowerSetting, uint16_t *aRawPowerSettingLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Get the power settings for the given channel. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gab2b2443b37ff2f643df5c5a2b8449078(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint8_t *aRawPowerSetting, uint16_t *aRawPowerSettingLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Get the radio raw power setting for diagnostics module. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga36ed9507aa4048199108806d19718909(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, bool aEnable)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Enable/disable the platform layer to use the raw power setting set by `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga95424b51296360df9221da83a1d90a81`. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gac385f5586fad4e11c1195cab996f3450(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/struct/ot-radio-frame *aFrame, https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49 aError)` | `void` Processes the received radio frame. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga95424b51296360df9221da83a1d90a81(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const uint8_t *aRawPowerSetting, uint16_t aRawPowerSettingLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Set the radio raw power setting for diagnostics module. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga70cfe435ddb5e2a322a4db262b8d4a06(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, bool aEnable)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Start/stop the platform layer to transmit continuous carrier wave. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga1b1f6746f866db273fc41812de7f45da(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, bool aEnable)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Start/stop the platform layer to transmit stream of characters. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga21ae1e6fb05969ec0e78679cc4932d0b(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gab725003cfb10ba112b78ab1dc71e53eb aCallback, void *aContext)` | `void` Sets the platform diag output callback. |
| `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1gae8e12f8bde28a00a9e6c2cbc5ae137e5(int8_t aTxPower)` | `void` Sets the transmit power to use for factory diagnostics. |

## Enumerations

### otGpioMode

```
 otGpioMode
```
Defines the gpio modes.

| Properties ||
|---|---|
| `OT_GPIO_MODE_INPUT` | Input mode without pull resistor. |
| `OT_GPIO_MODE_OUTPUT` | Output mode. |

## Typedefs

### otPlatDiagOutputCallback

```
void(* otPlatDiagOutputCallback)(const char *aFormat, va_list aArguments, void *aContext)
```
Pointer to callback to output platform diag messages.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aFormat` | The format string. | | `[in] aArguments` | The format string arguments. | | `[out] aContext` | A pointer to the user context. | |

## Functions

### otPlatDiagAlarmCallback

```
void otPlatDiagAlarmCallback(
  otInstance *aInstance
)
```
Processes the alarm event.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance for current request. | |

### otPlatDiagChannelSet

```
void otPlatDiagChannelSet(
  uint8_t aChannel
)
```
Sets the channel to use for factory diagnostics.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aChannel` | The channel value. | |

### otPlatDiagGpioGet

```
otError otPlatDiagGpioGet(
  uint32_t aGpio,
  bool *aValue
)
```
Gets the gpio value.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aGpio` | The gpio number. | | `[out] aValue` | A pointer where to put gpio value. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully got the gpio value. | | `OT_ERROR_FAILED` | A platform error occurred while getting the gpio value. | | `OT_ERROR_INVALID_ARGS` | `aGpio` is not supported or `aValue` is NULL. | | `OT_ERROR_INVALID_STATE` | Diagnostic mode was not enabled or `aGpio` is not configured as input. | | `OT_ERROR_NOT_IMPLEMENTED` | This function is not implemented or configured on the platform. | |

### otPlatDiagGpioGetMode

```
otError otPlatDiagGpioGetMode(
  uint32_t aGpio,
  otGpioMode *aMode
)
```
Gets the gpio mode.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aGpio` | The gpio number. | | `[out] aMode` | A pointer where to put gpio mode. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully got the gpio mode. | | `OT_ERROR_FAILED` | Mode returned by the platform is not implemented in OpenThread or a platform error occurred while getting the gpio mode. | | `OT_ERROR_INVALID_ARGS` | `aGpio` is not supported or `aMode` is NULL. | | `OT_ERROR_INVALID_STATE` | Diagnostic mode was not enabled. | | `OT_ERROR_NOT_IMPLEMENTED` | This function is not implemented or configured on the platform. | |

### otPlatDiagGpioSet

```
otError otPlatDiagGpioSet(
  uint32_t aGpio,
  bool aValue
)
```
Sets the gpio value.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aGpio` | The gpio number. | | `[in] aValue` | true to set the gpio to high level, or false otherwise. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the gpio. | | `OT_ERROR_FAILED` | A platform error occurred while setting the gpio. | | `OT_ERROR_INVALID_ARGS` | `aGpio` is not supported. | | `OT_ERROR_INVALID_STATE` | Diagnostic mode was not enabled or `aGpio` is not configured as output. | | `OT_ERROR_NOT_IMPLEMENTED` | This function is not implemented or configured on the platform. | |

### otPlatDiagGpioSetMode

```
otError otPlatDiagGpioSetMode(
  uint32_t aGpio,
  otGpioMode aMode
)
```
Sets the gpio mode.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aGpio` | The gpio number. | | `[out] aMode` | The gpio mode. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the gpio mode. | | `OT_ERROR_FAILED` | A platform error occurred while setting the gpio mode. | | `OT_ERROR_INVALID_ARGS` | `aGpio` or `aMode` is not supported. | | `OT_ERROR_INVALID_STATE` | Diagnostic mode was not enabled. | | `OT_ERROR_NOT_IMPLEMENTED` | This function is not implemented or configured on the platform. | |

### otPlatDiagModeGet

```
bool otPlatDiagModeGet(
  void
)
```
Indicates whether or not factory diagnostics mode is enabled.

<br />

| Details ||
|---|---|
| **Returns** | TRUE if factory diagnostics mode is enabled, FALSE otherwise. |

### otPlatDiagModeSet

```
void otPlatDiagModeSet(
  bool aMode
)
```
Enables/disables the factory diagnostics mode.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMode` | TRUE to enable diagnostics mode, FALSE otherwise. | |

### otPlatDiagProcess

```
otError otPlatDiagProcess(
  otInstance *aInstance,
  uint8_t aArgsLength,
  char *aArgs[]
)
```
Processes a factory diagnostics command line.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance for current request. | | `[in] aArgsLength` | The number of arguments in `aArgs`. | | `[in] aArgs` | The arguments of diagnostics command line. | |
| Return Values | |---|---| | `OT_ERROR_INVALID_ARGS` | The command is supported but invalid arguments provided. | | `OT_ERROR_NONE` | The command is successfully process. | | `OT_ERROR_INVALID_COMMAND` | The command is not valid or not supported. | |

### otPlatDiagRadioGetPowerSettings

```
otError otPlatDiagRadioGetPowerSettings(
  otInstance *aInstance,
  uint8_t aChannel,
  int16_t *aTargetPower,
  int16_t *aActualPower,
  uint8_t *aRawPowerSetting,
  uint16_t *aRawPowerSettingLength
)
```
Get the power settings for the given channel.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aChannel` | The radio channel. | | `[out] aTargetPower` | The target power in 0.01 dBm. | | `[out] aActualPower` | The actual power in 0.01 dBm. | | `[out] aRawPowerSetting` | A pointer to the raw power setting byte array. | | `[in,out] aRawPowerSettingLength` | On input, a pointer to the size of `aRawPowerSetting`. On output, a pointer to the length of the raw power setting data. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully got the target power. | | `OT_ERROR_INVALID_ARGS` | The `aChannel` is invalid, , `aActualPower`, `aRawPowerSetting` or `aRawPowerSettingLength` is NULL or is too short. | | `OT_ERROR_NOT_FOUND` | The power settings for the `aChannel` was not found. | | `OT_ERROR_NOT_IMPLEMENTED` | This method is not implemented. | |

### otPlatDiagRadioGetRawPowerSetting

```
otError otPlatDiagRadioGetRawPowerSetting(
  otInstance *aInstance,
  uint8_t *aRawPowerSetting,
  uint16_t *aRawPowerSettingLength
)
```
Get the radio raw power setting for diagnostics module.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[out] aRawPowerSetting` | A pointer to the raw power setting byte array. | | `[in,out] aRawPowerSettingLength` | On input, a pointer to the size of `aRawPowerSetting`. On output, a pointer to the length of the raw power setting data. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the raw power setting. | | `OT_ERROR_INVALID_ARGS` | The `aRawPowerSetting` or `aRawPowerSettingLength` is NULL or is too short. | | `OT_ERROR_NOT_FOUND` | The raw power setting is not set. | | `OT_ERROR_NOT_IMPLEMENTED` | This method is not implemented. | |

### otPlatDiagRadioRawPowerSettingEnable

```
otError otPlatDiagRadioRawPowerSettingEnable(
  otInstance *aInstance,
  bool aEnable
)
```
Enable/disable the platform layer to use the raw power setting set by `https://openthread.io/reference/group/plat-factory-diagnostics#group__plat-factory-diagnostics_1ga95424b51296360df9221da83a1d90a81`.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aEnable` | TRUE to enable or FALSE to disable the raw power setting. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully enabled/disabled the raw power setting. | | `OT_ERROR_NOT_IMPLEMENTED` | This method is not implemented. | |

### otPlatDiagRadioReceived

```
void otPlatDiagRadioReceived(
  otInstance *aInstance,
  otRadioFrame *aFrame,
  otError aError
)
```
Processes the received radio frame.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance for current request. | | `[in] aFrame` | The received radio frame. | | `[in] aError` | The received radio frame status. | |

### otPlatDiagRadioSetRawPowerSetting

```
otError otPlatDiagRadioSetRawPowerSetting(
  otInstance *aInstance,
  const uint8_t *aRawPowerSetting,
  uint16_t aRawPowerSettingLength
)
```
Set the radio raw power setting for diagnostics module.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aRawPowerSetting` | A pointer to the raw power setting byte array. | | `[in] aRawPowerSettingLength` | The length of the `aRawPowerSetting`. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the raw power setting. | | `OT_ERROR_INVALID_ARGS` | The `aRawPowerSetting` is NULL or the `aRawPowerSettingLength` is too long. | | `OT_ERROR_NOT_IMPLEMENTED` | This method is not implemented. | |

### otPlatDiagRadioTransmitCarrier

```
otError otPlatDiagRadioTransmitCarrier(
  otInstance *aInstance,
  bool aEnable
)
```
Start/stop the platform layer to transmit continuous carrier wave.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aEnable` | TRUE to enable or FALSE to disable the platform layer to transmit continuous carrier wave. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully enabled/disabled . | | `OT_ERROR_INVALID_STATE` | The radio was not in the Receive state. | | `OT_ERROR_NOT_IMPLEMENTED` | This method is not implemented. | |

### otPlatDiagRadioTransmitStream

```
otError otPlatDiagRadioTransmitStream(
  otInstance *aInstance,
  bool aEnable
)
```
Start/stop the platform layer to transmit stream of characters.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aEnable` | TRUE to enable or FALSE to disable the platform layer to transmit stream. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully enabled/disabled. | | `OT_ERROR_INVALID_STATE` | The radio was not in the Receive state. | | `OT_ERROR_NOT_IMPLEMENTED` | This function is not implemented. | |

### otPlatDiagSetOutputCallback

```
void otPlatDiagSetOutputCallback(
  otInstance *aInstance,
  otPlatDiagOutputCallback aCallback,
  void *aContext
)
```
Sets the platform diag output callback.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aCallback` | A pointer to a function that is called on outputting diag messages. | | `[in] aContext` | A pointer to the user context. | |

### otPlatDiagTxPowerSet

```
void otPlatDiagTxPowerSet(
  int8_t aTxPower
)
```
Sets the transmit power to use for factory diagnostics.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aTxPower` | The transmit power value. | |

## 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).