initial virtual sensor with protobuf
This commit is contained in:
commit
cbee09be85
7 changed files with 326 additions and 0 deletions
sensor-query-cli
30
sensor-query-cli/main.cpp
Normal file
30
sensor-query-cli/main.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpcpp/channel.h>
|
||||
#include <grpcpp/client_context.h>
|
||||
#include <grpcpp/create_channel.h>
|
||||
#include <grpcpp/security/credentials.h>
|
||||
|
||||
#include "sensor.pb.h"
|
||||
#include "sensor.grpc.pb.h"
|
||||
|
||||
int main() {
|
||||
auto channel = std::shared_ptr(grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials()));
|
||||
auto stub = Sensor::NewStub(channel);
|
||||
|
||||
grpc::ClientContext context;
|
||||
|
||||
StatusRequest request;
|
||||
SensorStatus status;
|
||||
grpc::Status rpc_status = stub->get_status(&context, request, &status);
|
||||
|
||||
if( rpc_status.ok() ) {
|
||||
std::cout << "Sensor Status:" << std::endl;
|
||||
std::cout << status.DebugString() << std::endl;
|
||||
} else {
|
||||
std::cout << "get_status() failed" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue