Esempio n. 1
0
int sampleMain()
{
    swi_av_Asset_t *asset = NULL;
    swi_av_Table_t *table = NULL;
    rc_ReturnCode_t res;

    const char *columns[] = {
          "col1",
          "col2",
          "timestamp"
        };

    res = swi_av_Init();
    if (res != RC_OK)
    {
        fprintf(stderr, "Failed to initialize airvantage module\n");
        return 1;
    }

    LE_INFO("Initializing asset\n");
    res = swi_av_asset_Create(&asset, ASSET_ID);
    if (res != RC_OK)
    {
        fprintf(stderr, "Failed to create asset\n");
        return 1;
    }

    LE_INFO("Registering asset\n");
    res = swi_av_asset_Start(asset);
    if (res != RC_OK)
    {
        fprintf(stderr, "Failed to register asset module\n");
        return 1;
    }

    res = swi_av_asset_PushString(asset, "event.status", "now", SWI_AV_TSTAMP_AUTO, "booting");
    if (res != RC_OK)
    {
        fprintf(stderr, "Failed to push data\n");
        return 1;
    }

    res = swi_av_table_Create(asset, &table, "col.data", 3, columns, POLICY, STORAGE_RAM, 0);
    if (res != RC_OK)
    {
        fprintf(stderr, "Failed to create table bedroom.data\n");
        return 1;
    }

    AddBedroomData(asset, table, 10);
    sleep(2);

    swi_av_asset_Destroy(asset);

    swi_av_Destroy();
    return 0;
}
Esempio n. 2
0
static int test_9_TableManipulation()
{
    swi_status_t res;
    swi_av_Asset_t* asset = NULL;
    swi_av_Table_t *table = NULL;
    const char *columns[] = { "column1", "column2", "column3" };

    res = swi_av_Init();
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_asset_Create(&asset, ASSET_ID);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_asset_Start(asset);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_table_Create(asset, &table, "test", 3, columns, "now", STORAGE_RAM, 0);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_table_PushInteger(table, 1234);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_table_PushFloat(table, 1234.1234);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_table_PushString(table, "test");
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_table_PushString(table, "fake push");
    if (res != SWI_STATUS_VALUE_OUT_OF_BOUND)
        return res;

    res = swi_av_table_PushRow(table);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_table_Destroy(table);
    if (res != SWI_STATUS_OK)
        return res;
    swi_av_asset_Destroy(asset);
    return 0;
}