• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BATTERY_MANAGE_FEATURE_H
17 #define BATTERY_MANAGE_FEATURE_H
18 
19 #include "feature.h"
20 #include "message.h"
21 #include "service.h"
22 #include "ibattery.h"
23 #include "battery_info.h"
24 #include "battery_mgr.h"
25 #include "battery_interface.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif // __cplusplus
30 
31 static IBattery *g_batteryDevice = NULL;
32 
33 typedef struct {
34     INHERIT_FEATURE;
35     INHERIT_IUNKNOWNENTRY(BatteryInterface);
36     Identity identity_;
37 } BatteryFeatureApi;
38 
39 
40 const char *GetFeatureName(Feature *feature);
41 void OnFeatureStop(Feature *feature, Identity identity);
42 BOOL OnFeatureMessage(Feature *feature, Request *request);
43 void OnFeatureInitialize(Feature *feature, Service *parent, Identity identity);
44 
45 int32_t BatterySocImpl(IUnknown *iUnknown);
46 BatteryChargeState ChargingStatusImpl(IUnknown *iUnknown);
47 BatteryHealthState HealthStatusImpl(IUnknown *iUnknown);
48 BatteryPluggedType PluggedTypeImpl(IUnknown *iUnknown);
49 int32_t VoltageImpl(IUnknown *iUnknown);
50 char* TechnologyImpl(IUnknown *iUnknown);
51 
52 int32_t BatteryTemperatureImpl(IUnknown *iUnknown);
53 
54 #define BATTERY_FEATURE_INTERFACE_IMPL                              \
55     .GetName = GetFeatureName,                                      \
56     .OnInitialize = OnFeatureInitialize,                            \
57     .OnStop = OnFeatureStop,                                        \
58     .OnMessage = OnFeatureMessage
59 
60 #define BATTERY_INTERFACE_IMPL                                      \
61     .GetBatSocFunc = BatterySocImpl,                                \
62     .GetChargingStatusFunc = ChargingStatusImpl,                    \
63     .GetHealthStatusFunc = HealthStatusImpl,                        \
64     .GetPluggedTypeFunc = PluggedTypeImpl,                          \
65     .GetBatVoltageFunc = VoltageImpl,                               \
66     .GetBatTechnologyFunc = TechnologyImpl,                         \
67     .GetBatTemperatureFunc = BatteryTemperatureImpl
68 
69 BatteryFeatureApi *GetBatteryFeatureImpl(void);
70 
71 #ifdef __cplusplus
72 }
73 #endif // __cplusplus
74 #endif // BATTERY_MANAGE_FEATURE_H