Stream data through multiple QRCodes
a bit like this meme:
![]()
This project is made possible by all the sponsors supporting my work
You can join them at my sponsors profile:
- QiFi CLI - CLI for streaming QR code file transmission
- luby-transform - Luby Transform encoding and decoding
- @qifi/generate - Stream Generated QR Codes for data transmission
This situation of streaming QR code data transmission is similar to the "Binary Erasure Channel (BEC)," which is a communication model. In this model, the sender transmits binary data (0 or 1), and the receiver has a certain probability of not receiving some data bits, which are marked as "erased" or "lost." In other words, the receiver knows which bits are lost but does not know their specific values. This model is used to study and design coding techniques that can effectively transmit information even in cases of data loss.
Scientists have already achieved very mature research results on how to efficiently transmit data in BEC, one of which is using "Fountain Codes." Fountain Codes are a type of error-correcting code that can effectively transmit information even in the case of data loss. This project uses Luby Transform coding, which is a type of Fountain Code. The basic principle is to divide the original data into multiple small blocks and then generate an unlimited number of encoded blocks through encoding. The receiver only needs to receive enough encoded blocks (usually slightly more than the original blocks) to reconstruct the original data.
IMG_0556.MP4
1. Install Dependencies
You need install Node.js first.The project uses pnpm as its package manager. First, ensure you have pnpm installed:
npm install -g pnpmThen, install the project dependencies:
pnpm install2. Build the Project
Build the project using the command specified in the package.json and netlify.toml:
pnpm run buildThis will generate the output in the .output directory.
Alternatively, if you want to run the development server to test changes:
pnpm run dev3. Serve the Project Locally
if your target environment have Node.js, you can copy entire .output directory to where you want.You can preview this build using:
node .output/server/index.mjsif your target environment don't have Node.js, you cat just host those static files.
cd .output/public
python -m http.serverYou will usually encounter the following errors.
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
you need a custom web server, Run in the .output/public directory:
# python custom_http_server.py
from http.server import SimpleHTTPRequestHandler, HTTPServer
class CustomHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.extensions_map.update({
".js": "application/javascript",
})
super().end_headers()
ADDR = '0.0.0.0'
PORT = 8000
with HTTPServer((ADDR, PORT), CustomHandler) as httpd:
print(f"Serving on http://{ADDR}:{PORT}")
httpd.serve_forever()