GNU Radio's LORA Package
gr::lora Namespace Reference

Classes

class  channelizer
 <+description of block+> More...
 
class  channelizer_impl
 
class  controller
 
class  controller_impl
 
class  debugger
 
class  decoder
 <+description of block+> More...
 
class  decoder_impl
 Return the DecoderState as string for debugging purposes. More...
 
class  message_file_sink
 <+description of block+> More...
 
class  message_file_sink_impl
 
class  message_socket_sink
 Sink for messages, sent to socket. More...
 
class  message_socket_sink_impl
 
class  message_socket_source
 Message socket source block , using UDP. More...
 
class  message_socket_source_impl
 

Enumerations

enum class  DecoderState {
  DETECT , SYNC , FIND_SFD , PAUSE ,
  DECODE_HEADER , DECODE_PAYLOAD , STOP
}
 DecoderState : Each state the LoRa decoder can be in. More...
 

Functions

int32_t wrap_index (int32_t i, int32_t n)
 Wrap indices Python-like, i.e. array[wrap_index(-1, array_length)] gets the last element.
 
template<class T >
clamp (const T d, const T min, const T max)
 Clamp given value in the given range.
 
uint32_t rotl (uint32_t bits, uint32_t count=1u, const uint32_t size=8u)
 Rotate the given bits to the left and return the result.
 
template<typename T >
std::string to_bin (const T v, const uint32_t bitwidth)
 Return the v represented in a binary string.
 
template<typename T >
void print_vector_bin (std::ostream &out, const std::vector< T > &v, const std::string &prefix, const int element_len_bits)
 Append the data in a given vector to an output stream with a comma delimiter.
 
bool check_parity_string (const std::string &word, const bool even=true)
 Check whether the parity of the given binary string is even.
 
bool check_parity (uint64_t word, const bool even=true)
 Check whether the parity of the given uint64_t is even.
See https://graphics.stanford.edu/~seander/bithacks.html for more.
 
uint32_t select_bits (const uint32_t data, const uint8_t *indices, const uint8_t n)
 Select the bits in data given by the indices in *indices.
 
uint8_t bit (const uint8_t v, const uint8_t i)
 Select a single bit from the given byte.
 
uint8_t pack_byte (const uint8_t a, const uint8_t b, const uint8_t c, const uint8_t d, const uint8_t e, const uint8_t f, const uint8_t g, const uint8_t h)
 Pack the given 8 bits in a byte with: hgfe dcba
 
uint8_t pack_nibble (const uint8_t a, const uint8_t b, const uint8_t c, const uint8_t d)
 Pack the given 4 bits in a nibble with: dcba
 
uint8_t hamming_encode_soft (const uint8_t v)
 Encode the given word with standard Hamming(7,4) and return a byte with the set parity bits.
 
void swap_nibbles (uint8_t *array, uint32_t length)
 Swap nibbles of a byte array.
 
static uint8_t hamming_decode_soft_byte (uint8_t v)
 Hamming(8,4) decoding by constructing a Syndrome matrix LUT for XORing on parity errors.
 
template<typename T >
void print_vector (std::ostream &out, const T *v, const std::string &prefix, const int size, const int element_len_bits)
 
template<typename T >
void print_vector_hex (std::ostream &out, const T *v, const uint32_t size, bool endline, bool print_ascii)
 
template<typename T >
void print_interleave_matrix (std::ostream &out, const std::vector< T > &v, const uint32_t sf)
 
bool header_checksum (const uint8_t *header)
 
uint32_t dissect_packet (const void **header, uint32_t header_size, const uint8_t *buffer, uint32_t offset)
 
uint32_t build_packet (uint8_t *buffer, uint32_t offset, const void *header, uint32_t header_size)
 

Variables

static std::vector< std::string > term_colors
 
const uint8_t prng_header []
 
const uint8_t prng_payload_cr56 []
 
const uint8_t prng_payload_cr78 []
 

Enumeration Type Documentation

◆ DecoderState

enum class gr::lora::DecoderState
strong

DecoderState : Each state the LoRa decoder can be in.

Enumerator
DETECT 
SYNC 
FIND_SFD 
PAUSE 
DECODE_HEADER 
DECODE_PAYLOAD 
STOP 

Function Documentation

◆ bit()

uint8_t gr::lora::bit ( const uint8_t  v,
const uint8_t  i 
)
inline

