-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathbusInterface.c
More file actions
196 lines (168 loc) · 4.34 KB
/
busInterface.c
File metadata and controls
196 lines (168 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2019 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdbool.h>
#include <stdlib.h>
#include <rbus/rbus.h>
#include "t2log_wrapper.h"
#include "busInterface.h"
#if defined(CCSP_SUPPORT_ENABLED)
#include "ccspinterface.h"
#endif
#include "rbusInterface.h"
#include "dbusInterface.h"
static bool isRbus = false ;
static bool isBusInit = false ;
bool isRbusEnabled( )
{
T2Debug("%s ++in \n", __FUNCTION__);
if(RBUS_ENABLED == rbus_checkStatus())
{
isRbus = true;
}
else
{
isRbus = false;
}
T2Debug("RBUS mode active status = %s \n", isRbus ? "true" : "false");
T2Debug("%s --out \n", __FUNCTION__);
return isRbus;
}
static bool busInit( )
{
T2Debug("%s ++in \n", __FUNCTION__);
if(!isBusInit)
{
if (isRbusEnabled())
{
T2Debug("%s --RBUS mode is active \n", __FUNCTION__); //CID 158206:Unchecked return value
}
isBusInit = true;
if (dBusInterface_Init() == T2ERROR_SUCCESS)
{
T2Debug("%s --DBUS mode is active \n", __FUNCTION__); //CID 158206:Unchecked return value
}
else
{
T2Error("%s --DBUS init failed \n", __FUNCTION__);
}
}
T2Debug("%s --out \n", __FUNCTION__);
return isBusInit;
}
T2ERROR getParameterValue(const char* paramName, char **paramValue)
{
T2Debug("%s ++in \n", __FUNCTION__);
T2ERROR ret = T2ERROR_FAILURE ;
if(!isBusInit)
{
busInit();
}
if(isRbus)
{
ret = getRbusParameterVal(paramName, paramValue);
}
#if defined(CCSP_SUPPORT_ENABLED)
else
{
ret = getCCSPParamVal(paramName, paramValue);
}
#endif
T2Debug("%s --out \n", __FUNCTION__);
return ret;
}
Vector* getProfileParameterValues(Vector *paramList, int count)
{
T2Debug("%s ++in\n", __FUNCTION__);
Vector *profileValueList = NULL;
if(!isBusInit)
{
busInit();
}
if(isRbus)
{
profileValueList = getRbusProfileParamValues(paramList, count);
}
#if defined(CCSP_SUPPORT_ENABLED)
else
{
profileValueList = getCCSPProfileParamValues(paramList, count);
}
#endif
T2Debug("%s --Out\n", __FUNCTION__);
return profileValueList;
}
T2ERROR publishDBUSEventsProfileUpdates()
{
T2Debug("%s ++in\n", __FUNCTION__);
T2ERROR ret = T2ERROR_FAILURE ;
T2Info("Publishing dbus event for t2profile update notification to components \n");
ret = publishdbusEventsProfileUpdates();
T2Debug("%s --out\n", __FUNCTION__);
return ret;
}
T2ERROR registerGetMarkerListCallback(T2EventMarkerListCallback callback)
{
T2Debug("%s ++in\n", __FUNCTION__);
T2ERROR ret = T2ERROR_FAILURE ;
ret = registerDbusHandlerGetMarkerListCallback(callback);
T2Debug("%s --out\n", __FUNCTION__);
return ret;
}
/**
* Register with right bus call back dpending on dbus/rbus mode
*/
T2ERROR registerForTelemetryEvents(TelemetryEventCallback eventCB)
{
T2ERROR ret = T2ERROR_FAILURE;
T2Debug("%s ++in\n", __FUNCTION__);
if(!isBusInit)
{
busInit();
}
ret = registerDbusT2EventListener(eventCB);
if (isRbus)
{
// ret = registerRbusT2EventListener(eventCB);
T2Info("RBUS repeaceled with dbus\n");
#ifdef DCMAGENT
/* Register DCM Events */
ret = registerRbusDCMEventListener();
#endif
}
#if defined(CCSP_SUPPORT_ENABLED)
else
{
ret = registerCcspT2EventListener(eventCB);
}
#endif
T2Debug("%s --out\n", __FUNCTION__);
return ret;
}
T2ERROR unregisterForTelemetryEvents()
{
return T2ERROR_SUCCESS;
}
T2ERROR busUninit()
{
if (isRbus)
{
unregisterRbusT2EventListener();
}
return T2ERROR_SUCCESS;
}