phyphox Forums
How to generate QR code by self programming - Printable Version

+- phyphox Forums (https://phyphox.org/forums)
+-- Forum: Discussion (https://phyphox.org/forums/forumdisplay.php?fid=1)
+--- Forum: Experiments and Ideas (https://phyphox.org/forums/forumdisplay.php?fid=4)
+--- Thread: How to generate QR code by self programming (/showthread.php?tid=1387)



How to generate QR code by self programming - mxxsir - 07-15-2021

hello everyone. Now I have a file(named str1.phyphox) on my computer. I want to use JAVA to create the QR code of this file, just as the phyphox Web-editor creates offline QR code.
I have read it carefully https://phyphox.org/wiki/index.php?title=Transferring_ phyphox_ Experiments & oldid = 20727. I also searched the related topics in the forum, but I still couldn't realize my idea (frustratingly, scanning QR code, always "indicates QR-code failure", which may be caused by CRC32).
Who can help me and share a sample program?

Through the study of this function, I hope that phyphox APP can share .phyphox experiment by QR code, teacher can post QR code to students in the future.

Here is my nasty code and efforts, thank you.
[attachment=397]


RE: How to generate QR code by self programming - Sebastian Staacks - 07-15-2021

Wow, that would probably be helpful for others, too. Especially because the editor generates rather large files that make offline QR codes impractical as they need to be split into multiple codes. When doing it manually, you can usually fit most things into a single QR code. (BTW: You can strip all the editor:... attributes to save on file size as they are not interpreted by phyphox, but only by the editor when loading the file again, which will most likely never happen from the QR code.)

I did not have the chance to read and try your entire code, but at a first glance, I have the following remarks:
  • Unless there is a problem in phyphox, the error should say something about CRC if that is the problem. I think, you are stuck one step before the CRC is checked. I think that phyphox does not even see the characters "phyphox" at the beginning. (See next item.) What is the exact error message?
  • You encode the entire thing as base64 and store it in a text-based QR code. It needs to be a binary QR code and as far as I know, QR codes have a dedicated encoding mode for binary data. Unless this is done via base64 (which I doubt as it would be very inefficient for how QR codes work and for the already small capacity they provide), this is not the same and you should check the QR code library you use for a method to store binary data instead of a string.
  • Phyphox only accepts zipped data in offline QR codes, so you need to compress it first. (Sorry, the documentation can be read as if this was a suggestion, but it is a requirement.)
  • Endianess can be quite annoying here. I cannot tell from your code without testing, but this has tripped me several times, so you might try switching bytesfor the CRC32 when you get to the point where this just does not want to match.

You can also see the receiving end here, if that helps: https://github.com/phyphox/phyphox-android/blob/720caa56d391b316f3732c1fdf5531efea5b25ae/app/src/main/java/de/rwth_aachen/phyphox/ExperimentList.java#L2130

Also, as you might try to compare your results to the one from the editor, be aware that phyphox allows you to strip the header of the zip file. You can only include the binary data, followed by a data descriptor, which is what the editor does. However, this is just a warning that the editor goes one step further - you can include a full zip file and should probably try this first.


RE: How to generate QR code by self programming - mxxsir - 07-20-2021

Thank you very much for your answer! With the help of a professional programmer, offline QR code has been implemented. Thanks! Heart


RE: How to generate QR code by self programming - Sebastian Staacks - 07-21-2021

Great, happy to hear it. If you would like to share your code, you can either just upload it here or send it to us via mail. It might be interesting to other users, too.


RE: How to generate QR code by self programming - mxxsir - 07-23-2021

Thank your encouragement! Heart The code is rough and messy, and the comments are in Chinese. my English is poor. The .phyphox file cannot be more than 1.5k bytes, it will generate a blank jpg. Huh


RE: How to generate QR code by self programming - Jens Noriʇzsɔɥ - 07-23-2021

A QR code could store up to 2953 Bytes at low error correction level (or less for medium, quartile or high). Perhaps this is the reason…

Does your code support multiple QR symbols?