.NET Console
The simplest CLI. No bells and whistles, but it gets the job done!
We'll build two versions: One will retrieve sensor data using our REST service, and the other will call the gRPC service.
Console Project for REST
https://github.com/jfcarr/dotnet-iot-tui/tree/main/src/ConsoleClient
Steps:
- Create the project, using
consoleas the project type. - Add a project reference to
SenseHatLib.csproj - App settings:
- Copy the
appsettings.default.jsonfile toappsettings.json, and update the setting values. - Add appsettings content entry to the .csproj file.
- Copy the
- Implement details in
Program.cs
Console Project for gRPC
https://github.com/jfcarr/dotnet-iot-tui/tree/main/src/SenseHatGrpcClient
Steps:
- Create the project, using
consoleas the project type. - Add package references to support gRPC:
Google.Protobuf,Grpc.Net.Client, andGrpc.Tools. - Add a project reference to
SenseHatLib.csproj - App settings:
- Copy the
appsettings.default.jsonfile toappsettings.json, and update the setting values. - Add appsettings content entry to the .csproj file.
- Copy the
- Protocol buffer:
- Copy the protocol buffer file from the gRPC service project, and update the namespace.
- Add a Protobuf entry to the project file.
- Implement details in
Program.cs