dji_battery.hpp
1 
30 #ifndef ADVANCED_SENSING_DJI_BATTERY_H
31 #define ADVANCED_SENSING_DJI_BATTERY_H
32 
33 #include "dji_type.hpp"
34 namespace DJI
35 {
36 namespace OSDK
37 {
38 
39 #pragma pack(1)
40 
41 typedef struct DJIWholeBatteryState {
42  uint32_t reserve1 :15;
43  uint32_t isFakeSingleBatteryMode:1;
44  uint32_t isSingleBatteryMode:1;
45  uint32_t reserve2:4;
46  uint32_t batteryNotReady:1;
48  uint32_t voltageNotSafety:1;
50  uint32_t reserve3:3;
51  uint32_t veryLowVoltageAlarm:1;
52  uint32_t LowVoltageAlarm:1;
53  uint32_t reserve4:2;
54  uint32_t seriousLowCapacityAlarm:1;
55  uint32_t LowCapacityAlarm:1;
57 
63 typedef struct BatteryWholeInfo {
64  uint16_t remainFlyTime;
65  uint16_t goHomeNeedTime;
66  uint16_t landNeedTime;
67  uint16_t goHomeNeedCapacity;
68  uint16_t landNeedCapacity;
69  float safeFlyRadius;
72  uint8_t goHomeCountDownState;
77  uint16_t voltage;
80  uint8_t lowBatteryAlarmEnable :1;
81  uint8_t seriousLowBatteryAlarmThreshold:7;
82  uint8_t seriousLowBatteryAlarmEnable :1;
83  uint8_t reserve;
85 
86 
89  DJI_BATTERY_SELF_CHECK_NORAML = 0,
90  DJI_BATTERY_SELF_CHECK_NTC_ABNORAML = 1,
91  DJI_BATTERY_SELF_CHECK_MOS_ABNROMAL = 2,
92  DJI_BATTERY_SELF_CHECK_R_ABNORMAL = 3,
93  DJI_BATTERY_SELF_CHECK_CELL_DAMAGE = 4,
94  DJI_BATTERY_SELF_CHECK_CAL_EXP = 5,
95  DJI_BATTERY_SELF_CHECK_GAUGEPARM_EXP = 6,
96  DJI_BATTERY_SELF_CHECK_RES = 7,
98 
101  DJI_BETTERY_CLOSED_NORMAL = 0,
102  DJI_BETTERY_CLOSED_FORCED = 1,
103  DJI_BETTERY_CLOSED_SCD = 2,
115 
117 typedef enum {
118  DJI_SOH_NORMAL = 0,
119  DJI_SOH_ALERT = 1,
120  DJI_SOH_SAFE = 2,
121  DJI_SOH_RESERVE = 3,
123 
126  DJI_NO_HEAT = 0,
127  DJI_IN_HEAT = 1,
128  DJI_KEEP_WARM = 2,
130 
133  DJI_SOC_NORMAL = 0,
134  DJI_SOC_ABNORMAL_HIGH = 1,
135  DJI_SOC_JUMP_DOWN = 2,
136  DJI_SOC_JUMP_UP = 3,
137  DJI_SOC_INVALID = 4,
138  DJI_reserved1 = 5,
139  DJI_reserved2 = 6,
140  DJI_reserved3 = 7,
142 
143 typedef struct DJISmartBatteryState {
144  uint32_t reserved :12;
145  uint32_t cellBreak :5;
146  uint32_t selfCheckError :3;
147  uint32_t reserved1 :7;
148  uint32_t batteryClosedReason :5;
149  uint8_t reserved2 :6;/*[0]CHG state;[1]DSG state;[2]ORING state*/
150  uint8_t batSOHState :2;
151  uint8_t maxCycleLimit:6;
152  uint8_t reserved3 :2;
153  uint16_t lessBattery :1;
154  uint16_t batteryCommunicationAbnormal:1;
155  uint16_t reserved4 :3;
156  uint16_t hasCellBreak :1;
157  uint16_t reserved5 :4;
158  uint16_t isBatteryEmbed :1;
159  uint16_t heatState :2;
160  uint16_t socState :3;
161 } DJISmartBatteryState;
162 
163 typedef struct SmartBatteryDynamicInfo {
164  uint8_t reserve;
165  uint8_t batteryIndex;
166  int32_t currentVoltage;
167  int32_t currentElectric;
168  uint32_t fullCapacity;
169  uint32_t remainedCapacity;
170  int16_t batteryTemperature;
171  uint8_t cellCount;
172  uint8_t batteryCapacityPercent;
173  DJISmartBatteryState batteryState;
174  uint8_t reserve1;
175  uint8_t reserve2;
176  uint8_t SOP;
177 } SmartBatteryDynamicInfo;
178 
179 #pragma pack()
180 
181 class Vehicle;
182 class DJIBatteryImpl;
183 
184 class DJIBattery
185 {
186 public:
187  enum class RequestSmartBatteryIndex
188  {
189  FIRST_SMART_BATTERY = 1,
190  SECOND_SMART_BATTERY = 2,
191  };
192 
193 public:
194  DJIBattery(Vehicle *vehicle = 0);
195  ~DJIBattery();
196 
197  Vehicle* vehicle;
198  DJIBatteryImpl* djiBatteryImpl;
199 
200 public:
215  bool subscribeBatteryWholeInfo(bool enable);
216 
223  bool getBatteryWholeInfo(BatteryWholeInfo& batteryWholeInfo);
224 
235  bool getSingleBatteryDynamicInfo(const DJIBattery::RequestSmartBatteryIndex batteryIndex, SmartBatteryDynamicInfo& batteryDynamicInfo);
236 };
237 
238 }
239 }
240 #endif //ADVANCED_SENSING_DJI_BATTERY_H
DJISmartBatteryHeatState
Definition: dji_battery.hpp:125
Definition: dji_battery.hpp:109
struct DJI::OSDK::BatteryWholeInfo BatteryWholeInfo
DJIBatteryClosedReasonImpl
Definition: dji_battery.hpp:100
DJISmartBatterySohState
Definition: dji_battery.hpp:117
float safeFlyRadius
Definition: dji_battery.hpp:69
DJIWholeBatteryState batteryState
Definition: dji_battery.hpp:71
DJISmartBatterySocWarning
Definition: dji_battery.hpp:132
uint8_t lowBatteryAlarmThreshold
Definition: dji_battery.hpp:79
DJISmartBatterySelfCheck
Definition: dji_battery.hpp:88
Definition: dji_battery.hpp:112
Definition: dji_battery.hpp:106
Definition: dji_battery.hpp:104
Definition: dji_battery.hpp:113
Definition: dji_battery.hpp:107
Definition: dji_battery.hpp:110
Definition: dji_battery.hpp:41
Definition: dji_battery.hpp:108
Data type and Data Structure definitions for use throughout DJI OSDK.
Definition: dji_battery.hpp:63
uint16_t landNeedTime
Definition: dji_battery.hpp:66
uint16_t landNeedCapacity
Definition: dji_battery.hpp:68
uint16_t goHomeNeedCapacity
Definition: dji_battery.hpp:67
Definition: dji_ack.cpp:38
struct DJI::OSDK::DJIWholeBatteryState DJIWholeBatteryState
uint8_t gohomeCountDownvalue
Definition: dji_battery.hpp:76
Definition: dji_battery.hpp:111
uint32_t voltageNotSafety
Definition: dji_battery.hpp:48
Definition: dji_battery.hpp:105
uint16_t voltage
Definition: dji_battery.hpp:77
uint32_t reserve3
Definition: dji_battery.hpp:50
float capacityConsumeSpeed
Definition: dji_battery.hpp:70
uint8_t batteryCapacityPercentage
Definition: dji_battery.hpp:78