# Jam Detection

# Jam Detection

This module includes functions for signal jamming detection feature.

## Summary

The functions in this module are available when jam-detection feature (`OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE`) is enabled.

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga65a7bc730cbfb6672c135de7634e0851)(bool aJamState, void *aContext)` | typedef `void(*` Pointer is called if signal jam detection is enabled and a jam is detected. |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga34722b9b31be406d7014467b0bec302a(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `uint8_t` Get the Jam Detection Busy Period (in seconds) |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga9b7ab151d2a7312bc132f4a2cd78e1c7(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `uint64_t` Get the current history bitmap. |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1gab3148dd40bce76dfe376d2ba4ca3e0d3(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `int8_t` Get the Jam Detection RSSI Threshold (in dBm). |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga1be4e4820e2c0917c3cdd236b066f8a1(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `bool` Get the Jam Detection State. |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga7ed75d1fead2b461464634803a8a37e8(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `uint8_t` Get the Jam Detection Detection Window (in seconds). |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1gad837b030e6ea6c89ed8cb41ffbbe5f3d(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `bool` Get the Jam Detection Status (enabled/disabled) |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1gadb690602f2bd2e5040b2cff1e7597cd5(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint8_t aBusyPeriod)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Set the Jam Detection Busy Period (in seconds). |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga54c979d56ebcd0e2b16f19098d354e95(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, int8_t aRssiThreshold)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Set the Jam Detection RSSI Threshold (in dBm). |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga300dc86bd15e898c7b418a3e019c1f61(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint8_t aWindow)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Set the Jam Detection Detection Window (in seconds). |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1gac80de8b6763bc9bc6a3ca3b934380e91(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga65a7bc730cbfb6672c135de7634e0851 aCallback, void *aContext)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Start the jamming detection. |
| `https://openthread.io/reference/group/api-jam-detection#group__api-jam-detection_1ga70c6d4047fd122243d18d8d350aa02f6(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Stop the jamming detection. |

## Typedefs

### otJamDetectionCallback

```
void(* otJamDetectionCallback)(bool aJamState, void *aContext)
```
Pointer is called if signal jam detection is enabled and a jam is detected.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aJamState` | Current jam state (`true` if jam is detected, `false` otherwise). | | `[in] aContext` | A pointer to application-specific context. | |

## Functions

### otJamDetectionGetBusyPeriod

```
uint8_t otJamDetectionGetBusyPeriod(
  otInstance *aInstance
)
```
Get the Jam Detection Busy Period (in seconds)

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | The Jam Detection Busy Period. |

### otJamDetectionGetHistoryBitmap

```
uint64_t otJamDetectionGetHistoryBitmap(
  otInstance *aInstance
)
```
Get the current history bitmap.

This value provides information about current state of jamming detection module for monitoring/debugging purpose. It returns a 64-bit value where each bit corresponds to one second interval starting with bit 0 for the most recent interval and bit 63 for the oldest intervals (63 sec earlier). The bit is set to 1 if the jamming detection module observed/detected high signal level during the corresponding one second interval.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | The current history bitmap. |

### otJamDetectionGetRssiThreshold

```
int8_t otJamDetectionGetRssiThreshold(
  otInstance *aInstance
)
```
Get the Jam Detection RSSI Threshold (in dBm).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | The Jam Detection RSSI Threshold. |

### otJamDetectionGetState

```
bool otJamDetectionGetState(
  otInstance *aInstance
)
```
Get the Jam Detection State.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | The Jam Detection state (`true` jam is detected, \`false' otherwise). |

### otJamDetectionGetWindow

```
uint8_t otJamDetectionGetWindow(
  otInstance *aInstance
)
```
Get the Jam Detection Detection Window (in seconds).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | The Jam Detection Window. |

### otJamDetectionIsEnabled

```
bool otJamDetectionIsEnabled(
  otInstance *aInstance
)
```
Get the Jam Detection Status (enabled/disabled)

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | The Jam Detection status (true if enabled, false otherwise). |

### otJamDetectionSetBusyPeriod

```
otError otJamDetectionSetBusyPeriod(
  otInstance *aInstance,
  uint8_t aBusyPeriod
)
```
Set the Jam Detection Busy Period (in seconds).

The number of aggregate seconds within the detection window where the RSSI must be above threshold to trigger detection.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aBusyPeriod` | The Jam Detection busy period (should be non-zero and less than or equal to Jam Detection Window) | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the window. | | `OT_ERROR_INVALID_ARGS` | The given input is not within the valid range. | |

### otJamDetectionSetRssiThreshold

```
otError otJamDetectionSetRssiThreshold(
  otInstance *aInstance,
  int8_t aRssiThreshold
)
```
Set the Jam Detection RSSI Threshold (in dBm).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aRssiThreshold` | The RSSI threshold. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the threshold. | |

### otJamDetectionSetWindow

```
otError otJamDetectionSetWindow(
  otInstance *aInstance,
  uint8_t aWindow
)
```
Set the Jam Detection Detection Window (in seconds).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aWindow` | The Jam Detection window (valid range is 1 to 63) | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the window. | | `OT_ERROR_INVALID_ARGS` | The given input parameter not within valid range (1-63) | |

### otJamDetectionStart

```
otError otJamDetectionStart(
  otInstance *aInstance,
  otJamDetectionCallback aCallback,
  void *aContext
)
```
Start the jamming detection.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aCallback` | A pointer to a function called to notify of jamming state change. | | `[in] aContext` | A pointer to application-specific context. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully started the jamming detection. | | `OT_ERROR_ALREADY` | Jam detection has been started before. | |

### otJamDetectionStop

```
otError otJamDetectionStop(
  otInstance *aInstance
)
```
Stop the jamming detection.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully stopped the jamming detection. | | `OT_ERROR_ALREADY` | Jam detection is already stopped. | |

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