Prusa MINI Firmware overview
Base64StreamDecoder Class Reference

#include <base64_stream_decoder.h>

Public Member Functions

 Base64StreamDecoder ()
 
void Reset ()
 
int ConsumeChar (char c, uint8_t *out)
 

Static Public Member Functions

static uint8_t find64 (uint8_t base64c)
 

Constructor & Destructor Documentation

◆ Base64StreamDecoder()

Base64StreamDecoder::Base64StreamDecoder ( )
19  : state(States::AwaitingFirst) {
20  }

Member Function Documentation

◆ find64()

static uint8_t Base64StreamDecoder::find64 ( uint8_t  base64c)
static
22  {
23  return base64_inverse[base64c];
24  }
Here is the caller graph for this function:

◆ Reset()

void Base64StreamDecoder::Reset ( )
26  {
27  state = States::AwaitingFirst;
28  }
Here is the caller graph for this function:

◆ ConsumeChar()

int Base64StreamDecoder::ConsumeChar ( char  c,
uint8_t out 
)
28  {
29  // pozor na konec zaznamu - special handling
30  uint8_t ic = (c != '=') ? find64(static_cast<uint8_t>(c)) : 0;
31  if (ic == 0xff)
32  return -1; // neplatny vstupni znak
33 
34  switch (state) {
35  case States::AwaitingFirst:
36  lastbits = ic;
37  state = States::FirstByteOut;
38  return 0;
39  case States::FirstByteOut: {
40  *out = (lastbits << 2) | (ic >> 4);
41  lastbits = ic;
42  state = States::SecondByteOut;
43  }
44  return 1;
45  case States::SecondByteOut: {
46  *out = (lastbits << 4) | (ic >> 2);
47  lastbits = ic; // zbyvaji mi 2 bity na pristi kus
48  state = States::ThirdByteOut;
49  }
50  return 1;
51  case States::ThirdByteOut: {
52  *out = (lastbits << 6) | ic;
53  lastbits = 0; // nic nezbylo
54  state = States::AwaitingFirst;
55  }
56  return 1;
57  }
58  return -1; // just in case...
59 }
Here is the call graph for this function:
state
static volatile fsensor_t state
Definition: filament_sensor.c:23
Base64StreamDecoder::find64
static uint8_t find64(uint8_t base64c)
Definition: base64_stream_decoder.h:22
uint8_t
const uint8_t[]
Definition: 404_html.c:3