-
Notifications
You must be signed in to change notification settings - Fork 976
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
Why are these pairing parameters in aioble.security module private? #800
Comments
Hi @brianreinhold, You're right this is a somewhat confusing pattern, especially compared to CPython code. In fact, you can't use these from your application at all. There's a MicroPython optimisation where a variable that starts with The recommended approach is to copy the constants you need into your program using the same optimisation trick. You can see this pattern in the aioble l2cap examples (for different constants). It isn't particularly elegant, but it saves a lot of size in the long run. As far as I can see this pattern isn't explicitly documented for |
@projectgus Thanks for the heads up. I did add them to my source (as I had no choice) but I will check out that optimization. I figured anything labeled 'const' would be placed in ROM and read from ROM with some optimized reference scheme. |
It is indeed (mostly) added to flash (ROM) storage, but the size in flash can still add up hence the additional optimisation on top of the first one which makes the variable "vanish" entirely. |
@projectgus Can these _constants only be called from a given file or a given package? I have a bunch of these Bluetooth constants that need to be called by several classes each in their own file. |
@brianreinhold That's correct, the only options are:
|
The aioble security module defines several very important constants needed for pairing such as
I don't understand why they are private. These same constants are needed in any pairing request invoked by the application which means the application must redefine them. I think I can still use them though linters will complain and that would violate policy. Can't they be made public or did I miss something (my search did not find any public set of such constants).
The text was updated successfully, but these errors were encountered: