-
Notifications
You must be signed in to change notification settings - Fork 59
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
B21 Support? #4
Comments
Currently, some parts (e.g. image size) of niimprint is hard-coded to D11-like printers. I need to fix this (and do documentation!) someday, but I'm busy for personal things. |
Totally understand! I've made a lot more progress and I'm able to get it to print larger sizes now, but I'm struggling to get it to print in landscape. Do you have any data you could share about how the header in the image packets is calculated? I'm trying to scale it up to work with a full width image (400px wide for this printer, as far as I can tell), but I'm having trouble calculating the header in a way that works. Far as I can tell so far, the header is 6 bytes where the first two bytes is the line number, the next three bytes are the counts of how many bits are set in that line (where each byte represents the number of bits set for the length of the line divided by 3) and the last byte is always 0x01. This works fine when I use lines of width 30 (where each of the three bytes represents 10 bytes each), but it doesn't work when I try to scale it up to lines of width 48 (where each byte would represent 16 bytes). Any suggestions? edit: OK so I actually got the above working, and it's printing nicely! That being said, I don't know how to handle calculating the checksum for a line length that doesn't divide nicely by 3. Any idea how I could do it for, for example, a line length of 50 (400px)? |
I'm working on a React Native implementation based on this repo, can you give an example of your code? I'm going through a similar problem when "transforming" a canvas. |
Could you perform Bluetooth packet capture between B21 and official app? I'd like to analyze, but I don't have any devices other than D11. |
Sure, what do you want to see? |
Sure, but I don't know how to do this. Any articles you can point me to? Anyway, I think I mostly got this figured out. Looks like even the official app can only print as large as 384mm wide, so looks like I'm already at the max. |
For Android, refer Gadgetbridge's document about BT snoop. Not sure about capturing on IOS |
I bought B21 myself for analyze, and it uses same packet type as D11. Different thing is, D11's pixel count encodes 32 pixels per byte (96 / 3 = 32), but B21 encodes 128 pixels per byte (384 / 3 = 128). |
@kjy00302 What's your experience with aftermarket rolls of paper on B1/B21? |
unfortunately I don't have a rooted phone, and for whatever reason the non-root methods don't work for me. Either way, I see you bought one to see for yourself
yeah I ended up figuring this out, was able to get it to print fine using 128 pixels/byte @alexzirnea I scanned the NFC tag in one of the official rolls with my Flipper Zero and have been emulating it when powering up so that I can use rolls of receipt paper (super cheap) for testing. This has been working great, looks like the B21 only tries to read the NFC tag when powering up or after opening/closing the lid. |
@rickyelopez I wouldn't have worried about the possibility of spoofing the NFC tag. The issue is that some sizes are tied to a specific serial number contained within the NFC tag itself
I guess you can inject a "known" roll data and print with it forever and also have custom size labels? |
Yeah that's exactly why I did it.
|
I think it is very unlikely that the printer will ever write to the tag itself. |
I have some wireshark captures of USB communication (basically serial data) with B21. Anyone needs that? |
I think USB serial uses same protocol as Bluetooth serial. (also refer #8) |
@kjy00302 cool :) |
NFC IDseems all the IDs have the format
Genuine Check MechanismI put 10 new rolls then back to the old roll but it is still faint. previously when calling the technical hotline, they said they were able to see the number of prints on a roll based on the serial number of my roll. I might take that with a pinch of salt because the number of prints (300 claimed) was way more than the number of labels I had in the roll (240). either the NVM storage is like you mentioned, 20 rolls or more (definitely above 10), or they are using some other smarts that might involve online DB. that being said, I can't even print a test page clearly even when the device is not connected to the app |
That is really good info! |
@rickyelopez Are you able to share your code? The code works with the D110, but I have 15x30mm labels, 120x240 bitmap - but the top is continously cropped off. I suspect its the bit counts but unsure how to approach it. |
Sure, I can push my code to a fork tonight. I didn't clean it up but it should work. |
That'd be great. Thank you! |
https://github.com/kjy00302/niimprint/compare/main...rickyelopez:niimprint:b21?expand=1 Sorry for the mess. I think I had started to try to clean up some of the code but then I got busy with other projects. Anyway, what you're looking for should be in there. |
Thanks Ricky - much appreciated. |
I tried using the Niimbot B21 with a raspberry pi yesterday. I managed to connect to via bluetooth, but not via USB. But then when I ran the scripts (several forks of them, also the one by @rickyelopez) I get timeouts or
Here are two of the error messages:
The first one is shown when the Pi is connected to the printer via bluetooth, the second one when it isn’t. And then I have a final question: did anyone manage to turn off the sound? It’s horrible! |
@vasilisvg check out my fork. B21 works fine both via bluetooth and usb. I also got "connection timed out" error, I think that's because B21 has two bluetooth addresses and you connected to the wrong one (see notes here). P.S. I don't beleive there's a way to disable sound in software. The only way is to take it apart and desolder the beeper. |
that's an awesome cleanup, thanks! |
@AndBondStyle That looks fantastic! I’ll probably have some time to play with it later this week. Can’t wait! |
@AndBondStyle I managed to get it to work! Thank you so much! |
More genuine label rolls in my hand:
Maybe these will help somehow? |
1D:A0:70:AC:8E:00:00 50*30 label |
I had another go at this and found out there's also this text on the serial port on the PCB
|
Data exchange log between printer and label: |
Hi there, really cool that you managed to figure all this out.
I'm trying this on a B21, and when I try to print an image with a width of 96px, it comes out in the center of the label, rotated the wrong way, and tiny. Any idea why that might be happening?
I've read through all the code and I'm not understanding a few things:
It is printing something, so it seems like the general structure is the same across this printer and whichever one you were testing this with. Happy to help get this working on the B21, but as it stands I'm missing some context on what to try.
Appreciate any help, thanks!
The text was updated successfully, but these errors were encountered: