mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
fix: give out ids up to the maximum
New ids stopped two short of the limits, at 30 shades, 14 groups and 14 rooms instead of 32, 16 and 16, while the web UI showed the full limits. The original loop ran i < MAX - 1, an off-by-one: nothing indexes by id or treats the last two ids as special. ModelSnapshot's next-id answers and SomfyShadeController's allocation now run from 1 to the maximum. Found during LOOP_QUEUE_PLAN.md's review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bee6a6d60b
commit
e4ac7a29c6
3 changed files with 17 additions and 8 deletions
|
|
@ -126,18 +126,18 @@ void writeGroup(JsonFormatter &json, const group_snapshot_t &group, shade_lookup
|
|||
uint8_t nextRoomId(const model_snapshot_t &snap) {
|
||||
uint8_t ids[SOMFY_MAX_ROOMS];
|
||||
for(uint8_t i = 0; i < snap.roomCount; i++) ids[i] = snap.rooms[i].roomId;
|
||||
return firstFreeId(ids, snap.roomCount, SOMFY_MAX_ROOMS - 2);
|
||||
return firstFreeId(ids, snap.roomCount, SOMFY_MAX_ROOMS);
|
||||
}
|
||||
uint8_t nextShadeId(const model_snapshot_t &snap) {
|
||||
uint8_t ids[SOMFY_MAX_SHADES];
|
||||
for(uint8_t i = 0; i < snap.shadeCount; i++) ids[i] = snap.shades[i].shadeId;
|
||||
const uint8_t id = firstFreeId(ids, snap.shadeCount, SOMFY_MAX_SHADES - 2);
|
||||
const uint8_t id = firstFreeId(ids, snap.shadeCount, SOMFY_MAX_SHADES);
|
||||
return id == 0 ? 255 : id;
|
||||
}
|
||||
uint8_t nextGroupId(const model_snapshot_t &snap) {
|
||||
uint8_t ids[SOMFY_MAX_GROUPS];
|
||||
for(uint8_t i = 0; i < snap.groupCount; i++) ids[i] = snap.groups[i].groupId;
|
||||
const uint8_t id = firstFreeId(ids, snap.groupCount, SOMFY_MAX_GROUPS - 2);
|
||||
const uint8_t id = firstFreeId(ids, snap.groupCount, SOMFY_MAX_GROUPS);
|
||||
return id == 0 ? 255 : id;
|
||||
}
|
||||
uint32_t nextRemoteAddress(const model_snapshot_t &snap, uint8_t id) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue