jeffmer / WatchApps

Support to run Bangle/Espruino Apps on P8, ROCK and Magic3 Smart Watches
MIT License
19 stars 10 forks source link

Gadgetbridge notifications #3

Closed dapgo closed 2 years ago

dapgo commented 2 years ago

Would it be possible to port the bangle "GadgetBridge" apps to Watchapps?

Android Integration Messages

I haven't tried to install but I assume that required functions from bangle will be missing here.

jeffmer commented 2 years ago

Yes, I have had a quick look and tried loading both apps directly from the Bangle App loader. The apps run with no issues and I think the only thing you need to do is add a line to .boot0 to run the android boot file. .boot0 should really look for boot files but it does not currently so a quick hack would be:

if(STOR.read("android.boot.js")) eval(STOR.read("android.boot.js"));

I do not have and a working android phone to hand so I cannot test further -let me know how you get on.

jeffmer commented 2 years ago

Correction, you need to add the line:

if(STOR.read("android.boot.js")) eval(STOR.read("android.boot.js"));

at the end of main.js

dapgo commented 2 years ago

Before I was trying without success with:

if(require("Storage").read("android.boot.js")) eval(require("Storage").read("android.boot.js"));

and NRF.setAdvertising({},{name:"espruino"});

(also with bangle term)

but GB is/was not discovering the device.

I added the line to main.js but I am still not able to discover the watch from GB. Even if i use the GB unsupported devices mode, that can find pcs or refrigerators xD

I can give you an android device compatible with GB, but maybe shipment cost is higher than the phone value

jeffmer commented 2 years ago

HI, I got hold of an oldish Android phone (5.0.1) and got in to run gadgetBridge. I did manage to connect to a P8 running the apps, however, I could not connect to a magic3, mostly because the GadgetBridge app crashed after it discovered three devices. Did not manage to get much further with the connect device - not sure how to debug.

Correction: I had a silly mistake and now the battery percentage display in GadgetBridge so communication is OK.

jeffmer commented 2 years ago

OK, if you update your main module from the repository (delete it and reload), notifications should now work. I will leave it open until you confirm that you gave got it to work with the real GB. I tested it with a message typed at the Web IDE console: GB({t:"notify", id:5, src:"gadget",title:"Test",body:"message"});

dapgo commented 2 years ago

Yes, it works 💯

The only remark is that I had to add a step(upload lcp-p8.js) in the middle of removing and installing, because installation was failing Uncaught ReferenceError: "p" is not defined

at console it was more verbose Uncaught ReferenceError: "ST7789" is not defined at line 10 col 4 in main.js var g=ST7789(); ^

Uncaught Error: Cannot read property 'drawRect' of undefined at line 1 col 2 g.drawRect(10,g.getHeight()-16,g.getWidth()-10,g.getHeight()... ^ Uncaught ReferenceError: "p" is not defined at line 1 col 1287 ...muVluM6myKDvs7")),0,1253);;p(7);Bluetooth.println("OK")

jeffmer commented 2 years ago

I thought the new version of boot had fixed that. Anyway, I will close this issue!