Set correct initial thingId
This commit is contained in:
parent
1d89b5401d
commit
3e4ed82cbe
@ -106,9 +106,9 @@ void Participant::SendThingInfo(Thing *thing) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Passer::Control::Participant::PublishThingInfo(Thing *thing) {
|
void Passer::Control::Participant::PublishThingInfo(Thing *thing) {
|
||||||
std::cout << "Publish thing info\n";
|
// std::cout << "Publish thing info" << thing->networkId << "\n";
|
||||||
// Strange, when publishing, the network id is irrelevant, because it is
|
// Strange, when publishing, the network id is irrelevant, because it is
|
||||||
// connected to a specific site...
|
// connected to a specific site...
|
||||||
ThingMsg *thingMsg = new ThingMsg(this->networkId, thing);
|
ThingMsg *thingMsg = new ThingMsg(this->networkId, thing);
|
||||||
this->Publish(thingMsg);
|
this->Publish(thingMsg);
|
||||||
delete thingMsg;
|
delete thingMsg;
|
||||||
|
18
Sensors/TemperatureSensor.cpp
Normal file
18
Sensors/TemperatureSensor.cpp
Normal 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
|
21
Sensors/TemperatureSensor.h
Normal file
21
Sensors/TemperatureSensor.h
Normal 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
|
@ -192,7 +192,7 @@ int Thing::Add(Thing *newThing) {
|
|||||||
return thing->id;
|
return thing->id;
|
||||||
}
|
}
|
||||||
allThings.push_back(newThing);
|
allThings.push_back(newThing);
|
||||||
return allThings.size() - 1;
|
return allThings.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thing::Remove(Thing *thing) {
|
void Thing::Remove(Thing *thing) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user