Commit a429aba8 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

publish string repr of eigen stuff

parent a626aed4
......@@ -21,7 +21,7 @@ class MqttInterface {
std::mutex data_m;
bool getRun();
// std::string getValues();
std::string getValues();
std::string getBattery();
};
#endif /* !MQTT_INTERFACE_HPP */
......@@ -50,13 +50,19 @@ void MqttInterface::start() {
MQTTClient_subscribe(client, "/odri/commands", 0);
MQTTClient_deliveryToken token;
char *battery_c;
// char* values_c;
std::string values_s;
std::string battery_s;
char* values_c;
char* battery_c;
while (getRun()) {
battery_c = getBattery().data();
values_s = getValues();
battery_s = getBattery();
values_c = values_s.data();
battery_c = battery_s.data();
MQTTClient_publish(client, "/odri/battery", strlen(battery_c), battery_c, 0, 0, &token);
MQTTClient_publish(client, "/odri/values", strlen(values_c), values_c, 0, 0, &token);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
......@@ -75,6 +81,13 @@ bool MqttInterface::getRun() {
return run_;
}
std::string MqttInterface::getValues() {
std::lock_guard<std::mutex> guard(data_m);
std::stringstream ret;
ret << values_.transpose();
return ret.str();
}
std::string MqttInterface::getBattery() {
std::lock_guard<std::mutex> guard(data_m);
std::string ret = std::to_string(battery_);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment