Merge pull request #9463 from pcdiem/dgr1

Add device group count/index checks
This commit is contained in:
Theo Arends 2020-10-04 17:40:26 +02:00 committed by GitHub
commit d689b74b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,6 +119,7 @@ void DeviceGroupsInit(void)
for (uint32_t relay_index = 0; relay_index < MAX_RELAYS; relay_index++) {
if (PinUsed(GPIO_REL1, relay_index)) device_group_count = relay_index + 1;
}
if (device_group_count > MAX_DEV_GROUP_NAMES) device_group_count = MAX_DEV_GROUP_NAMES;
}
// Otherwise, set the device group count to 1.
@ -464,6 +465,9 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
// If device groups is not up, ignore this request.
if (!device_groups_up) return 1;
// If the device group index is higher then the number of device groups, ignore this request.
if (device_group_index >= device_group_count) return 0;
// If we're currently processing a remote device message, ignore this request.
if (ignore_dgr_sends && message_type != DGR_MSGTYPE_UPDATE_COMMAND) return 0;