-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from sharpbrick/issue-65-simpler-discovery
Make DiscoveryAsync more user friendly #65 non-breaking
- Loading branch information
Showing
6 changed files
with
86 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
examples/SharpBrick.PoweredUp.Examples/ExampleDiscoverByType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using SharpBrick.PoweredUp; | ||
|
||
namespace Example | ||
{ | ||
public class ExampleDiscoverByType : BaseExample | ||
{ | ||
public TechnicMediumHub DirectlyConnectedHub { get; private set; } | ||
|
||
// device needs to be switched on! | ||
public override async Task DiscoverAsync(bool enableTrace) | ||
{ | ||
var hub = await host.DiscoverAsync<TechnicMediumHub>(); | ||
|
||
selectedHub = DirectlyConnectedHub = hub; | ||
|
||
await hub.ConnectAsync(); | ||
} | ||
|
||
public override async Task ExecuteAsync() | ||
{ | ||
using (var technicMediumHub = DirectlyConnectedHub) | ||
{ | ||
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0x00, 0x00); | ||
|
||
await Task.Delay(2000); | ||
|
||
await technicMediumHub.RgbLight.SetRgbColorsAsync(0x00, 0xff, 0x00); | ||
|
||
await Task.Delay(2000); | ||
|
||
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0xff, 0x00); | ||
|
||
await Task.Delay(2000); | ||
|
||
await technicMediumHub.SwitchOffAsync(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters