I would like to make a new message type called wsm_info
.
In this message type, I want to include a vehicle structure, as it follows:
struct vehicle{
int vehicle_id;
Coord vehicle_pos;
float speed;
};
In the veins example there is a function called: prepareWSM
that's declared in BaseWaveApplLayer.h
. This function is a virtual WaveShortMessage*
type.
If the wsm_info
was inherented from WaveShortMessage
I wouldn't need to write and declare a new prepareWSM
for wsm_info
, right?
So how can I make this wsm_info
message inherented of WaveShortMessage
?
I tried to write like this in the wsm_info.h
:
class wsm_info : public WaveShortMessage
Instead of, that was written previously:
class wsm_info : public ::omnetpp::cPacket
But the error that I get is the following one:
cannot initialize a variable of type wsm_info * with an rvalue of type WaveShortMessage
The full code of my msg_info is below:
cplusplus {{
#include "veins/base/utils/Coord.h"
#include "veins/modules/messages/WaveShortMessage_m.h"
}}
class noncobject Coord;
class WaveShortMessage;
struct vehicle {
int vehicle_id;
Coord vehicle_pos;
float speed;
};
message wsm_info extends WaveShortMessage {
//Version of the Wave Short Message
int wsmVersion = 0;
//Determine which security mechanism was used
int securityType = 0;
//Channel Number on which this packet was sent
int channelNumber;
//Data rate with which this packet was sent
int dataRate = 1;
//Power Level with which this packet was sent
int priority = 3;
//Unique number to identify the service
int psid = 0;
//Provider Service Context
string psc = "Service with some Data";
//Length of Wave Short Message
int wsmLength;
vehicle data;
int senderAddress = 0;
int recipientAddress = -1;
int serial = 0;
Coord senderPos;
simtime_t timestamp = 0;
}
Can anyone take a look on my code and point me where is wrong and why? Thanks!