GNU Radio's LORA Package
utilities.h File Reference
#include <cstdint>
#include <string.h>
#include <iomanip>
#include <sstream>
Include dependency graph for utilities.h:

Go to the source code of this file.

Namespaces

namespace  gr
 
namespace  gr::lora
 

Macros

#define MAC_CRC_SIZE   2u
 
#define MAX_PWR_QUEUE_SIZE   4
 
#define SM(value, shift, mask)   (((value) << (shift)) & (mask))
 
#define MS(value, mask, shift)   (((value) & (mask)) >> (shift))
 

Functions

int32_t gr::lora::wrap_index (int32_t i, int32_t n)
 Wrap indices Python-like, i.e. array[wrap_index(-1, array_length)] gets the last element. More...
 
template<class T >
gr::lora::clamp (const T d, const T min, const T max)
 Clamp given value in the given range. More...
 
uint32_t gr::lora::rotl (uint32_t bits, uint32_t count=1u, const uint32_t size=8u)
 Rotate the given bits to the left and return the result. More...
 
template<typename T >
std::string gr::lora::to_bin (const T v, const uint32_t bitwidth)
 Return the v represented in a binary string. More...
 
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)
 Append the data in a given vector to an output stream with a comma delimiter. More...
 
bool gr::lora::check_parity_string (const std::string &word, const bool even=true)
 Check whether the parity of the given binary string is even. More...
 
bool gr::lora::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. More...
 
uint32_t gr::lora::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. More...
 
uint8_t gr::lora::bit (const uint8_t v, const uint8_t i)
 Select a single bit from the given byte. More...
 
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)
 Pack the given 8 bits in a byte with: hgfe dcba More...
 
uint8_t gr::lora::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 More...
 
uint8_t gr::lora::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. More...
 
void gr::lora::swap_nibbles (uint8_t *array, uint32_t length)
 Swap nibbles of a byte array. More...
 
static uint8_t gr::lora::hamming_decode_soft_byte (uint8_t v)
 Hamming(8,4) decoding by constructing a Syndrome matrix LUT for XORing on parity errors. More...
 
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)
 
template<typename T >
void gr::lora::print_vector_hex (std::ostream &out, const T *v, const uint32_t size, bool endline, bool print_ascii)
 
template<typename T >
void gr::lora::print_interleave_matrix (std::ostream &out, const std::vector< T > &v, const uint32_t sf)
 
bool gr::lora::header_checksum (const uint8_t *header)
 
uint32_t gr::lora::dissect_packet (const void **header, uint32_t header_size, const uint8_t *buffer, uint32_t offset)
 
uint32_t gr::lora::build_packet (uint8_t *buffer, uint32_t offset, const void *header, uint32_t header_size)
 

Variables

static std::vector< std::string > gr::lora::term_colors
 

Macro Definition Documentation

◆ MAC_CRC_SIZE

#define MAC_CRC_SIZE   2u

◆ MAX_PWR_QUEUE_SIZE

#define MAX_PWR_QUEUE_SIZE   4

◆ MS

#define MS (   value,
  mask,
  shift 
)    (((value) & (mask)) >> (shift))

◆ SM

#define SM (   value,
  shift,
  mask 
)    (((value) << (shift)) & (mask))