Simple XOR based coding algorithms.  
More...
Simple XOR based coding algorithms. 
- Warning
 - This feature is experimental!
 This is a very basic implementation, it can only recover 1 lost block in 3 and only has a 33% chance of recovering two consecutive lost blocks. API / Algorithm might change if that means we can do better.  
 | 
| file   | xor.h | 
|   | XOR coding definitions. 
  | 
|   | 
 | 
| void  | coding_xor_generate (void *data, size_t len, uint8_t *parity) | 
|   | Generate parity and mix data buffer.  More...
  | 
|   | 
| bool  | coding_xor_recover (void *data, size_t len, uint8_t *parity, uint8_t *blocks, size_t block_size, bool recover_parity) | 
|   | Restore and unmix buffer.  More...
  | 
|   | 
◆ CODING_XOR_PARITY_LEN
      
        
          | #define CODING_XOR_PARITY_LEN | 
          ( | 
            | 
          in | ) | 
           | 
        
      
 
Value:
#define CONFIG_CODING_XOR_CHECK_BYTES
Number of payload bytes per parity byte.
 
 
Get the size of the needed parity buffer for a given payload size. 
- Parameters
 - 
  
  
 
Definition at line 48 of file xor.h.
 
 
◆ coding_xor_generate()
      
        
          | void coding_xor_generate  | 
          ( | 
          void *  | 
          data,  | 
        
        
           | 
           | 
          size_t  | 
          len,  | 
        
        
           | 
           | 
          uint8_t *  | 
          parity  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Generate parity and mix data buffer. 
This generates parity data to recover one in CONFIG_CODING_XOR_CHECK_BYTES bytes. The data buffer is then mixed to distribute bytes amongst transfer blocks, so that the chance for consecutive bytes to be in the same block is lowered.
- Parameters
 - 
  
    | [in,out] | data | The data buffer to be processed  | 
    | [in] | len | Size of the data buffer  | 
    | [out] | parity | Buffer to hold parity data. Must be at least CODING_XOR_PARITY_LEN(len) bytes  | 
  
   
 
 
◆ coding_xor_recover()
      
        
          | bool coding_xor_recover  | 
          ( | 
          void *  | 
          data,  | 
        
        
           | 
           | 
          size_t  | 
          len,  | 
        
        
           | 
           | 
          uint8_t *  | 
          parity,  | 
        
        
           | 
           | 
          uint8_t *  | 
          blocks,  | 
        
        
           | 
           | 
          size_t  | 
          block_size,  | 
        
        
           | 
           | 
          bool  | 
          recover_parity  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Restore and unmix buffer. 
- Parameters
 - 
  
    | [in,out] | data | The data buffer to be restored  | 
    | [in] | len | Size of the data buffer  | 
    | [in,out] | parity | Buffer with parity data. Must be at least CODING_XOR_PARITY_LEN(len) bytes  | 
    | [in,out] | blocks | Bitfieled to indicate which blocks were received. This indicates the presence of both data and parity blocks. Parity blocks are appended after the last data block. If a block was restored it's bit will be set.  | 
    | [in] | block_size | Size of a data/payload block  | 
    | [in] | recover_parity | If true, missing parity blocks will be re-generated from data blocks. | 
  
   
- Returns
 - True if all data blocks were recovered