-
Notifications
You must be signed in to change notification settings - Fork 11
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
Start of higher level SDK #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments.
await self.bluetooth.connect() | ||
await self.inject_all_library_functions() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably handle exceptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? Seems best to let the exceptions bubble up since they are descriptive of the issue and we don't want to continue if we were unable to connect.
Thank you for the feedback. I have fixed all the concerns you both brought up, except for trapping exceptions in frame-utilities-for-python/src/frameutils/frame.py Lines 32 to 36 in e5f4c65
The exceptions that may bubble up include when the device can't be found, where it's in a bad state and needs to be re-paired, etc. These are descriptive and not possible to work around so it seems best to let them bubble up. Do you have any ideas for how to better handle this? Also I added |
Per discussions with @siliconwitch, I published my Python SDK as a separate package leaving this existing Here's the new frame-sdk-python package links: |
Started adding a higher level SDK framework. See the readme for examples of usage.
Frame.run_lua(string: str, await_print: bool = False) -> Optional[str]
executes lua regardless of length by callingFrame.send_long_lua
as necessaryFrame.evaluate(string: str) -> str
evaluates lua (regardless of length) and returns the result (equivalent to wrapping it inprint()
)Frame.send_long_lua(string: str, await_print: bool = False) -> Optional[str]
executes lua longer than the MTU by writing it to a file in chunks and then running that file.FrameFileSystem.write_file(path: str, data: bytes, checked: bool = False)
writes a file in chunks.checked
adds basic checking for each chunk to ensure correct writing, which is important for reliability in my testing.Also added
FrameFileSystem.file_exists
andFrameFileSystem.delete_file
and a bunch of others, but there's still plenty more to go.Also added
Bluetooth.set_print_debugging(value: bool)
which is effectively keepsshow_me
on, and is useful for debuggingwrite_file
or anywhere else where the user is not directly callingBluetooth.send_lua()
.Added several tests as well. All tests are passing consistently for me on MacOS. Failures on Ubuntu due to an incompatibility between Ubuntu's BlueZ bluetooth driver and the Bleak python bluetooth library (see hbldh/bleak#1166 (comment), although the change required is out of scope for this PR). I am getting inconsistent failures on Windows due to connection instability, which will require additional testing later.