Select a single bit from the given byte.

Parameters
vThe byte to select from.
iThe index to select the bit from starting from the LSB.

Referenced by hamming_decode_soft_byte(), and hamming_encode_soft().

◆ build_packet()

uint32_t gr::lora::build_packet ( uint8_t *  buffer,
uint32_t  offset,
const void *  header,
uint32_t  header_size 
)
inline

◆ check_parity()

bool gr::lora::check_parity ( uint64_t  word,
const bool  even = true 
)
inline

Check whether the parity of the given uint64_t is even.
See https://graphics.stanford.edu/~seander/bithacks.html for more.

Parameters
wordThe uint64_t to check.
evenCheck for even (true) or uneven (false) parity.

◆ check_parity_string()

bool gr::lora::check_parity_string ( const std::string &  word,
const bool  even = true 
)
inline

Check whether the parity of the given binary string is even.

Parameters
wordThe string to check.
evenCheck for even (true) or uneven (false) parity.

◆ clamp()

template<class T >
T gr::lora::clamp ( const T  d,
const T  min,
const T  max 
)
inline

Clamp given value in the given range.

Template Parameters
TThe type of variable to clamp.
d, min and max must be of this type.
Parameters
dThe value to clamp.
minThe lower bound of the range.
maxThe upper bound of the range.

◆ dissect_packet()

uint32_t gr::lora::dissect_packet ( const void **  header,
uint32_t  header_size,
const uint8_t *  buffer,
uint32_t  offset 
)
inline

◆ hamming_decode_soft_byte()

static uint8_t gr::lora::hamming_decode_soft_byte ( uint8_t  v)
inlinestatic

Hamming(8,4) decoding by constructing a Syndrome matrix LUT for XORing on parity errors.

DEPRECATED

Parameters
vThe byte to decode.
Returns
Returs a nibble containing the corrected data.

References bit(), and pack_nibble().

◆ hamming_encode_soft()

uint8_t gr::lora::hamming_encode_soft ( const uint8_t  v)
inline

Encode the given word with standard Hamming(7,4) and return a byte with the set parity bits.

Parameters
vThe nibble to encode.

References bit(), and pack_byte().

◆ header_checksum()

bool gr::lora::header_checksum ( const uint8_t *  header)
inline

◆ pack_byte()

uint8_t gr::lora::pack_byte ( const uint8_t  a,
const uint8_t  b,
const uint8_t  c,
const uint8_t  d,
const uint8_t  e,
const uint8_t  f,
const uint8_t  g,
const uint8_t  h 
)
inline

Pack the given 8 bits in a byte with: hgfe dcba

Parameters
a-hThe bits to pack with the LSB first.

Referenced by hamming_encode_soft().

◆ pack_nibble()

uint8_t gr::lora::pack_nibble ( const uint8_t  a,
const uint8_t  b,
const uint8_t  c,
const uint8_t  d 
)
inline

Pack the given 4 bits in a nibble with: dcba

Parameters
a-dThe bits to pack with the LSB first.

Referenced by hamming_decode_soft_byte().

◆ print_interleave_matrix()

template<typename T >
void gr::lora::print_interleave_matrix ( std::ostream &  out,
const std::vector< T > &  v,
const uint32_t  sf 
)
inline

References term_colors, to_bin(), and wrap_index().

◆ print_vector()

template<typename T >
void gr::lora::print_vector ( std::ostream &  out,
const T *  v,
const std::string &  prefix,
const int  size,
const int  element_len_bits 
)
inline

References to_bin().

◆ print_vector_bin()

template<typename T >
void gr::lora::print_vector_bin ( std::ostream &  out,
const std::vector< T > &  v,
const std::string &  prefix,
const int  element_len_bits 
)
inline

Append the data in a given vector to an output stream with a comma delimiter.

Template Parameters
TThe type of variable to append.
Parameters
outThe output stream to append to.
vThe vector containing the data to append.
prefixA prefix to include before appending the data.
element_len_bitsThe length in bits of the data in v.

References to_bin().

◆ print_vector_hex()

template<typename T >
void gr::lora::print_vector_hex ( std::ostream &  out,
const T *  v,
const uint32_t  size,
bool  endline,
bool  print_ascii 
)
inline

◆ rotl()

uint32_t gr::lora::rotl ( uint32_t  bits,
uint32_t  count = 1u,
const uint32_t  size = 8u 
)
inline

Rotate the given bits to the left and return the result.

Parameters
bitsThe value to rotate.
countThe amount of bits to rotate (shift to left and add to right).
sizeThe size in bits used in bits.
e.g. 1 byte given => size = 8
e.g. only 6 bits in use => size = 6, and all bits higher than (1 << size-1) will be zeroed.

◆ select_bits()

uint32_t gr::lora::select_bits ( const uint32_t  data,
const uint8_t *  indices,
const uint8_t  n 
)
inline

Select the bits in data given by the indices in *indices.

Parameters
dataThe data to select bits from.
*indicesArray with the indices to select.
nThe amount of indices.

◆ swap_nibbles()

void gr::lora::swap_nibbles ( uint8_t *  array,
uint32_t  length 
)
inline

Swap nibbles of a byte array.

Parameters
arrayArray of uint8_t bytes
lengthLength of the array

◆ to_bin()

template<typename T >
std::string gr::lora::to_bin ( const T  v,
const uint32_t  bitwidth 
)
inline

Return the v represented in a binary string.

Template Parameters
TThe type of variable to convert.
Parameters
vThe value to convert.
bitwidthThe length in bits of the given variable v.

Referenced by print_interleave_matrix(), print_vector(), and print_vector_bin().

◆ wrap_index()

int32_t gr::lora::wrap_index ( int32_t  i,
int32_t  n 
)
inline

Wrap indices Python-like, i.e. array[wrap_index(-1, array_length)] gets the last element.

Parameters
iIndex of array
nLength of array

Referenced by print_interleave_matrix().

Variable Documentation

◆ prng_header

const uint8_t gr::lora::prng_header[]
Initial value:
= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}

Header whitening sequence

◆ prng_payload_cr56

const uint8_t gr::lora::prng_payload_cr56[]
Initial value:
= {
0xff, 0xff, 0x2d, 0xff, 0x78, 0xff, 0x30, 0x2e, 0x0, 0x2e, 0x12, 0x3c, 0x14, 0x28, 0xa, 0x30, 0x36, 0x0, 0x1e, 0x12, 0x2e, 0x14, 0x3c, 0xa, 0x28, 0x36, 0x30, 0x1e, 0x12, 0x2e, 0x6, 0x3c, 0xc, 0x28, 0x3a, 0x30, 0x24, 0x12, 0x18, 0x6, 0x30, 0xc, 0x0, 0x3a, 0x0, 0x24, 0x0, 0x18, 0x0, 0x30, 0x12, 0x0, 0x14, 0x0, 0x18, 0x0, 0x30, 0x0, 0x12, 0x12, 0x6, 0x14, 0x1e, 0x18, 0x3c, 0x30, 0x28, 0x12, 0x30, 0x6, 0x12, 0x1e, 0x14, 0x3c, 0x18, 0x28, 0x22, 0x30, 0x14, 0x12, 0xa, 0x14, 0x36, 0x18, 0x1e, 0x22, 0x3c, 0x14, 0x28, 0xa, 0x30, 0x36, 0x0, 0x1e, 0x0, 0x3c, 0x0, 0x28, 0x12, 0x30, 0x6, 0x0, 0xc, 0x0, 0x28, 0x0, 0x22, 0x12, 0x14, 0x6, 0x18, 0xc, 0x22, 0x28, 0x14, 0x22, 0x18, 0x14, 0x22, 0x18, 0x6, 0x22, 0xc, 0x14, 0x3a, 0x18, 0x36, 0x22, 0x1e, 0x6, 0x3c, 0xc, 0x28, 0x3a, 0x22, 0x36, 0x14, 0x1e, 0x18, 0x3c, 0x30, 0x28, 0x0, 0x22, 0x0, 0x14, 0x12, 0x18, 0x14, 0x30, 0xa, 0x0, 0x24, 0x0, 0xa, 0x12, 0x36, 0x14, 0xc, 0xa, 0x3a, 0x24, 0x36, 0xa, 0xc, 0x36, 0x3a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0x3c, 0x3c, 0x3a, 0x3a, 0x36, 0x36, 0xc, 0x1e, 0x28, 0x3c, 0x22, 0x3a, 0x6, 0x36, 0x1e, 0xc, 0x2e, 0x28, 0x3c, 0x22, 0x3a, 0x6, 0x36, 0x1e, 0x1e, 0x2e, 0x2e, 0x3c, 0x2e, 0x3a, 0x2e, 0x36, 0x3c, 0x1e, 0x3a, 0x2e, 0x24, 0x2e, 0x18, 0x2e, 0x22, 0x3c, 0x6, 0x3a, 0xc, 0x24, 0x28, 0x18, 0x22, 0x22, 0x6, 0x6, 0xc, 0xc, 0x3a, 0x28, 0x24, 0x22, 0xa, 0x6, 0x24, 0xc, 0x18, 0x3a, 0x30, 0x24, 0x12, 0xa, 0x6, 0x24, 0xc, 0x18, 0x28, 0x30, 0x30, 0x12, 0x0, 0x6, 0x0, 0xc, 0x12, 0x28, 0x6, 0x30, 0x1e, 0x0, 0x3c, 0x0, 0x3a, 0x12, 0x24, 0x6, 0xa, 0x1e, 0x24, 0x3c, 0xa, 0x3a, 0x24, 0x24, 0xa, 0xa, 0x36, 0x24, 0x1e, 0xa, 0x2e, 0x24, 0x2e, 0xa, 0x3c, 0x36, 0x28, 0x1e, 0x22, 0x2e, 0x14, 0x2e, 0xa, 0x3c, 0x24, 0x28, 0x18, 0x22, 0x30, 0x14, 0x0, 0xa, 0x12, 0x24, 0x14, 0x18, 0x18, 0x30, 0x22, 0x0, 0x6, 0x12, 0x1e, 0x14, 0x2e, 0x18, 0x2e, 0x22, 0x2e, 0x6, 0x2e, 0x1e, 0x0, 0x0, 0x0, 0x0, 0x24, 0x6
}

Whitening sequence

◆ prng_payload_cr78

const uint8_t gr::lora::prng_payload_cr78[]
Initial value:
= {
0xff, 0xff, 0x2d, 0xff, 0x78, 0xff, 0xe1, 0xff, 0x00, 0xff, 0xd2, 0x2d, 0x55, 0x78, 0x4b, 0xe1, 0x66, 0x00, 0x1e, 0xd2, 0xff, 0x55, 0x2d, 0x4b, 0x78, 0x66, 0xe1, 0x1e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, 0x99, 0xff, 0x33, 0x2d, 0x87, 0xaa, 0xcc, 0xb4, 0x78, 0x99, 0x33, 0x33, 0x87, 0x87, 0xcc, 0xcc, 0xaa, 0x78, 0xb4, 0x33, 0x4b, 0x87, 0xb4, 0xcc, 0x99, 0xaa, 0xe1, 0xb4, 0xd2, 0x4b, 0x87, 0xb4, 0xcc, 0x99, 0x78, 0xe1, 0xe1, 0xd2, 0x00, 0x87, 0x00, 0xcc, 0xd2, 0x78, 0x87, 0xe1, 0x1e, 0x00, 0x2d, 0x00, 0xaa, 0xd2, 0xb4, 0x87, 0x4b, 0x1e, 0xb4, 0x2d, 0x4b, 0xaa, 0xb4, 0xb4, 0x4b, 0x4b, 0x66, 0xb4, 0x1e, 0x4b, 0xff, 0xb4, 0xff, 0x4b, 0x2d, 0x66, 0x78, 0x1e, 0x33, 0xff, 0x55, 0xff, 0x4b, 0x2d, 0xb4, 0x78, 0x99, 0x33, 0xe1, 0x55, 0x00, 0x4b, 0xd2, 0xb4, 0x55, 0x99, 0x99, 0xe1, 0x33, 0x00, 0x87, 0xd2, 0x1e, 0x55, 0xff, 0x99, 0xff, 0x33, 0xff, 0x87, 0xff, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x87, 0xe1, 0xaa, 0xcc,
}

◆ term_colors

std::vector<std::string> gr::lora::term_colors
static
Initial value:
= {
"\e[0m",
"\e[1m\e[91m",
"\e[1m\e[92m",
"\e[1m\e[93m",
"\e[1m\e[94m",
"\e[1m\e[95m",
"\e[1m\e[96m",
"\e[1m\e[97m",
"\e[1m\e[31m",
"\e[1m\e[32m",
"\e[1m\e[33m",
"\e[1m\e[34m",
"\e[1m\e[35m",
"\e[1m\e[36m"
}

Referenced by print_interleave_matrix().