Skip to content

Commit 367cc7a

Browse files
authored
fix: work around missing protocol version in SDK 7.23.0/1 (#3)
1 parent 51c7ea0 commit 367cc7a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

app.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,19 @@ ApplicationInit(
11421142
initWs2812();
11431143
initqma6100p();
11441144

1145+
// Work around bugs in SDK 7.23.0/1 where the protocol file version is not written to NVM
1146+
// TODO: Remove in 7.23.2 where this is fixed
1147+
zpal_nvm_handle_t stack_handle = zpal_nvm_init(ZPAL_NVM_AREA_STACK);
1148+
if (stack_handle != NULL) {
1149+
size_t len = 0;
1150+
zpal_nvm_get_object_size(stack_handle, 0x0, &len);
1151+
if (len == 0) {
1152+
// The protocol file version is not written to NVM, so write it
1153+
uint32_t protocol_file_version = 0x05071701; // 7.23.1, format 5
1154+
zpal_nvm_write(stack_handle, 0x0, &protocol_file_version, sizeof(protocol_file_version));
1155+
}
1156+
}
1157+
11451158
// Try to restore the user-defined color from NVM
11461159
NabuCasaLedStorage_t ledStorage = {0};
11471160
if (
@@ -1165,7 +1178,7 @@ ApplicationInit(
11651178
set_color_buffer(white);
11661179
}
11671180

1168-
// Try to restore settings from NVM
1181+
// Try to restore configuration settings from NVM
11691182
bEnableTiltDetection = nc_config_get(NC_CFG_ENABLE_TILT_INDICATOR);
11701183

11711184
/*************************************************************************************

0 commit comments

Comments
 (0)