-
Notifications
You must be signed in to change notification settings - Fork 2
CPP SDK Documentation
Class that represents a Karl sensor.
Type | Name | Description |
---|---|---|
public std::string |
sensor_token |
Token assigned to sensor by controller on registration |
private std::unique_ptr<KarlController::Stub> |
stub_ |
Stub representing controller as a GPRC service |
Constructor for KarlSensorSDK object. Takes in a single std::shared_ptr<Channel>
representing a connection to the controller.
Example:
#include <grpcpp/grpcpp.h>
KarlSensorSDK karl(grpc::CreateChannel("localhost:59582", grpc::InsecureChannelCredentials()));
Alternate constructor for KarlSensorSDK object. Takes in a shared_ptr<Channel>
representing a connection to the controller and an sensor token. Used to instantiate already registered sensor.
Example:
#include <grpcpp/grpcpp.h>
KarlSensorSDK karl("PcmCl1R9AUWLmjddBP6jZpPs3070UO3D", grpc::CreateChannel("localhost:59582", grpc::InsecureChannelCredentials()));
request::SensorRegisterResult KarlSensorSDK::SensorRegister(string global_sensor_id, vector<string> keys, vector<string> returns, vector<int> app)
Method to register sensor with controller. Takes in a string global_sensor_id
representing the id for the sensor, and vectors of strings and ints representing the keys, returns, and apps. Returns a SensorRegisterResult
which contains strings sensor_token
and sensor_id
.
Example:
request::SensorRegisterResult result = karl.sensorRegister("camera", {"firmware","livestream"}, {"motion","streaming"}, {});
Method to push byte data to the data sink. Takes in a string param
to denote the label for the data and a vector<char>
for the data itself.
See examples/cpp/example.cc
for complete example.
Returns a pointer to a Reader which will read state updates from the controller.
Example:
unique_ptr<ClientReader<StateChangePair>> reader = karl.connectState();
StateChangePair pair;
while(reader->Read(&pair)) {
// Can read pair.key() and/or pair.value()
...