Skip to content

Controlling two hubs not working (Lego 42100) #190

@ChrisKretschmer

Description

@ChrisKretschmer

Hi all,
I'm trying to control the two hubs in the Lego kit 42100 (Liebherr excavator)
I tried to follow the example https://github.com/sharpbrick/powered-up/blob/master/examples/SharpBrick.PoweredUp.Examples/ExampleTwoHubsMotorControl.cs

When I try to connect to the two hubs using the BLE-MACs, i get the following error:

System.ArgumentNullException: Value cannot be null. (Parameter 'device')
   at SharpBrick.PoweredUp.WinRT.WinRTPoweredUpBluetoothDevice..ctor(BluetoothLEDevice device)
   at SharpBrick.PoweredUp.WinRT.WinRTPoweredUpBluetoothAdapter.GetDeviceAsync(IPoweredUpBluetoothDeviceInfo bluetoothDeviceInfo)
   at SharpBrick.PoweredUp.Bluetooth.BluetoothKernel.ConnectAsync()
   at SharpBrick.PoweredUp.Protocol.LegoWirelessProtocol.ConnectAsync(SystemType knownSystemType)
   at SharpBrick.PoweredUp.Hub.ConnectAsync()
   at LegoAPI.Services.Lego.Connect() in C:\Code\LegoAPI\LegoAPI\LegoAPI\Services\Lego.cs:line 54
   at LegoAPI.Services.Lego..ctor(PoweredUpHost host) in C:\Code\LegoAPI\LegoAPI\LegoAPI\Services\Lego.cs:line 28
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
(...)

The code looks as follows:

public ulong BluetoothAddressHub1 = BytesToULong(new byte[] { 0x90, 0x84, 0x2b, 0x64, 0x40, 0x3c });
public ulong BluetoothAddressHub2 = BytesToULong(new byte[] { 0x90, 0x84, 0x2b, 0x64, 0x85, 0x95 });

private async Task Connect()
{
Hub = await _host.CreateByStateAsync<TechnicMediumHub>(BluetoothAddressHub1);
await Hub.ConnectAsync();
Hub2 = await _host.CreateByStateAsync<TechnicMediumHub>(BluetoothAddressHub2);
await Hub2.ConnectAsync();
(...)

Connecting to a single hub works fine using the discoverAsync methods...

Does anyone has a idea?

Thanks in advance!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions