cubing / cubing.js

🛠 A library for displaying and working with twisty puzzles. Also currently home to the code for Twizzle.
https://js.cubing.net/cubing/
GNU General Public License v3.0
245 stars 44 forks source link

Add GAN i3 support #282

Closed ghost closed 11 months ago

ghost commented 1 year ago

Adding unsafeDecryptBlockWithIV. Moving the unsafeDecryptBlock functionality to unsafeDecryptBlockWithIV while retaining the 'zeros' IV used previously. This allows us to decrypt data which was encrypted with a predetermined IV (required for GANi3 support #212).

Roman- commented 1 year ago

The message "No Services matching UUID 0000fff0-0000-1000-8000-00805f9b34fb found in Device" is gone. However, after trying to connect Gan 356i3, this error message appears in 5 seconds after successful connection:

image

Making moves on the physical cube are not displayed, both before and after the message appears.

ghost commented 1 year ago

The message "No Services matching UUID 0000fff0-0000-1000-8000-00805f9b34fb found in Device" is gone. However, after trying to connect Gan 356i3, this error message appears in 5 seconds after successful connection:

image

Making moves on the physical cube are not displayed, both before and after the message appears.

Sorry it's not working, this is one of the areas I had trouble with.

There's a step during initialization where the cube should broadcast it's MAC address (which is needed to decrypt the cube's data). And, I believe this is probably what's failing for you. Unfortunately, I've had mixed results with getting it to work, and only recently had success when running the site over HTTPS. I've thought about prompting the user or having an input on the bluetooth sample screen, but I'd rather try and get it working properly.

If you want to hard code your own MAC address (for testing or other purposes), you can do it here:

https://github.com/cubing/cubing.js/blob/7f497faa22f0f32a8809c4e2be7d6fc79d049b06/src/cubing/bluetooth/smart-puzzle/gani3.ts#L162-L171

lgarron commented 1 year ago

Thanks! I'll have to take a close look at this, but I'll be glad to have support for the i3!

Roman- commented 1 year ago

@nagytech the hack with the hardcoded MAC works, but then the npm run build command fails:

$ npm run build

> cubing@0.38.1 build
> make build

rm -rf \
    dist .temp coverage script/bin/screenshot-src/main.js \
    ./alg ./bluetooth ./kpuzzle ./notation ./protocol ./puzzle-geometry ./puzzles ./scramble ./search ./stream ./twisty
node ./script/build/main.js all
Building target: static-package-metadata
Writing: alg/package.json
Writing: dist/esm/alg/index.d.ts
Writing: bluetooth/package.json
Writing: dist/esm/bluetooth/index.d.ts
Writing: kpuzzle/package.json
Writing: dist/esm/kpuzzle/index.d.ts
Writing: notation/package.json
Writing: dist/esm/notation/index.d.ts
Writing: protocol/package.json
Writing: dist/esm/protocol/index.d.ts
Writing: puzzle-geometry/package.json
Writing: dist/esm/puzzle-geometry/index.d.ts
Writing: puzzles/package.json
Writing: dist/esm/puzzles/index.d.ts
Writing: scramble/package.json
Writing: dist/esm/scramble/index.d.ts
Writing: search/package.json
Writing: dist/esm/search/index.d.ts
Writing: stream/package.json
Writing: dist/esm/stream/index.d.ts
Writing: twisty/package.json
Writing: dist/esm/twisty/index.d.ts
Successfully built target in 0.007 seconds (0 spent in dependencies): static-package-metadata
Building target: esm

  dist/esm/twsearch-BDAXZGZU-4Y6SSRS3.js                      468.3kb
  dist/esm/twisty/index.js                                    176.4kb
  dist/esm/puzzles-dynamic-side-events-5U5X3GU4.js            142.5kb
  dist/esm/puzzle-geometry/index.js                           132.9kb
  dist/esm/search-dynamic-solve-4x4x4-62DEQ3YO.js              67.9kb
  dist/esm/search-dynamic-solve-3x3x3-FJI2OWOW.js              63.2kb
  dist/esm/bluetooth/index.js                                  58.1kb
  dist/esm/chunk-K6P4XQ5M.js                                   52.9kb
  dist/esm/twisty-dynamic-3d-RWX3QZGR.js                       52.4kb
  dist/esm/search-dynamic-solve-fto-IDE3JR5R.js                47.4kb
  dist/esm/search-dynamic-sgs-unofficial-Q3G4WEHA.js           36.3kb
  dist/esm/chunk-H757CRS5.js                                   35.7kb
  dist/esm/chunk-EIWWC7GN.js                                   33.9kb
  dist/esm/search-dynamic-sgs-side-events-JBZITTJ6.js          32.3kb
  dist/esm/puzzles-dynamic-unofficial-QXSDLTK5.js              30.9kb
  dist/esm/chunk-APARZQAL.js                                   24.8kb
  dist/esm/search-dynamic-solve-master_tetraminx-N2NAFS2P.js   20.7kb
  dist/esm/chunk-E4YNQSMQ.js                                   20.7kb
  dist/esm/search-dynamic-solve-sq1-OKRDTBN4.js                19.9kb
  dist/esm/search-dynamic-solve-kilominx-ALWZNTV5.js           19.6kb
  dist/esm/chunk-RPPBS6RZ.js                                   19.3kb
  dist/esm/puzzles-dynamic-megaminx-FUKAIAP5.js                17.4kb
  dist/esm/puzzles-dynamic-3x3x3-QN5DUJUA.js                   17.4kb
  dist/esm/chunk-XXBWGDUL.js                                   11.8kb
  dist/esm/chunk-I2M2WN44.js                                   10.8kb
  dist/esm/puzzles-dynamic-4x4x4-DT42HVIY.js                    8.6kb
  dist/esm/chunk-TK463E2F.js                                    7.2kb
  dist/esm/chunk-ECJRP7TK.js                                    7.0kb
  dist/esm/twsearch-4XUU55WV.js                                 3.8kb
  dist/esm/chunk-KDJSZA3U.js                                    3.1kb
  dist/esm/stream/index.js                                      2.7kb
  dist/esm/chunk-ZYCJIZDN.js                                    880b 
  dist/esm/chunk-6OUID4YZ.js                                    876b 
  dist/esm/protocol/index.js                                    741b 
  dist/esm/search/index.js                                      724b 
  dist/esm/alg/index.js                                         668b 
  dist/esm/notation/index.js                                    582b 
  ...and 49 more output files...

âš¡ Done in 51ms
Successfully built target in 0.063 seconds (0.007 spent in dependencies): esm
Building target: types
Note: The `types` target is slow. Expect several seconds.
CLI Building entry: src/cubing/alg/index.ts, src/cubing/bluetooth/index.ts, src/cubing/kpuzzle/index.ts, src/cubing/notation/index.ts, src/cubing/protocol/index.ts, src/cubing/puzzle-geometry/index.ts, src/cubing/puzzles/index.ts, src/cubing/scramble/index.ts, src/cubing/stream/index.ts, src/cubing/search/index.ts, src/cubing/twisty/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.7.0
DTS Build start
src/cubing/bluetooth/smart-puzzle/gan.ts(445,16): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'BluetoothPuzzle'.
src/cubing/bluetooth/smart-puzzle/gan.ts(476,14): error TS2741: Property 'optionalManufacturerData' is missing in type '{ connect: any; prefixes: string[]; filters: { namePrefix: string; }[]; optionalServices: string[]; }' but required in type 'BluetoothConfig<BluetoothPuzzle>'.

Error: error occured in dts build
    at Worker.<anonymous> (/tmp/cubing.js/node_modules/tsup/dist/index.js:2281:26)
    at Worker.emit (node:events:511:28)
    at MessagePort.<anonymous> (node:internal/worker:260:53)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
DTS Build error
RollupError: Failed to compile. Check the logs above.
    at error (/tmp/cubing.js/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:210:30)
    at Object.error (/tmp/cubing.js/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:23714:20)
    at Object.error (/tmp/cubing.js/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:22979:42)
    at generateDtsFromTs (/tmp/cubing.js/node_modules/tsup/dist/rollup.js:7498:22)
    at /tmp/cubing.js/node_modules/tsup/dist/rollup.js:7505:59
    at _nullishCoalesce (/tmp/cubing.js/node_modules/tsup/dist/rollup.js:1:198)
    at Object.transform (/tmp/cubing.js/node_modules/tsup/dist/rollup.js:7505:18)
    at /tmp/cubing.js/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:23915:40
src/cubing/bluetooth/smart-puzzle/giiker.ts(256,14): error TS2741: Property 'optionalManufacturerData' is missing in type '{ connect: any; prefixes: string[]; filters: ({ namePrefix: string; } | { services: string[]; })[]; optionalServices: string[]; }' but required in type 'BluetoothConfig<BluetoothPuzzle>'.

src/cubing/bluetooth/smart-puzzle/gocube.ts(97,10): error TS2416: Property 'reset' in type 'GoCube' is not assignable to the same property in base type 'BluetoothPuzzle'.
  Type '() => void' is not assignable to type '() => Promise<void>'.
    Type 'void' is not assignable to type 'Promise<void>'.
src/cubing/bluetooth/smart-puzzle/gocube.ts(97,10): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'BluetoothPuzzle'.
src/cubing/bluetooth/smart-puzzle/gocube.ts(163,14): error TS2741: Property 'optionalManufacturerData' is missing in type '{ connect: any; prefixes: string[]; filters: { namePrefix: string; }[]; optionalServices: string[]; }' but required in type 'BluetoothConfig<BluetoothPuzzle>'.

src/cubing/bluetooth/smart-robot/GanRobot.ts(308,14): error TS2741: Property 'optionalManufacturerData' is missing in type '{ connect: any; prefixes: string[]; filters: { namePrefix: string; }[]; optionalServices: string[]; }' but required in type 'BluetoothConfig<GanRobot>'.

src/cubing/bluetooth/smart-timer/GanTimer.ts(137,14): error TS2741: Property 'optionalManufacturerData' is missing in type '{ connect: any; prefixes: string[]; filters: { namePrefix: string; }[]; optionalServices: string[]; }' but required in type 'BluetoothConfig<GanTimer>'.

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v20.2.0
make: *** [Makefile:28: build] Error 1

Note that npm run build on the master branch works just fine.

ghost commented 1 year ago

@Roman-

I've been using make dev which appears to be less strict. I'll have a look and fix up those warnings.

ghost commented 1 year ago

npm run build works for me now.

image

ghost commented 11 months ago

Gonna close this.

Thanks anyway.