32 lines
1018 B
C++
32 lines
1018 B
C++
#include "TemperatureSensor.h"
|
|
|
|
#include "Messages/LowLevelMessages.h"
|
|
|
|
namespace RoboidControl {
|
|
|
|
// TemperatureSensor::TemperatureSensor(Participant* participant,
|
|
// unsigned char thingId)
|
|
// : Thing(participant, Type::TemperatureSensor, thingId) {}
|
|
|
|
TemperatureSensor::TemperatureSensor(Participant* owner) : Thing(owner, Type::TemperatureSensor) {}
|
|
|
|
TemperatureSensor::TemperatureSensor(Thing* parent) : Thing(parent, Type::TemperatureSensor) {}
|
|
|
|
void TemperatureSensor::SetTemperature(float temp) {
|
|
this->temperature = temp;
|
|
}
|
|
|
|
int TemperatureSensor::GenerateBinary(char* buffer, unsigned char* ix) {
|
|
unsigned char startIx = *ix;
|
|
// std::cout << "Send temperature: " << this->temperature << "\n";
|
|
LowLevelMessages::SendFloat16(buffer, ix, this->temperature);
|
|
return *ix - startIx;
|
|
}
|
|
|
|
void TemperatureSensor::ProcessBinary(char* bytes) {
|
|
unsigned char ix = 0;
|
|
this->temperature = LowLevelMessages::ReceiveFloat16(bytes, &ix);
|
|
}
|
|
|
|
} // namespace RoboidControl
|