Set correct initial thingId

This commit is contained in:
Pascal Serrarens 2025-01-08 17:10:45 +01:00
parent 1d89b5401d
commit 3e4ed82cbe
4 changed files with 43 additions and 4 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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) {