# RadioLib: RadioLibBCH Class Reference

RadioLibBCH Class Reference

Class to calculate Bose–Chaudhuri–Hocquenghem (BCH) class of forward error correction codes. In theory, this should be able to calculate an arbitrary BCH(N, K) code, but so far it was only tested for BCH(31, 21). More...

`#include <FEC.h>`

## Public Member Functions

| RadioLibBCH ()
| Default constructor.
void | begin (uint8_t n, uint8_t k, uint32_t poly)
| Initialization method. More...
uint32_t | encode (uint32_t dataword)
| Encoding method - encodes one data word (without check bits) into a code word (with check bits). More...

## Detailed Description

Class to calculate Bose–Chaudhuri–Hocquenghem (BCH) class of forward error correction codes. In theory, this should be able to calculate an arbitrary BCH(N, K) code, but so far it was only tested for BCH(31, 21).

## Member Function Documentation

## begin()

void RadioLibBCH::begin | ( | uint8_t | n,
|  | uint8_t | k,
|  | uint32_t | poly
| ) |  |

Initialization method.

Parameters

  n | Code word length in bits, up to 32.
  k | Data portion length in bits, up to "n".
  poly | Powers of the irreducible polynomial.

## encode()

uint32_t RadioLibBCH::encode | ( | uint32_t | dataword | ) |

Encoding method - encodes one data word (without check bits) into a code word (with check bits).

Parameters

  dataword | Data word without check bits. The caller is responsible to make sure the data is on the correct bit positions!

Returns
  Code word with error check bits.

The documentation for this class was generated from the following files:

- src/utils/FEC.h
- src/utils/FEC.cpp