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

Discuss BlueGiga Support (and Control+ activation on it) #77

Closed
Sodoshi opened this issue Aug 3, 2020 · 13 comments · Fixed by #145
Closed

Discuss BlueGiga Support (and Control+ activation on it) #77

Sodoshi opened this issue Aug 3, 2020 · 13 comments · Fixed by #145
Assignees
Labels
question Further information is requested

Comments

@Sodoshi
Copy link

Sodoshi commented Aug 3, 2020

Adding Control+ Support ( Mistakenly posted under #58 because the hub describes as a 88012 WeDo 2.0 hub...)
Have made a repo: https://github.com/Sodoshi/SharpBrick.PoweredUp.Bluegiga
Will try and make this more generic to fit SharpBrick observables.

@tthiery
Copy link
Member

tthiery commented Aug 3, 2020

Control+ is already supported. 88012 is the SharpBrick.PoweredUp.TechnicMediumHub in the source code. Sorry for the confusion on the labeling.

@tthiery tthiery changed the title Control+ Discuss BlueGiga Support (and Control+ activation on it) Aug 3, 2020
@tthiery
Copy link
Member

tthiery commented Aug 3, 2020

Can we clarify what we are talking here. I am a bit confused.

Can you hint me, where your current obstacles are?

@Sodoshi
Copy link
Author

Sodoshi commented Aug 3, 2020

When I started work on connecting up an 88012 (I bought the liebherr-r-9800-excavator-42100 kit), it refused to work with any of my existing Bluetooth adapters. After some research, it seemed the latest version of the 88012 uses BLED112 for Control+, and the only BLED112 adapter I could find was the BlueGiga. That's when my painful journey began. (The only existing code I could find to work was the S2Bot, and I wanted c#). When I use Sharp to connect to my hub, it identified as a WeDo 2.0 hub, so I got confused, so apologies for that.

@Sodoshi
Copy link
Author

Sodoshi commented Aug 3, 2020

My biggest current issue is identifying ports. I can't find any code that can dynamically identify them yet, and the TechnicMediumHub ports aren't working for the motors, only for lights, accelerometer, etc.

@tthiery
Copy link
Member

tthiery commented Aug 3, 2020

Hmmm. When you got 88012s... So the TechnicMediumHub... These work including ports and everything.

Some hints

  • if you have not recently connected to the control+ app, do it now. Maybe your hubs have an older firmware version. I did that when I bought mine from BrickLink
  • first, check your BT stack. By default hubs are identified using BLE manufacturer data and in a concrete offset. That might explain your WeDo 2.0 identification problem. There is an API PoweredUpHost.Create which bypasses the above problem. One of the examples use the code instead of the discovery.
  • Use the cli project and type dotnet run -- device list. Dump the result here. That should expose the ports if the BLE stack work correctly.

@tthiery tthiery added the question Further information is requested label Aug 3, 2020
@tthiery
Copy link
Member

tthiery commented Aug 13, 2020

@Sodoshi I have not heard anything ... can I assist you with something?

@Sodoshi
Copy link
Author

Sodoshi commented Aug 13, 2020

I'm good for the moment. I found the source of my confusion:
https://education.lego.com/en-gb/support/wedo-2/bluetooth-driver
Lego's WeDo 2.0 documentation said Bluegiga is their only 'supported' dongle, so I stupidly bought one thinking Control+ and WeDo2 need the same BLED 112.
I bought another dongle and got Control+ working with your code as-is, but I still want to revisit what I started and make Bluegiga work too (because I'm bloody-minded that way).
You can close down this issue for now. When I've got some more production-ready code together (rather than the ropy patch I made to prove things), I'll pull it for you.

@tthiery
Copy link
Member

tthiery commented Aug 13, 2020

Awesome. I agree. I think a BLE driver with proper support for advertisement and characteristics etc... should work fine.

I will keep this open as I want to have an active communication with my consumers ;)

@tthiery
Copy link
Member

tthiery commented Oct 11, 2020

Hi @Sodoshi ... bloody-minded 😀 opinion about whether we should put this to its well deserved closed issue state or are you continue thinking about developing this BLE adapter? Any other update?

@dkurok
Copy link
Contributor

dkurok commented Mar 12, 2021

Hi, not sure wether @Sodoshi did some work on BlueGiga-BLED112-support...
I did an implementation and tested all examples - they work (under Windows; should also work on Raspberry Pi or any Linux able to run .NET becaue the Bluegiga-Dongle is just a serial-device / COM-port).
I have only one issue with it:
I tried to talk to two Hubs (Technic Medium Hubs). It seems that the HubId of a Hub is always set to 0x00 and this is somehow incorrect. I could get two Hubs working by using Hub.Configure(hubid) and setting the HubId to the actual connection (byte) which the adapter has to the hub. But this is dynamic! I have also added this example.
Are you interested in making a Push-request on my changes?

@tthiery
Copy link
Member

tthiery commented Mar 13, 2021

@dkurok Yes, HubId is currently set to 0. I do not have multiple hubs by hand and honestly, did not investigate into the networking aspects of it. The HubId ... to my limited understanding ... makes sense once you have on BLE connection addressing a network of hubs when speaking to one of them. Kind of a mesh.

Regards HubId & Meshing: Feel free to create a second issue apart of this and we can discuss a suitable design & contribution.

Regards BlueGiga support: If @Sodoshi does not react, let us further discuss if you want to publish your code. Would be awesome.

@Sodoshi
Copy link
Author

Sodoshi commented Mar 14, 2021

I'd love to see @dkurok push. I've switched to a non-bled adapter for now, but I'd happily help test.

@dkurok
Copy link
Contributor

dkurok commented Mar 15, 2021

Hi, I did a pull-request now; hopefully I did it the correct way - newbe to GitHub in handling open source pojects
@tthiery : Regards HubId: I tested again and after one of my Hubs received an update of the firmware (I tried Control+-app) everything works fine now. So no need to change something with HubId; as of the protocol from Lego this has always to be 0x00 and seems to be an extension for the future where one hub can control others (so a mesh of Hubs where one is controlling others)
My eample with two Motors (part of the pull-request) now works and there is no need to assign a HubId. The connection to the correct Hub is in the responsibility of the bluetooth-implementation (commands are send to a device, which is connected on a hub which has a bluetooth connection at a given time)

tthiery pushed a commit that referenced this issue Mar 31, 2021
- BlueGiga BLE Stack Implementation (BlueGiga-dongle BLED112)
- Extend CLI by new arguments
- Improve DumpStaticPortInfo to avoid Exception

#77 breaking
tthiery added a commit that referenced this issue Mar 31, 2021
- Minor Updates to reduce changed lines & README.
- Cleanup README and whitespace changes

#77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants