-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adaptation to Instax SQUARE Link #4
Comments
I have no way of testing this (I don't have that printer) but I expect it to work pretty much the same way, except with a larger image. The mini link uses a 600x800 image so I think the square would use 800x800? Though I can also imagine the code being slightly different as the same filesize limit but a larger image would mean a lower quality image will be printed. If you have an Android phone you could try to record the bluetooth interaction and we can see what happens. See this post for info on doing that: jpwsutton/instax_api#21 (comment) |
@geffaelden If you're on IOS and have a Mac you can also use their PacketLogger tool to record the data between your phone and the printer. Using those logs I should be able to see if / what needs to be changed in to code to support the SQUARE link. I did this the other day and it's pretty straightforward. Basically the steps are:
Pretty clear steps can be found here: https://www.bluetooth.com/blog/a-new-way-to-debug-iosbluetooth-applications/ |
@javl I've done this but can't seem to figure out which log is for the image printing |
@geffaelden On what platform? If you used Packet Logger with IOS you can just start recording, do the printing and stop recording, and send that complete file. There might be some other stuff in there but that doesn't matter, I can filter out the printer part. |
@javl I used the iOS PacketLogger method. Here's the log of the test print I did: https://drive.google.com/file/d/1OZD5cZ8FS1ZkrVpG3Rx0y92isoHqskKw/view?usp=share_link |
@geffaelden Thanks, I'll take a look as soon as I can 👍 |
@geffaelden Took a very quick look and it seems it shouldn't be too hard to adapt my code to work, just need to find the time ;) |
@geffaelden Something is different compared to the way the Mini Link prints its images. Managed to get a 800x800 px image from your logs, but there are some glitches. Do you still have the image file you used for printing? If so I could compare it against what I get from to logs to see what is happening (the app sends over the actual image, so by comparing the original bytes with the logs I should be able to see what's changed). |
Ok, that might explain something: the other printer only supports .jpg but this is .png (though the header in the logs seems to suggest jpg). Thanks for the file. |
It seems the square (and probably wide) apps allow you to select more image types (jpg, png and some newer formats used on IOS and Android) than the app for the Mini Link does (jpg only) but the app just converts the image to jpg before sending it to the printer. There was some error in my parser but now I'm able to extract your image from the logs, meaning I should be able to adapt my code to send your image to the printer as well. Stay tuned ;) Not sure what would be the best approach: having the user set a device type (something like |
@geffaelden I think the fix to support the square is simple: can you try replacing |
I successfully printed an image on the Instax Square Link 🥳 Using a chunkSize of 1808 did the trick! Initially, I encountered an issue with the incorrect image size, which was caused by faulty compression (see image 🤦🏼♂️). However, using an 800x800 JPEG resolved the problem. I developed my own implementation in TypeScript, utilizing the Bluetooth Web API, and drew significant inspiration from your work, @javl. Thank you for your great work! In addition to this, I've been working on parsing other messages of the INSTAX Protocol, such as battery status, charging status, printed images, and more. I wanted to created an alternative UI to print images with an Instax printer via a web browser. I plan to upload my code to GitHub in the coming days. |
@linssenste Wow, super cool! For my current project printing from Python is more useful, but being able to print straight from the browser is such a great idea! And way more accessible for people who don't know how to use Python! Do post a link when your code is online, I'll add it to my readme. |
@linssenste
|
@javl Thanks! I uploaded my source code in the repository and the project is accessible here: https://instax-link-web.vercel.app/ It’s currently only working with the SQUARE printer, but I have access to the mini and wide soon and will test and implement them. 🙃 I will work with your repository as well soon, as I want to programmatically control the printers as well, so we may also close this issue then. Btw: if you want to scale images to test with the python code, you can just download the image, it’s already compressed and resized |
For the mini just use a size of 900 as in my current code. So we know: I thought the wide was just the mini but on landscape, but looking at them online they look more like even larger versions of the square at 800 × 1260. So, 1808 bytes but more packets? |
@linssenste Great readme by the way (and I love Jasper the dog) |
@linssenste was thinking about adding a setting to specify the printer you're using, but then I read this in your readme
I totally forgot you can just get the model type from the printer :) Way more user friendly. But could you point me towards where you get the print size from the device? All the sizes I see in your repo seem to be hard-coded? |
@javl yes, you are right. the adaption to the mini shall be pretty straight forward now :) I will add this functionality, and you may test it (you can abort before printing). I had a quick look at the wide-link protocol and there seems to be a variation how the chunks send, it seems to also have a chunk size of 900 but is using a different splitting of the chunks, but I have to look into that in more detail. I will share a record here as well :) Yes, you can actually also get the type from the serial number (I guess square starts with 50*, wide 20*, mini ???) and there seems to be a readable printer type value in the DEVICE_INFO_SERVICE. But I worked with the image size, because I thought this was more convenient. It's actually not hardcoded - initially it is set to 800x800 and can be switched on the frontend. Once a printer is connected it the image size is read in the |
That works perfectly. You can also get the printer type from a code it sends: the Link Mini seems to be |
Hi @javl, @linssenste, Trying to make this work with a raspberry pi and an instax square link, so it's been a bit painful. Right now, my main problem is during the data packing when it creates packets for printing, with an 800x800 image and a chunksize of 1808.
I get an error:
The length of imagedata at that point is 90110, so more than the H format. |
Your error is 'Error: 'H' format requires 0 <= number <= 65535' which seems to be correct if the length of your data is 90110, which is more than the max allowed 65535 from the error. This suggests your image is about 90kb, try saving it at a lower quality so you end up around or below 65kb. I've had trouble getting this to work with the Rpi so very curious to see your results. In my case it became VERY slow and I was thinking of moving back to a script that uses a bluetooth socket instead when running on a pi. Would love to get this working reliably. |
@vertgo |
@javl I thought I posted last night, I got it working using 'i' instead of 'H'. It was a bit unreliable so there will have to be more tests. Would 'i' also work for the mini printer (I only have the square and the wide, about to try the wide). I could query the model and then decide which to use (square, mini or wide). I tested it from mac and then got it working on the pi. Doing it from pi was a bit spotty, as the simplepyble required installing from piwheels and was only compatible with raspbian bullseye. It is slow, and speed is important to me, so if sockets are faster would love to try that.
|
@vertgo If you run your Pi with a desktop you could give the site @linssenste made a try (you need to enable bluetooth in your browser's settings). It already includes the resizing. https://instax-link-web.vercel.app/ I'd love to be able to use a single bluetooth backend for all systems, but if we can't find a way to speed up the transfer, adding another layer for the socket is needed I guess, as the Pi is also my main target device. I guess we could come up with some structure that allows the user to write a single script and let the module decide what backend to use automatically. I never made a proper tag or branch with the old version, but if you want to give it a go I think the socket was still around in commit 5f78b12 on the main branch (or otherwise just check some other old commits). |
How did you come to the conclusion it was 1808? It seems so specific. I am trying to track down why printing from the app is SO much faster than using the library |
@vertgo If you log the data transfer you can see the size of the packets it is sending. Basically it is the size of the payload minus the header (2), length (1), event code (2), checksum (1) and packet index (4). See this post for an example: #9 (comment) Making it faster would be amazing, but I haven't figure out how yet 😞 |
I've created a separate issue for the speed problem, feel free to post any suggestions, test or remarks in there! |
@javl , isn't the length two (2) bytes ? |
I was wondering if the same code can be adapted to the SQUARE Link? https://instax.com/square_link/en/
The text was updated successfully, but these errors were encountered: