Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
someip_sd_client.h
1#ifndef SOMEIP_SD_CLIENT
2#define SOMEIP_SD_CLIENT
3
4#include "../../../core/optional.h"
5#include "../../helper/ipv4_address.h"
6#include "../../helper/ttl_timer.h"
7#include "../../entry/service_entry.h"
8#include "./fsm/service_notseen_state.h"
9#include "./fsm/service_seen_state.h"
10#include "./fsm/client_initial_wait_state.h"
11#include "./fsm/client_repetition_state.h"
12#include "./fsm/service_ready_state.h"
13#include "./fsm/stopped_state.h"
14#include "./someip_sd_agent.h"
15
16namespace ara
17{
18 namespace com
19 {
20 namespace someip
21 {
22 namespace sd
23 {
25 class SomeIpSdClient : public SomeIpSdAgent<helper::SdClientState>
26 {
27 private:
28 helper::TtlTimer mTtlTimer;
29 bool mValidState;
30 std::mutex mOfferingMutex;
31 std::unique_lock<std::mutex> mOfferingLock;
32 std::condition_variable mOfferingConditionVariable;
33 std::mutex mStopOfferingMutex;
34 std::unique_lock<std::mutex> mStopOfferingLock;
35 std::condition_variable mStopOfferingConditionVariable;
36 fsm::ServiceNotseenState mServiceNotseenState;
37 fsm::ServiceSeenState mServiceSeenState;
38 fsm::ClientInitialWaitState mInitialWaitState;
39 fsm::ClientRepetitionState mRepetitionState;
40 fsm::StoppedState mStoppedState;
41 fsm::ServiceReadyState mServiceReadyState;
42 SomeIpSdMessage mFindServieMessage;
43 const uint16_t mServiceId;
44 std::mutex mEndpointMutex;
45 std::unique_lock<std::mutex> mEndpointLock;
46 core::Optional<std::string> mOfferedIpAddress;
47 core::Optional<uint16_t> mOfferedPort;
48
49 void sendFind();
50 bool matchRequestedService(
51 const SomeIpSdMessage &message, uint32_t &ttl) const;
52 bool tryExtractOfferedEndpoint(
53 const SomeIpSdMessage &message,
54 std::string &ipAddress, uint16_t &port) const;
55 void onOfferChanged(uint32_t ttl);
56 void receiveSdMessage(SomeIpSdMessage &&message);
57
58 protected:
59 void StartAgent(helper::SdClientState state) override;
60 void StopAgent() override;
61
62 public:
63 SomeIpSdClient() = delete;
64
74 uint16_t serviceId,
75 int initialDelayMin,
76 int initialDelayMax,
77 int repetitionBaseDelay = 30,
78 uint32_t repetitionMax = 3);
79
84 bool TryWaitUntiServiceOffered(int duration);
85
90 bool TryWaitUntiServiceOfferStopped(int duration);
91
99 std::string &ipAddress, uint16_t &port);
100
101 ~SomeIpSdClient() override;
102 };
103 }
104 }
105 }
106}
107
108#endif
Time To Live countdown timer.
Definition: ttl_timer.h:17
SOME/IP service discovery agent (i.e., a server or a client)
Definition: someip_sd_agent.h:21
SOME/IP service discovery client.
Definition: someip_sd_client.h:26
void StopAgent() override
Stop the service discovery agent.
Definition: someip_sd_client.cpp:174
bool TryWaitUntiServiceOfferStopped(int duration)
Try to wait unitl the server stops offering the service.
Definition: someip_sd_client.cpp:226
void StartAgent(helper::SdClientState state) override
Start the service discovery agent.
Definition: someip_sd_client.cpp:159
bool TryWaitUntiServiceOffered(int duration)
Try to wait unitl the server offers the service.
Definition: someip_sd_client.cpp:188
bool TryGetOfferedEndpoint(std::string &ipAddress, uint16_t &port)
Try to the offered unicast endpoint from the SD server.
Definition: someip_sd_client.cpp:266
SOME/IP service discovery message.
Definition: someip_sd_message.h:18
Client's service initial wait state.
Definition: client_initial_wait_state.h:19
Client's service repetition state.
Definition: client_repetition_state.h:19
Client's service state when the service is not seen.
Definition: service_notseen_state.h:20
Client's state when the service is requested and also up.
Definition: service_ready_state.h:19
Client's state when the service is seen (up) but not requested.
Definition: service_seen_state.h:19
Client state when the service is stopped.
Definition: stopped_state.h:19
A wrapper around a possible value.
Definition: optional.h:16
SdClientState
Service discovery client machine state.
Definition: machine_state.h:24