Skip to content

Commit

Permalink
Update persistent storage app for P6 platform (#15113)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenCY authored and pull[bot] committed Feb 2, 2024
1 parent accbe8b commit 03f2203
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions examples/persistent-storage/p6/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,53 @@
#include "AppConfig.h"
#include "KeyValueStorageTest.h"
#include "init_p6Platform.h"
#include <FreeRTOS.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/KeyValueStoreManager.h>
#include <task.h>

using namespace chip;

int main(int argc, char * argv[])
static TaskHandle_t sTestTaskHandle;
void TestTask(void * pvParameter)
{
CHIP_ERROR err = CHIP_NO_ERROR;
init_p6Platform();
err = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init();
if (err != CHIP_NO_ERROR)
{
P6_LOG("PersistedStorage::KeyValueStoreMgrImpl().Init() failed");
return;
}
while (1)
{
P6_LOG("Running Tests:");
chip::RunKvsTest();
vTaskDelay(60000); // Run every minute
}
}

extern "C" void vApplicationDaemonTaskStartupHook()
{
// Init Chip memory management before the stack
chip::Platform::MemoryInit();

err = chip::Platform::MemoryInit();
SuccessOrExit(err);
// Run tests
xTaskCreate(TestTask, "Test", 2048, NULL, 1, &sTestTaskHandle);
}

err = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init();
SuccessOrExit(err);
int main(int argc, char * argv[])
{
init_p6Platform();

P6_LOG("=============================================\n");
P6_LOG("chip-p6-persistent-storage-example starting\n");
P6_LOG("=============================================\n");

while (1)
{
P6_LOG("Running Tests:\n");
chip::RunKvsTest();
cyhal_system_delay_ms(60000); // Run every minute
}
P6_LOG("Starting FreeRTOS scheduler");

exit:
if (err != CHIP_NO_ERROR)
{
return 1;
}
return 0;
vTaskStartScheduler();

// Should never get here.
P6_LOG("vTaskStartScheduler() failed");
return -1;
}

0 comments on commit 03f2203

Please sign in to comment.