0

I use OMNeT++-5.3 and Veins-4.7.1. this is how I implement my code to send a message in counter mode (I do the same with flooding)

    void Counter::sendMessage(std::string blockedRoadId)
{
    t_channel channel = dataOnSch ? type_SCH : type_CCH;
    WaveShortMessage* wsm = prepareWSM("data", dataLengthBits, channel, dataPriority, -1,2);
    wsm->setWsmData(blockedRoadId.c_str());
    sendWSM(wsm);

    sentMessage = true;
}
void Counter::handleSelfMsg(cMessage *msg)
{
 // for "data" and "beacon" self messages
 if ((!strcmp(msg->getName(), "data")) || (!strcmp(msg->getName(), "beacon"))) {
 BaseWaveApplLayer::handleSelfMsg(msg);
 return;
 }
 else { // for "rebroadcast" self messages
 // if the number of times a warning message is received exceeds the counterThreshold
 // configuration variable, do not rebroadcast.
 if (receivedMessages[atol(msg->getName())].size() >= (unsigned)counterThreshold)
 return;
 // if greater than threshold.. rebroadcast.
 sendWSM(receivedMessages[atol(msg->getName())][0]->dup());
 }
}

these are the errors I find:

'dataPriority’ was not declared in this scope

‘sendWSM’ was not declared in this scope

could you help me?

this is the code Counter.h

typedef std::vector<WaveShortMessage*> WaveShortMessages;
class Counter : public BaseWaveApplLayer
{
    public:
        virtual void initialize(int stage);
        virtual void receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj);
    protected:
        TraCIMobility* traci;
        vector<WaveShortMessage*> warningMessages;
        map<long,WaveShortMessages> receivedMessages; // treeId, WSM vector
    protected:
        virtual void onBeacon(WaveShortMessage *wsm);
        virtual void onData(WaveShortMessage *wsm);
        virtual void handlePositionUpdate(cObject *obj);
        virtual void sendMessage(std::string blockedRoadId);
        virtual void handleSelfMsg(cMessage *msg)
  • Can you post the complete Counter.h file here as well? – thardes2 Mar 13 '19 at 13:27
  • the error is in counter.cc – user11196797 Mar 13 '19 at 13:45
  • Does `Counter` inherit from `BaseWaveApplLayer`? Could you edit your question and add `Counter.h` as well as `Counter.ned`? – Jerzy D. Mar 13 '19 at 14:04
  • and in Counter.ned i have: inline `import org.car2x.veins.modules.application.ieee80211p.BaseWaveApplLayer; import org.car2x.veins.modules.application.ieee80211p.BaseWaveApplLayer; simple Counter extends BaseWaveApplLayer` – user11196797 Mar 13 '19 at 14:20
  • It is impossible to answer this question without seeing your code in full. The error message you posted complained about you using symbols that you did not declare. Yes, the parts of your code that you are showing here do, indeed, not declare these symbols. Do you try to declare them somewhere else? Maybe. All that can be said for sure is that the code you are revealing to us does not declare them. Which is exactly what the compiler says. – Christoph Sommer Mar 13 '19 at 17:22
  • I am new to stackoverflow and sorry for not enough information. How and where could I declare them? – user11196797 Mar 13 '19 at 17:50
  • Are you asking how to declare a class method in C++? – Christoph Sommer Mar 14 '19 at 16:48
  • no, I thought they were defined in BaseWaveApplLayer that I didn't implement but it is in the veins 4.7.1, sendWSM and prepareWSM are defined by default for previous veins versions. My question is: do I have to implement sendWSM and prepareWSM, or are there some functions that do the same job? – user11196797 Mar 14 '19 at 18:01

0 Answers0