Skip to content
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

How to wrap this up into a nice API #3

Open
movprojects opened this issue Aug 12, 2017 · 10 comments
Open

How to wrap this up into a nice API #3

movprojects opened this issue Aug 12, 2017 · 10 comments

Comments

@movprojects
Copy link

What would it take to wrap up all this low level code into a nice python package? We have enough info for that yet?

@JorgePe
Copy link
Owner

JorgePe commented Aug 12, 2017

I am goind to write some python examples in athe next 2 days but I'm no programmer so I'm not the best person to write an API.
But it's quite easy to create a python package.
As I wrote, I use pybluez and gatttlib. There are other libraries but these were the first that I could use in ev3dev and are already included with it. I wrote a short tutorial on how to use ev3dev to talk with WeDo 2.0, if you want to understand the basics:
http://www.ev3dev.org/docs/tutorials/controlling-wedo2-motor/

Please understand that I'm reverse engineering the BOOST and writing short examples at the same time. A small background on BT BLE is needed if you want to use my information on your own right now. For example, I tend to use handles in my code, it's easier. But handles can change whenever the firmware changes so a good practice is to scan your device, read all uuids and get the handle for the uuid you want to use.
Also we can not assume that because today everything is at the same handle it will also be like that in the future - it can be split by several handles (like the WeDo 2.0). A good API will have to take that in consideration to prevent a total failure whenever LEGO updates the firmware.

@JorgePe
Copy link
Owner

JorgePe commented Aug 30, 2017

I already started a python package.
Still polishing some things (byte manipulation) but hope in a few to days to have something for controlling motors and RGB LED.
Sensors will follow later but I'm facing crashes when receiving notifications, I might need to upgrade my BlueZ stack or open an issue and hope for a pygattlib patch.

@undera
Copy link
Contributor

undera commented Sep 12, 2017

I took existing python examples and managed to make them work. That's positive experience.
I am python dev, and I think I'd make python part of it in slightly different way. Maybe I'll experiment on making my own python lib.
The thing I really miss is good explanation of wire protocol. Not always clear how to form commands, from the existing docs. Maybe I'll ask some questions later, hope somebody will help me.

Anyway this is awesome project and I wanted to say words of appreciation to its authors!

@JorgePe
Copy link
Owner

JorgePe commented Sep 12, 2017

Thanks! Great that you could manage to use the examples.

As I stated, I'm not really a programmer. Other people have joined the project and they do have a much better programming background/skills/whatever than my self and even started their own projects, that was one of the main ideas when this project started and I'm very happy that several people have made good use of it.

You're right , the protocol lacks a good explanation. Things have gone quite fast lately and last two weeks it has been impossible for me to keep up with all the information updates. Will try soon. But please note that until LEGO releases an official SDK there will be some dark parts - some commands were found by pure luck, like the WeDo 2.0 motor.

Even with a SDK, I feel that we will still be missing something. The WeDo 2.0 SDK doesn't properly document this new Power Functions 2.0 devices (WeDo 2.0 and BOOST... and probably something more still to be released).

if by any chance you start your own python library please give us a link so we can add to the README file (if you don't mind, of course). People will surely benefit if they have a better option than my library (which, by the way, is being target for my MINDSTORMS EV3 and Raspberry Pi's).

@undera
Copy link
Contributor

undera commented Sep 13, 2017

Here's my repo: https://github.com/undera/pylegoboost

@JorgePe
Copy link
Owner

JorgePe commented Sep 13, 2017

Added.
Be careful with the name... LEGO has some tough policies related to it's name and trademarks. Might not matter for a small open source project but if you ever make success and try to go to market they will come after you :)

Another BLE library based on BlueZ... have you used it before? I wonder if t works well on low power armel like the EV3.

@undera
Copy link
Contributor

undera commented Sep 13, 2017

No, this is my first attempt to do anything with Bluetooth.

Well, I can rename repo into pylgbst - will it help?

@JorgePe
Copy link
Owner

JorgePe commented Sep 13, 2017

For me the name is fine. It's your project, you do what you want :)

@undera
Copy link
Contributor

undera commented Sep 13, 2017

Sure I understand I'm free. But your advice is highly appreciated.

@undera
Copy link
Contributor

undera commented Sep 13, 2017

I have renamed it, just in case: https://github.com/undera/pylgbst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants