Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions config_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,40 @@ bool parseConfigBytes(uint8_t* configData, uint32_t configLen, struct GlobalConf
}
break;

// Packet types nRF does not functionally use. Skip past them by their
// correct on-wire size so subsequent packets are still parsed, instead
// of aborting the whole config on the first one seen.
case CONFIG_PKT_TOUCH: // touch_controller (0x28), 32 bytes
case CONFIG_PKT_BUZZER: // passive_buzzer (0x29), 32 bytes
case CONFIG_PKT_NFC: // nfc_config (0x2A), 32 bytes
case CONFIG_PKT_FLASH: // flash_config (0x2B), 32 bytes
if (offset > configLen) {
NRF_LOG_ERROR("Offset overflow before pkt 0x%02X", packetId);
globalConfig->loaded = false;
return false;
}
if (offset + 32 <= configLen - 2) {
NRF_LOG_DEBUG("Skipping unused pkt 0x%02X (32 bytes)", packetId);
offset += 32;
} else {
offset = configLen - 2; // Skip to CRC
}
break;

case CONFIG_PKT_DATA_EXTENDED: // data_extended (0x2C), 288 bytes
if (offset > configLen) {
NRF_LOG_ERROR("Offset overflow before data_extended");
globalConfig->loaded = false;
return false;
}
if (offset + 288 <= configLen - 2) {
NRF_LOG_DEBUG("Skipping unused pkt 0x2C (288 bytes)");
offset += 288;
} else {
offset = configLen - 2; // Skip to CRC
}
break;

default:
NRF_LOG_WARNING("Unknown pkt 0x%02X @%d", packetId, offset - 2);
offset = configLen - 2; // Skip to CRC
Expand Down
5 changes: 5 additions & 0 deletions constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
#define CONFIG_PKT_BINARY_INPUT 0x25
#define CONFIG_PKT_WIFI 0x26
#define CONFIG_PKT_SECURITY 0x27
#define CONFIG_PKT_TOUCH 0x28
#define CONFIG_PKT_BUZZER 0x29
#define CONFIG_PKT_NFC 0x2A
#define CONFIG_PKT_FLASH 0x2B
#define CONFIG_PKT_DATA_EXTENDED 0x2C

#define GPIO_PIN_UNUSED 0xFF

Expand Down