Skip to content

Commit

Permalink
[Logs] Add NVS logs (#22662)
Browse files Browse the repository at this point in the history
  • Loading branch information
pankore authored and pull[bot] committed Oct 11, 2023
1 parent 210f0ff commit ee9f23c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/platform/Ameba/AmebaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ CHIP_ERROR AmebaConfig::WriteConfigValue(Key key, bool val)
success = setPref_new(key.Namespace, key.Name, &value, 1);
if (!success)
ChipLogError(DeviceLayer, "setPref: %s/%s = %s failed\n", key.Namespace, key.Name, value ? "true" : "false");
else
ChipLogProgress(DeviceLayer, "NVS set: %s/%s = %s", key.Namespace, key.Name, val ? "true" : "false");

return CHIP_NO_ERROR;
}
Expand All @@ -203,6 +205,8 @@ CHIP_ERROR AmebaConfig::WriteConfigValue(Key key, uint32_t val)
success = setPref_new(key.Namespace, key.Name, (uint8_t *) &val, sizeof(uint32_t));
if (!success)
ChipLogError(DeviceLayer, "setPref: %s/%s = %d(0x%x) failed\n", key.Namespace, key.Name, val, val);
else
ChipLogProgress(DeviceLayer, "NVS set: %s/%s = %" PRIu32 " (0x%" PRIX32 ")", key.Namespace, key.Name, val, val);

return CHIP_NO_ERROR;
}
Expand All @@ -214,6 +218,8 @@ CHIP_ERROR AmebaConfig::WriteConfigValue(Key key, uint64_t val)
success = setPref_new(key.Namespace, key.Name, (uint8_t *) &val, sizeof(uint64_t));
if (!success)
ChipLogError(DeviceLayer, "setPref: %s/%s = %d(0x%x) failed\n", key.Namespace, key.Name, val, val);
else
ChipLogProgress(DeviceLayer, "NVS set: %s/%s = %" PRIu64 " (0x%" PRIX64 ")", key.Namespace, key.Name, val, val);

return CHIP_NO_ERROR;
}
Expand All @@ -225,6 +231,8 @@ CHIP_ERROR AmebaConfig::WriteConfigValueStr(Key key, const char * str)
success = setPref_new(key.Namespace, key.Name, (uint8_t *) str, strlen(str) + 1);
if (!success)
ChipLogError(DeviceLayer, "setPref: %s/%s = %s failed\n", key.Namespace, key.Name, str);
else
ChipLogProgress(DeviceLayer, "NVS set: %s/%s = \"%s\"", key.Namespace, key.Name, str);
return CHIP_NO_ERROR;
}

Expand All @@ -251,6 +259,8 @@ CHIP_ERROR AmebaConfig::WriteConfigValueBin(Key key, const uint8_t * data, size_
success = setPref_new(key.Namespace, key.Name, (uint8_t *) data, dataLen);
if (!success)
ChipLogError(DeviceLayer, "setPref: %s/%s failed\n", key.Namespace, key.Name);
else
ChipLogProgress(DeviceLayer, "NVS set: %s/%s = (blob length %" PRId32 ")", key.Namespace, key.Name, dataLen);

return CHIP_NO_ERROR;
}
Expand All @@ -262,6 +272,8 @@ CHIP_ERROR AmebaConfig::ClearConfigValue(Key key)
success = deleteKey(key.Namespace, key.Name);
if (!success)
ChipLogProgress(DeviceLayer, "%s : %s/%s failed\n", __FUNCTION__, key.Namespace, key.Name);
else
ChipLogProgress(DeviceLayer, "NVS erase: %s/%s", key.Namespace, key.Name);

return CHIP_NO_ERROR;
}
Expand Down

0 comments on commit ee9f23c

Please sign in to comment.