diff --git a/Participant.cpp b/Participant.cpp index 433b240..0dc3bc6 100644 --- a/Participant.cpp +++ b/Participant.cpp @@ -106,9 +106,9 @@ void Participant::SendThingInfo(Thing *thing) { } void Passer::Control::Participant::PublishThingInfo(Thing *thing) { - std::cout << "Publish thing info\n"; - // Strange, when publishing, the network id is irrelevant, because it is - // connected to a specific site... + // std::cout << "Publish thing info" << thing->networkId << "\n"; + // Strange, when publishing, the network id is irrelevant, because it is + // connected to a specific site... ThingMsg *thingMsg = new ThingMsg(this->networkId, thing); this->Publish(thingMsg); delete thingMsg; diff --git a/Sensors/TemperatureSensor.cpp b/Sensors/TemperatureSensor.cpp new file mode 100644 index 0000000..8e0034a --- /dev/null +++ b/Sensors/TemperatureSensor.cpp @@ -0,0 +1,18 @@ +#include "TemperatureSensor.h" + +#include "LowLevelMessages.h" + +namespace Passer { +namespace Control { + +TemperatureSensor::TemperatureSensor() : Thing(Type::TemperatureSensor) {} + +void TemperatureSensor::SetTemperature(float temp) { this->temp = temp; } + +void TemperatureSensor::SendBytes(char *buffer, unsigned char *ix) { + std::cout << "Send temperature: " << this->temp << "\n"; + LowLevelMessages::SendFloat16(buffer, ix, this->temp); +} + +} // namespace Control +} // namespace Passer \ No newline at end of file diff --git a/Sensors/TemperatureSensor.h b/Sensors/TemperatureSensor.h new file mode 100644 index 0000000..c9c3423 --- /dev/null +++ b/Sensors/TemperatureSensor.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Thing.h" + +namespace Passer { +namespace Control { + +class TemperatureSensor : public Thing { +public: + TemperatureSensor(); + + virtual void SetTemperature(float temp); + + void SendBytes(char *buffer, unsigned char *ix) override; + +protected: + float temp = 0; +}; + +} // namespace Control +} // namespace Passer \ No newline at end of file diff --git a/Thing.cpp b/Thing.cpp index 4cc43a9..4a79cc8 100644 --- a/Thing.cpp +++ b/Thing.cpp @@ -192,7 +192,7 @@ int Thing::Add(Thing *newThing) { return thing->id; } allThings.push_back(newThing); - return allThings.size() - 1; + return allThings.size(); } void Thing::Remove(Thing *thing) {