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_DEVICE_H 17 #define BATTERY_DEVICE_H 18 19 #include "ohos_init.h" 20 #include "samgr_lite.h" 21 #include "service.h" 22 #include "feature.h" 23 #include <iproxy_server.h> 24 #include <iunknown.h> 25 #include <pthread.h> 26 #include <log.h> 27 #include "ibattery.h" 28 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif // __cplusplus 33 34 #define BATTERY_DEVICE "battery_device" 35 #define BATTERY_FEATURE "battery_feature" 36 37 #define BATTERY_ERROR_UNKNOWN (-1) 38 #define BATTERY_ERROR_INVALID_ID (-2) 39 #define BATTERY_ERROR_INVALID_PARAM (-3) 40 #define BATTERY_OK 0 41 42 #define TASK_CONFIG_STACK_SIZE 0x800 43 #define TASK_CONFIG_QUEUE_SIZE 20 44 45 46 typedef struct BatteeryDeviceFeatureApi { 47 INHERIT_SERVER_IPROXY; 48 int32_t (*GetSoc)(void); 49 BatteryChargeState (*GetChargingStatus)(void); 50 BatteryHealthState (*GetHealthStatus)(void); 51 BatteryPluggedType (*GetPluggedType)(void); 52 int32_t (*GetVoltage)(void); 53 char* (*GetTechnology)(void); 54 int32_t (*GetTemperature)(void); 55 int (*TurnOnLed)(int red, int green, int blue); 56 int (*TurnOffLed)(void); 57 int (*SetLedColor)(int red, int green, int blue); 58 int (*GetLedColor)(int *red, int *green, int *blue); 59 void (*ShutDown)(void); 60 void (*UpdateBatInfo)(BatInfo*); 61 } BatteeryDeviceFeatureApi; 62 63 typedef struct BatteryDevice { 64 INHERIT_SERVICE; 65 INHERIT_IUNKNOWNENTRY(BatteeryDeviceFeatureApi); 66 Identity identity; 67 } BatteryDevice; 68 69 #ifdef __cplusplus 70 } 71 #endif // __cplusplus 72 #endif // BATTERY_SRV_CLIENT_H