-
-
Notifications
You must be signed in to change notification settings - Fork 754
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
Promise handling rewrite break BLE device use #2495
Comments
Eurgh. Ok, thanks. This'll be because of #2454 Stuff like this in BLE is done with But looking at this, jspromise_create just creates an empty object you've called So I'm not sure how this can really work as-is... @d3nd3 any thoughts? I guess maybe you assumed jspromise_create wasn't used outside so changed what it does? While we could just return the promise like jswrap_promise_constructor does, then the box is just not referenced at all and freed immediately which seems like it's not the plan? |
@gfwilliams I was aware of jspromise_create() usage outside, I thought its fine since I made the resolve/reject functions take a prombox instead of a promise, but if they are returning the promise to javascript usercode it has to be adjusted to return the child promise which it contains. JsVar *promise = jsvLockAgainSafe(blePromise);
jsble_central_getPrimaryServices(jswrap_ble_BluetoothRemoteGATTServer_getHandle(parent), uuid);
return jsvObjectGetChildIfExists(blePromise, JS_HIDDEN_CHAR_STR"prom"); Can you validate the locks? Not my speciality. Mb its good practise if we name the variables prombox to make it clear also. Box is just a naming for container. Also, are there any other functions which return a promise like this? |
In the code snippet above, I'm not sure what's going on with
A few I think - it's any Espruino function that creates and returns something to the user - so off the top of my head, the bluetooth connect (maybe disconnect), write, startNotifications, then on Bangle we've got beep, buzz, pressure. etc. Basically it's a pretty big bunch of changes. I'll try and reply properly in #2454 |
2v21.114 on Bangle 2 breaks
bthrm
andbthrmlite
for me. It seems to boil down toNRF.requestDevice()
not returning an actual promise and then failing because of the missingthen
-function. The promise itself seems to be run correctly since it prints unhandled errors likeUncaught Error: Unhandled promise rejection: No device found matching filters
.You can check with:
print(NRF.requestDevice({filters:[]}));
It prints
{ }
on 2v21.114 while it printsPromise: { }
on 2v21.The text was updated successfully, but these errors were encountered: