Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content Encoding Error #668

Open
kemploe opened this issue Jan 14, 2025 · 9 comments
Open

Content Encoding Error #668

kemploe opened this issue Jan 14, 2025 · 9 comments

Comments

@kemploe
Copy link

kemploe commented Jan 14, 2025

I tried to recompile websrc/index.html without success.

Here are the steps I have done:

  1. Successfully downloaded the latest (v2.0.0) source code from https://github.com/esprfid/esp-rfid

  2. Uncompress source code

  3. Fire up VS Code and subsequently the Platform IO extention then open the esp-rfid

  4. In tools/webfilesbuilder executed:
    a. npm install gulp
    b. npm install gulp-cli -g
    c. npm install gulp -D
    d. gulp

  5. Back to VS Code in Platform IO I executed 'build' then 'upload'

  6. Connected my laptop via Wi-Fi to 192.168.4.1

  7. Fire up Firefox and open http://192.168.4.1

  8. Firefox returned an error:

     Content Encoding Error
    
     The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
    

Did I missed something here?

My setup is:

- Windows 11 on Intel Core i7 Processor
- VS Code (user)		1.96.3
- node.js			22.13.0 (LTS)

Thanks a lot

@tctlrd
Copy link
Contributor

tctlrd commented Feb 4, 2025

Yes, the gulpfile.js needs some work. I was getting a corrupt gzipped font file and the final ".gz.h" byte array files were all coming out broken in some way resulting in the browser error you mentioned.

You can take a look at my currently working gulpfile.js (note: there are extra functions because it is from the esp32-rfid fork):

https://github.com/tctlrd/esp32-actl/blob/dev/tools/webfilesbuilder/gulpfile.js

Here is a functional file to byte array creator:

function createByteArray(source, destination, arrayName, cb) {
    try {
        const data = fs.readFileSync(source);
        const wstream = fs.createWriteStream(destination);
        wstream.on('error', function (err) {
            console.log(err);
        });

        wstream.write(`#define ${arrayName}_len ${data.length}\n`);
        wstream.write(`const uint8_t ${arrayName}[] PROGMEM = {`);

        for (let i = 0; i < data.length; i++) {
            if (i % 1000 === 0) wstream.write('\n');
            wstream.write('0x' + data[i].toString(16).padStart(2, '0'));
            if (i < data.length - 1) wstream.write(',');
        }

        wstream.write('\n};');
        wstream.end();
        cb();
    } catch (error) {
        console.error('Error processing gzipped file:', error);
        cb(error);
    }
}

@kemploe
Copy link
Author

kemploe commented Feb 4, 2025

@tctlrd

Wow, I was not expecting to get any answer from the developers and yet there is an answer and solution for the problem now.

You made my day, Thank you so much for your kindness.

I will grab your code and give you a feedback soon

~ kemploe ~

@matjack1
Copy link
Collaborator

matjack1 commented Feb 4, 2025

Hey @tctlrd , would you be up for opening a pull request?

Would be nice to merge efforts! I'm interested in supporting also ESP32, but I would prefer to keep also 8266 compatibility.

@matjack1
Copy link
Collaborator

matjack1 commented Feb 4, 2025

Reading this a bit more, I see that you are on Windows. I cannot test Windows right now, so if you can open a PR here with the code that works for you, if it works for me too we can get it merged quite quickly :)

@tctlrd
Copy link
Contributor

tctlrd commented Feb 5, 2025

@matjack1 yes, I plan to open a pull request; thank you! It will take some time since I am still working through the gulpfile. I am using linux and will not be testing on other operating systems.

@kemploe
Copy link
Author

kemploe commented Feb 7, 2025

@matjack1

Reading this a bit more, I see that you are on Windows. I cannot test Windows right now, so if you can open a PR here with the code that works for you, if it works for me too we can get it merged quite quickly :)

I have the same issue in Ubuntu 22.04 Desktop as well.

~ kemploe ~

@tctlrd
Copy link
Contributor

tctlrd commented Feb 11, 2025

@matjack1

As requested: #670

Hey @tctlrd , would you be up for opening a pull request?

Would be nice to merge efforts! I'm interested in supporting also ESP32, but I would prefer to keep also 8266 compatibility.

@matjack1
Copy link
Collaborator

Awesome! Thanks, I'll try it very soon, hopefully tomorrow :)

@matjack1
Copy link
Collaborator

@kemploe the code is now merged on stable, if you have time to test, it would be very nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants