Improve broadcast support
This commit is contained in:
parent
9de2fa6492
commit
60516dec0d
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
NetworkSync::NetworkSync(Roboid* roboid) {
|
NetworkSync::NetworkSync(Roboid* roboid) {
|
||||||
this->roboid = roboid;
|
this->roboid = roboid;
|
||||||
|
this->networkId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkSync::ReceiveMessage(Roboid* roboid, unsigned char bytecount) {
|
void NetworkSync::ReceiveMessage(Roboid* roboid, unsigned char bytecount) {
|
||||||
@ -27,7 +28,6 @@ void NetworkSync::ReceiveMessage(Roboid* roboid, unsigned char bytecount) {
|
|||||||
|
|
||||||
switch (buffer[0]) {
|
switch (buffer[0]) {
|
||||||
case NetworkIdMsg:
|
case NetworkIdMsg:
|
||||||
// this->networkId = NetworkIdMsg;
|
|
||||||
ReceiveNetworkId();
|
ReceiveNetworkId();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ void NetworkSync::ReceiveMessage(Roboid* roboid, unsigned char bytecount) {
|
|||||||
void NetworkSync::ReceiveNetworkId() {
|
void NetworkSync::ReceiveNetworkId() {
|
||||||
this->networkId = buffer[1];
|
this->networkId = buffer[1];
|
||||||
#ifdef RC_DEBUG
|
#ifdef RC_DEBUG
|
||||||
SERIALPORT.printf("_Received network Id %d\n", this->networkId);
|
SERIALPORT.printf("Received network Id %d\n", this->networkId);
|
||||||
#endif
|
#endif
|
||||||
SendName(roboid);
|
SendName(roboid);
|
||||||
SendModel(roboid);
|
SendModel(roboid);
|
||||||
@ -50,6 +50,17 @@ void NetworkSync::ReceiveNetworkId() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkSync::PublishDevice() {
|
||||||
|
unsigned char ix = 0;
|
||||||
|
buffer[ix++] = DeviceMsg;
|
||||||
|
buffer[ix++] = 0; // No network ID
|
||||||
|
PublishBuffer(ix);
|
||||||
|
|
||||||
|
#ifdef RC_DEBUG
|
||||||
|
SERIALPORT.printf("Publish Device\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkSync::PublishState(Roboid* roboid) {
|
void NetworkSync::PublishState(Roboid* roboid) {
|
||||||
SendPose(roboid);
|
SendPose(roboid);
|
||||||
PublishPerception(roboid);
|
PublishPerception(roboid);
|
||||||
@ -208,17 +219,6 @@ void NetworkSync::SendPose(Thing* thing, bool recurse) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkSync::PublishClient() {
|
|
||||||
unsigned char ix = 0;
|
|
||||||
buffer[ix++] = ClientMsg;
|
|
||||||
buffer[ix++] = 0; // No network ID
|
|
||||||
SendBuffer(ix);
|
|
||||||
|
|
||||||
#ifdef RC_DEBUG
|
|
||||||
SERIALPORT.println("Sent new Client");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkSync::PublishState(Sensor* sensor) {
|
void NetworkSync::PublishState(Sensor* sensor) {
|
||||||
float* value = (float*)sensor->GetValue();
|
float* value = (float*)sensor->GetValue();
|
||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
|
@ -14,7 +14,7 @@ class NetworkSync {
|
|||||||
NetworkSync() {};
|
NetworkSync() {};
|
||||||
NetworkSync(Roboid* roboid);
|
NetworkSync(Roboid* roboid);
|
||||||
|
|
||||||
unsigned char networkId;
|
unsigned char networkId = 0;
|
||||||
|
|
||||||
/// @brief Retreive and send the roboid state
|
/// @brief Retreive and send the roboid state
|
||||||
/// @param roboid The roboid for which the state is updated
|
/// @param roboid The roboid for which the state is updated
|
||||||
@ -54,7 +54,7 @@ class NetworkSync {
|
|||||||
static const unsigned char InvestigateMsg = 0x81;
|
static const unsigned char InvestigateMsg = 0x81;
|
||||||
static const unsigned char ModelMsg = 0x90;
|
static const unsigned char ModelMsg = 0x90;
|
||||||
static const unsigned char NameMsg = 0x91;
|
static const unsigned char NameMsg = 0x91;
|
||||||
static const unsigned char ClientMsg = 0xA0;
|
static const unsigned char DeviceMsg = 0xA0;
|
||||||
static const unsigned char NetworkIdMsg = 0xA1;
|
static const unsigned char NetworkIdMsg = 0xA1;
|
||||||
|
|
||||||
typedef void (*Buffer)(UInt8* buffer, UInt16 bufferSize);
|
typedef void (*Buffer)(UInt8* buffer, UInt16 bufferSize);
|
||||||
@ -128,7 +128,7 @@ class NetworkSync {
|
|||||||
virtual void SendBuffer(unsigned char bufferSize);
|
virtual void SendBuffer(unsigned char bufferSize);
|
||||||
virtual void PublishBuffer(unsigned char bufferSize);
|
virtual void PublishBuffer(unsigned char bufferSize);
|
||||||
|
|
||||||
void PublishClient();
|
void PublishDevice();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user