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

Pixljs Support? #25

Open
christopher-roelofs opened this issue Sep 25, 2022 · 10 comments
Open

Pixljs Support? #25

christopher-roelofs opened this issue Sep 25, 2022 · 10 comments

Comments

@christopher-roelofs
Copy link

Can pixljs support be added? It looks like the firmware patch could support several eapruino boards with the same hardware but I think pixljs has the most potential with the lcd.

@DanTheMan827
Copy link
Owner

DanTheMan827 commented Sep 25, 2022

The script may already work for the pixl.js provided that the appropriate custom firmware is built for it, but I don't have a pixl that I could actually test with, so I can't verify.

Here's the custom firmware built for pixl.js if you want to try

espruino_2v15.1_pixljs.zip

The firmware patch itself should work on Puck (Including Lite), Pixl, and Bangle (1 and 2), but the script has no special accommodations for hardware with screens

@christopher-roelofs
Copy link
Author

Thanks. My pixljs hasn't arrived yet but I took some time today and built the firmware with your patch. I'm planning on starting with your script and build up from there. In a reddit post, you mentioned issues with the newest firmware. We're you able to resolve those?

@DanTheMan827
Copy link
Owner

Since posting that, I've moved everything important into native code in the custom firmware, you have the NTAG215 javascript object that handles all the setup and NFC communication.

@christopher-roelofs
Copy link
Author

I was able to load up the custom firmware and test the script with only a few modifications and it's working as expected. I noticed you had custom firmware for the banglejs watches but since they are using different chips, I don't think they will support the add ntag lib you created. With that said, I think we can close this.

Is there any way to get the amiibo id or name from the tag? I see you have get tag info but I'm not sure how to get the values in text.

@DanTheMan827
Copy link
Owner

DanTheMan827 commented Sep 30, 2022

  • The bangle uses NRF52840 like the puck, does it not?
  • What modifications did you need to make to get it working?

getTagInfo returns the minimal information needed to identify an amiibo and to decrypt the nickname given.

The function slices data off the full tag, so to reconstruct it you would reconstruct as follows:

  • Bytes 0-7 -> 0-7 of the tag
  • Bytes 8-19 -> 16-27 of the tag
  • Bytes 20-39 -> 32-51 of the tag
  • Bytes 40-47 -> 84-91 of the tag (The amiibo identification)
  • Bytes 48-79 -> 96-127 of the tag

After that, everything is in the same place as an encrypted tag, except for the game data.

@christopher-roelofs
Copy link
Author

You are right, the banglejs2 has the same chip as the puck and pixl. It is the original bangle that has a nRF52832. I Actually own a banglejs2 so I should try the custom firmware and see if it works.

The biggest changes so far I made to the script is identifying the pixl vs the puck from the BOARD and then using BTN1 instead of BTN. I could test it again but I don't think BTN was working. Beyond that, I'm hoping to print the current tag information to the LCD.

Trying to wrap my head around how to convert the bytes to get the head and tail values mentioned here:

To determine amiibo model type, use data from page #21 and #22. Page #21 (bytes[84..<88]) is the "head" and page #22 (bytes[88..<92]) is the "tail" - you can use these values at amiiboapi.com.

@DanTheMan827
Copy link
Owner

DanTheMan827 commented Oct 14, 2022

Reopened because I want to implement at least basic support for the pixl.js (and the other capable espruino hardware)

I don't have any devices with a screen, but I figure I could at minimum make use of the menu module shared across the different devices

@christopher-roelofs
Copy link
Author

Instead of trying to keep one script for all the devices, I stripped out the puck specific functionality I didn't care about to reduce the bloat. Not sure if you want to re-use anything.

https://github.com/christopher-roelofs/ntag215-puck.js/blob/master/pixl.js

Also, based on the comments from the Espruino creator, both bangle and bangle2 don't have the same nfc functionality so I think the only official boards applicable for this are puck, pixl and the MDBT42Q Breakout

@DanTheMan827
Copy link
Owner

DanTheMan827 commented Oct 15, 2022

That's unfortunate that the bangle devices don't have the NFC capability.

As far as a single script for multiple boards, I use terser to minify the code and that removes dead code paths as part of the minification and optimization.

So, if you set a constant to a value and then check that value, it will evaluate the if and remove that code branch entirely if the check fails.

Think if it like how you might use preprocessor conditions in a language like C or C++ to only build certain code paths.

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

No branches or pull requests

2 participants