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

Add fastupload option #34

Closed
wants to merge 4 commits into from
Closed

Add fastupload option #34

wants to merge 4 commits into from

Conversation

MickaelGuilloux
Copy link

I use base64 encoding for uploading files. Then the NodeMCU "encode" module is used for decoding, which is really more efficient.
As the NodeMCU "encode" module is not included by default on the firmware, I have add this as an option, so that the user can choose whether use it or not.

Mickaël added 4 commits April 24, 2017 19:51
Use base64 encoding for file upload. Data are decoded using the module "encode". This  module must be in the NodeMCU Firmeware for this option to run.
@AndiDittrich
Copy link
Owner

Thanks Mickael!

i will check it soon

@AndiDittrich
Copy link
Owner

Dear Mickael,

i've decided to reject your pull request because i prefer a more generic variant which uses base64 encoding by default with a fallback to hex. this wont require any config flags and will always choose the fastest available method - this is especially more suitable for beginners.

to achive this, i will replace the hexWriteHelper functions with the following generic one (currently working on it)

-- Regular Version
-- ---------------------

-- Base64 Module available ?
if encoder and encoder.fromBase64 then
    -- Use build-in BASE64 Decoder
    _G.__nmtwrite = function(s) file.write(encoder.fromBase64(s)) end
    print("b")
else
    -- Use classic HEX Decoder
    _G.__nmtwrite = function(s) for c in s:gmatch('..') do file.write(string.char(tonumber(c, 16))) end end
    print("h") 
end

i hope this is in your intention and it would be great if you like to test/validate the new version.

best regards, Andi

@AndiDittrich
Copy link
Owner

Please try the latest version of the master branch. i've added the base64/hex transfer functions including the uncompressed code

@MickaelGuilloux
Copy link
Author

Hi Andi,

You are right, your solution is even better and exactly in my intention.
I've just try the latest version of the master branch: it is working fine (both "base64" and "hex" transfert).

For your information, with 23 files for a total size of 32437 bytes, I observe:

  • "base64" transfert: 12 seconds
  • "hex" transfert: more than 1 minute and a half

Thanks for NodeMCU-Tool, it is well written (code is clear and simple) and well documented ! Good job !

best regards, Mickaël

@AndiDittrich
Copy link
Owner

Great! v2.1.0 is out including this feature :)

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

Successfully merging this pull request may close these issues.

2 participants