dji_battery_impl.hpp
1 
30 #ifndef ADVANCED_SENSING_DJI_BATTERY_IMPL_H
31 #define ADVANCED_SENSING_DJI_BATTERY_IMPL_H
32 
33 #include "dji_type.hpp"
34 #include "dji_platform.hpp"
35 #include <vector>
36 
37 namespace DJI {
38 namespace OSDK{
39 #pragma pack(1)
40 
41 typedef struct DJIWholeBatteryStateImpl {
42  uint32_t reserve :15;
43  uint32_t isFakeSingleBatteryMode:1;
44  uint32_t isSingleBatteryMode:1;
45  uint32_t batteryPowerOffWarning:1;
46  uint32_t batteryShutDownProtection:1;
47  uint32_t powerLimit:1;
48  uint32_t firstChargeNotFull:1;
49  uint32_t batteryNotReady:1;
51  uint32_t voltageNotSafety:1;
54  uint32_t batteryCommunicationError:1;
55  uint32_t batteryCellError:1;
56  uint32_t lv2LowVoltageAlarm:1;
57  uint32_t lv1LowVoltageAlarm:1;
58  uint32_t smartBatteryLanding:1;
59  uint32_t smartBatteryGoHome:1;
60  uint32_t seriousLowCapacityAlarm:1;
61  uint32_t LowCapacityAlarm:1;
63 
69 typedef struct BatteryWholeInfoImpl {
70  uint16_t remainFlyTime;
71  uint16_t goHomeNeedTime;
72  uint16_t landNeedTime;
73  uint16_t goHomeNeedCapacity;
74  uint16_t landNeedCapacity;
75  float safeFlyRadius;
78  uint8_t goHomeCountDownState;
83  uint16_t voltage;
86  uint8_t lowBatteryAlarmEnable:1;
87  uint8_t seriousLowBatteryAlarmThreshold:7;
88  uint8_t seriousLowBatteryAlarmEnable:1;
89  uint8_t batteryType:2;
90  uint8_t reserve :6;
92 
95  DJI_APP_FIRAMWARE = 0,
96  DJI_LOADER_FIRMWARE = 1,
98 
99 
100 typedef struct DJISmartBatteryStateImpl {
101  uint32_t firstLevelElectric :1;
102  uint32_t secondLevelElectric :1;
103  uint32_t firstLevelOverHeating :1;
104  uint32_t secondLevelOverHeating :1;
105  uint32_t firstLevelLowTemperature :1;
106  uint32_t secondLevelLowTemperature:1;
107  uint32_t shortCut :1;
108  uint32_t cellUnderVoltage :5;
109  uint32_t cellBreak :5;
110  uint32_t selfCheckError :3;
111  uint32_t reset :1;
112  uint32_t dischargeDuringStorage :1;
113  uint32_t electricityOver :1;
114  uint32_t pressKeyClose :1;
115  uint32_t firmwareAbnormal :1;
116  uint32_t sopWarning :1;
117  uint32_t reserved2 :1;
118  uint32_t batteryClosedReason :5;
119  uint8_t mosCONTROL :3;/*[0]CHG state;[1]DSG state;[2]ORING state*/
120  uint8_t isBatteryMosReady:1;
121  uint8_t batteryEndLife :1;
122  uint8_t batPF :1;
123  uint8_t batSOHState :2;
124  uint8_t maxCycleLimit:6;
125  uint8_t reserved3 :2;
126  uint16_t lessBattery :1;
127  uint16_t batteryCommunicationAbnormal:1;
128  uint16_t voltageDiffOverRange1 :1;
129  uint16_t voltageDiffOverRange2 :1;
130  uint16_t hasCellLowVoltages :1;
131  uint16_t hasCellBreak :1;
132  uint16_t hasDiffBatteryFirmware :1;
133  uint16_t hasSocLow :1;
134  uint16_t hasBatteryPowerSupplyAbnormal :1;
135  uint16_t cellDiffVoltageOverRange:1;
136  uint16_t isBatteryEmbed :1;
137  uint16_t heatState :2;
138  uint16_t socState :3;
139 } DJISmartBatteryStateImpl;
140 
141 typedef struct SmartBatteryDynamicInfoImpl {
142  uint8_t returnCode;
143  uint8_t batteryIndex;
144  int32_t currentVoltage;
145  int32_t currentElectric;
146  uint32_t fullCapacity;
147  uint32_t remainedCapacity;
148  int16_t batteryTemperature;
149  uint8_t cellCount;
150  uint8_t batteryCapacityPercent;
151  DJISmartBatteryStateImpl batteryState;
152  uint8_t batteryPrtocolVersion;
154  uint8_t batteryNumber;
156  uint8_t SOP;
157 } SmartBatteryDynamicInfoImpl;
158 
159 const uint8_t MaxSmartBatteryNum = 2;
160 
161 #pragma pack()
162  class Vehicle;
163  class DJIBatteryImpl {
164  public:
165  DJIBatteryImpl(Vehicle* vehicle);
166  ~DJIBatteryImpl();
167 
168  Vehicle* vehicle;
169 
170  public:
171  void setBatteryWholeInfo(const uint8_t *batteryData, const uint16_t dataLen);
172  void getBatteryWholeInfo(BatteryWholeInfoImpl& batteryWholeInfo);
173 
174  bool createBatteryInfoLock();
175  bool lockBatteryInfo();
176  bool freeBatteryInfo();
177  bool destroyBatteryInfoLock();
178 
179  private:
180  BatteryWholeInfoImpl batteryWholeInfo;
181  T_OsdkMutexHandle m_batteryLock;
182  };
183 }
184 }
185 
186 
187 #endif //ADVANCED_SENSING_DJI_BATTERY_IMPL_H
188 
189 
struct DJI::OSDK::DJIWholeBatteryStateImpl DJIWholeBatteryStateImpl
uint16_t landNeedCapacity
Definition: dji_battery_impl.hpp:74
uint16_t voltage
Definition: dji_battery_impl.hpp:83
uint8_t gohomeCountDownvalue
Definition: dji_battery_impl.hpp:82
DJIWholeBatteryStateImpl batteryState
Definition: dji_battery_impl.hpp:77
uint16_t goHomeNeedCapacity
Definition: dji_battery_impl.hpp:73
Definition: dji_battery_impl.hpp:69
uint8_t lowBatteryAlarmThreshold
Definition: dji_battery_impl.hpp:85
float capacityConsumeSpeed
Definition: dji_battery_impl.hpp:76
uint32_t verySeriousLowVoltage
Definition: dji_battery_impl.hpp:53
DJIBatteryFirmwareAbnormalImpl
Definition: dji_battery_impl.hpp:94
Definition: dji_battery_impl.hpp:41
Data type and Data Structure definitions for use throughout DJI OSDK.
float safeFlyRadius
Definition: dji_battery_impl.hpp:75
uint32_t powerLimit
Definition: dji_battery_impl.hpp:47
Definition: dji_ack.cpp:38
uint8_t batteryCapacityPercentage
Definition: dji_battery_impl.hpp:84
uint32_t voltageNotSafety
Definition: dji_battery_impl.hpp:51
uint32_t firstChargeNotFull
Definition: dji_battery_impl.hpp:48
struct DJI::OSDK::BatteryWholeInfoImpl BatteryWholeInfoImpl
uint16_t landNeedTime
Definition: dji_battery_impl.hpp:72