UeWarningAlertApp.h Source File

Simu5G: UeWarningAlertApp.h Source File
Simu5G
UeWarningAlertApp.h
1//
2// Simu5G
3//
4// Copyright (C) 2019-2021 Giovanni Nardini, Giovanni Stea, Antonio Virdis et al. (University of Pisa)
5// Copyright (C) 2022-2026 Giovanni Nardini, Giovanni Stea et al. (University of Pisa)
6//
7// This file is part of a software released under the license included in file
8// "license.pdf". Please read LICENSE and README files before using it.
9// The above files and the present reference are part of the software itself,
10// and cannot be removed from it.
11//
12
13#ifndef __UEWARNINGALERTAPP_H_
14#define __UEWARNINGALERTAPP_H_
15
16#include <inet/common/ModuleRefByPar.h>
17#include <inet/common/geometry/common/Coord.h>
18#include <inet/common/geometry/common/EulerAngles.h>
19#include <inet/mobility/contract/IMobility.h>
20#include <inet/networklayer/common/L3Address.h>
21#include <inet/networklayer/common/L3AddressResolver.h>
22#include <inet/transportlayer/contract/udp/UdpSocket.h>
23
24#include "simu5g/apps/mec/WarningAlert/packets/WarningAlertPacket_m.h"
25#include "simu5g/common/binder/Binder.h"
26#include "simu5g/mec/platform/MeAppPacket_Types.h"
27
28namespace simu5g {
29
30using namespace omnetpp;
31
45
46class UeWarningAlertApp : public cSimpleModule, public inet::UdpSocket::ICallback
47{
48
49 //communication to device app and mec app
50 inet::UdpSocket socket;
51
52 int size_;
53 simtime_t period_;
54 int localPort_;
55 int deviceAppPort_;
56 inet::L3Address deviceAppAddress_;
57
58 // MEC application endPoint (returned by the device app)
59 inet::L3Address mecAppAddress_;
60 int mecAppPort_;
61
62 std::string mecAppName;
63
64 // mobility information
65 opp_component_ptr<cModule> ue;
66 inet::ModuleRefByPar<inet::IMobility> mobility;
67 inet::Coord position;
68
69 //scheduling
70 enum MsgKind {
71 KIND_SELF_START = 1000,
72 KIND_SELF_STOP,
73 KIND_SELF_MEC_APP_START,
74 };
75
76 cMessage *selfStart_ = nullptr;
77 cMessage *selfStop_ = nullptr;
78
79 cMessage *selfMecAppStart_ = nullptr;
80
81 // used to write in a log file
82 bool log;
83
84 public:
85 ~UeWarningAlertApp() override;
86
87 protected:
88
89 int numInitStages() const override { return inet::NUM_INIT_STAGES; }
90 void initialize(int stage) override;
91 void handleMessage(cMessage *msg) override;
92
93 void sendStartMEWarningAlertApp();
94 void sendMessageToMecApp();
95 void sendStopMEWarningAlertApp();
96
97 void handleAckStartMEWarningAlertApp(inet::Packet *packet);
98 void handleInfoMEWarningAlertApp(inet::Packet *packet);
99 void handleAckStopMEWarningAlertApp(inet::Packet *packet);
100
101 // UdpSocket::ICallback methods
102 void socketDataArrived(inet::UdpSocket *socket, inet::Packet *packet) override;
103 void socketErrorArrived(inet::UdpSocket *socket, inet::Indication *indication) override;
104 void socketClosed(inet::UdpSocket *socket) override;
105};
106
107} //namespace
108
109#endif
110
Definition UeWarningAlertApp.h:47
Definition AlertReceiver.h:24