Line data Source code
1 : /********************************************************************************
2 : * Copyright (c) 2026 Accenture
3 : *
4 : * This program and the accompanying materials are made available under the
5 : * terms of the Apache License Version 2.0 which is available at
6 : * https://www.apache.org/licenses/LICENSE-2.0
7 : *
8 : * SPDX-License-Identifier: Apache-2.0
9 : ********************************************************************************/
10 :
11 : #include "someip/RebootTrackerEndpoint.h"
12 :
13 : namespace someip
14 : {
15 38 : RebootTrackerEndpoint::RebootTrackerEndpoint()
16 38 : : _latestUnicastSessionId(0U)
17 38 : , _latestMulticastSessionId(0U)
18 38 : , _latestUnicastRebootFlag(false)
19 38 : , _latestMulticastRebootFlag(false)
20 38 : {}
21 :
22 58 : void RebootTrackerEndpoint::setUnicast(uint16_t const sessionId, bool const rebootFlag)
23 : {
24 58 : _latestUnicastSessionId = sessionId;
25 58 : _latestUnicastRebootFlag = rebootFlag;
26 58 : }
27 :
28 4 : void RebootTrackerEndpoint::setMulticast(uint16_t const sessionId, bool const rebootFlag)
29 : {
30 4 : _latestMulticastSessionId = sessionId;
31 4 : _latestMulticastRebootFlag = rebootFlag;
32 4 : }
33 :
34 6 : bool RebootTrackerEndpoint::getMulticastRebootValue(
35 : uint16_t const sessionId, bool const rebootFlag) const
36 : {
37 6 : if (rebootFlag == false)
38 : {
39 1 : return false;
40 : }
41 5 : if (_latestMulticastRebootFlag == false)
42 : {
43 1 : return true;
44 : }
45 :
46 4 : return _latestMulticastSessionId >= sessionId;
47 : }
48 :
49 86 : bool RebootTrackerEndpoint::getUnicastRebootValue(
50 : uint16_t const sessionId, bool const rebootFlag) const
51 : {
52 86 : if (rebootFlag == false)
53 : {
54 2 : return false;
55 : }
56 84 : if (_latestUnicastRebootFlag == false)
57 : {
58 1 : return true;
59 : }
60 :
61 83 : return _latestUnicastSessionId >= sessionId;
62 : }
63 :
64 38 : void RebootTrackerEndpoint::initActiveReboot()
65 : {
66 38 : _latestUnicastSessionId = 0U;
67 38 : _latestMulticastSessionId = 0U;
68 38 : _latestUnicastRebootFlag = true; // true to avoid detection of reboot on startup
69 38 : _latestMulticastRebootFlag = true; // true to avoid detection of reboot on startup
70 38 : }
71 :
72 : } // namespace someip
|