Переглянути джерело

Expose method to generate compact ID

Christopher Mullins 6 роки тому
батько
коміт
fea8148775

+ 1 - 1
lib/MiLightState/GroupStatePersistence.cpp

@@ -35,6 +35,6 @@ void GroupStatePersistence::clear(const BulbId &id) {
 }
 
 char* GroupStatePersistence::buildFilename(const BulbId &id, char *buffer) {
-  uint32_t compactId = (id.deviceId << 24) | (id.deviceType << 8) | id.groupId;
+  uint32_t compactId = id.getCompactId();
   return buffer + sprintf(buffer, "%s%x", FILE_PREFIX, compactId);
 }

+ 5 - 0
lib/Types/BulbId.cpp

@@ -34,3 +34,8 @@ bool BulbId::operator==(const BulbId &other) {
     && groupId == other.groupId
     && deviceType == other.deviceType;
 }
+
+uint32_t BulbId::getCompactId() const {
+  uint32_t id = (deviceId << 24) | (deviceType << 8) | groupId;
+  return id;
+}

+ 1 - 0
lib/Types/BulbId.h

@@ -13,4 +13,5 @@ struct BulbId {
   BulbId(const uint16_t deviceId, const uint8_t groupId, const MiLightRemoteType deviceType);
   bool operator==(const BulbId& other);
   void operator=(const BulbId& other);
+  uint32_t getCompactId() const;
 };