Beispiel #1
0
void TestSettingsDelete(void)
{
    uint8_t key = 8;
    uint8_t readBuffer[kMaxStageDataLen];
    uint16_t readBufferLength;

    VerifyOrQuit(otPlatSettingsAdd(&sInstance, key, sWriteBuffer, sWriteBufferLength) == kThreadError_None,
                 "Settings::Delete::Add Fail\n");
    VerifyOrQuit(otPlatSettingsGet(&sInstance, key, 0, readBuffer, &readBufferLength) == kThreadError_None,
                 "Settings::Delete::Get Fail\n");
    VerifyOrQuit(!memcmp(readBuffer, sWriteBuffer, static_cast<uint16_t>(sWriteBufferLength)),
                 "Settings::Delete::Add Check Fail\n");
    VerifyOrQuit(otPlatSettingsDelete(&sInstance, key, -1) == kThreadError_None, "Settings::Delete::Delete Fail\n");
    VerifyOrQuit(otPlatSettingsGet(&sInstance, key, 0, readBuffer, &readBufferLength) == kThreadError_NotFound,
                 "Settings::Delete::Get Fail\n");
}
Beispiel #2
0
void TestSettingsSwap(void)
{
    ThreadError error = kThreadError_None;
    uint8_t key = 11;
    uint16_t index = 0;
    uint8_t readBuffer[kMaxStageDataLen];
    uint16_t readBufferLength = kMaxStageDataLen;

    while (true)
    {
        error = otPlatSettingsAdd(&sInstance, key, sWriteBuffer, sWriteBufferLength);
        VerifyOrQuit(error == kThreadError_None || error == kThreadError_NoBufs, "Settings::Swap::Add Fail\n");

        if (error == kThreadError_NoBufs)
        {
            break;
        }

        index++;
    }

    VerifyOrQuit(otPlatSettingsDelete(&sInstance, key, 0) == kThreadError_None, "Settings::Swap::Delete Fail\n");
    VerifyOrQuit(otPlatSettingsAdd(&sInstance, key, sWriteBuffer, sWriteBufferLength) == kThreadError_None,
                 "Settings::Swap::Add Fail after swap\n");
    VerifyOrQuit(otPlatSettingsGet(&sInstance, key, index - 1, readBuffer, &readBufferLength) == kThreadError_None,
                 "Settings::Swap::Get Fail\n");
    VerifyOrQuit(!memcmp(readBuffer, sWriteBuffer, static_cast<uint16_t>(sWriteBufferLength)),
                 "Settings::Swap::Add and Swap Check Fail\n");
}
Beispiel #3
0
otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
{
    uint16_t length;
    bool     index0;

    index0 = (otPlatSettingsGet(aInstance, aKey, 0, NULL, &length) == OT_ERROR_NOT_FOUND ? true : false);
    return addSetting(aInstance, aKey, index0, aValue, aValueLength);
}
Beispiel #4
0
void TestSettingsSet(void)
{
    uint8_t key = 9;
    uint8_t readBuffer[kMaxStageDataLen];
    uint16_t readBufferLength;

    for (uint8_t index = 0; index < 2; index++)
    {
        VerifyOrQuit(otPlatSettingsAdd(&sInstance, key, sWriteBuffer, sWriteBufferLength) == kThreadError_None,
                     "Settings::Set::Add Fail\n");
    }

    VerifyOrQuit(otPlatSettingsSet(&sInstance, key, sWriteBuffer, sWriteBufferLength) == kThreadError_None,
                 "Settings::Set::Set Fail\n");
    VerifyOrQuit(otPlatSettingsGet(&sInstance, key, 0, readBuffer, &readBufferLength) == kThreadError_None,
                 "Settings::Set::Get Fail\n");
    VerifyOrQuit(!memcmp(readBuffer, sWriteBuffer, static_cast<uint16_t>(sWriteBufferLength)),
                 "Settings::Set::Set Check Fail\n");
}