RoboidControl-cpp/Things/TemperatureSensor.cpp
2025-03-07 11:47:45 +01:00

31 lines
988 B
C++

#include "TemperatureSensor.h"
#include "Messages/LowLevelMessages.h"
namespace RoboidControl {
// TemperatureSensor::TemperatureSensor() : Thing(Type::TemperatureSensor) {}
// TemperatureSensor::TemperatureSensor() : Thing(Type::TemperatureSensor) {}
TemperatureSensor::TemperatureSensor(Participant* participant,
unsigned char networkId,
unsigned char thingId)
: Thing(participant, networkId, thingId, Type::TemperatureSensor) {}
void TemperatureSensor::SetTemperature(float temp) {
this->temperature = temp;
}
void TemperatureSensor::GenerateBinary(char* buffer, unsigned char* ix) {
// std::cout << "Send temperature: " << this->temperature << "\n";
LowLevelMessages::SendFloat16(buffer, ix, this->temperature);
}
void TemperatureSensor::ProcessBinary(char* bytes) {
unsigned char ix = 0;
this->temperature = LowLevelMessages::ReceiveFloat16(bytes, &ix);
}
} // namespace RoboidControl