ACKme / Mbed 2 deprecated wiconnect-test-console

Dependencies:   WiConnect mbed

Revision:
0:836c9a6383e0
Child:
1:5137ec8f4c45
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/blocking/file/FileListTest.cpp	Mon Aug 11 11:31:32 2014 +0000
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2014, ACKme Networks
+ * All Rights Reserved.
+ *
+ * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks;
+ * the contents of this file may not be disclosed to third parties, copied
+ * or duplicated in any form, in whole or in part, without the prior
+ * written permission of ACKme Networks.
+ */
+
+
+#include "tests/Tests.h"
+#include "Wiconnect.h"
+
+
+
+static void printFileList(const FileList &fileList);
+
+
+
+/*************************************************************************************************/
+WiconnectResult fileListCommand(int argc, char **argv)
+{
+    WiconnectResult result;
+    Wiconnect *wiconnect = Wiconnect::getInstance();
+    FileList fileList;
+    uint32_t type = FILE_TYPE_ANY;
+    const char *name = NULL;
+    uint32_t version = 0;
+
+    while(argc > 0)
+    {
+        if(argv[0][0] != '-' || argc < 2)
+        {
+            LOG_ERROR("Invalid command line argument");
+            return WICONNECT_BAD_ARG;
+        }
+
+        switch(argv[0][1])
+        {
+        case 'v': {
+            if(!Wiconnect::fileVersionStrToInt(argv[1], &version))
+            {
+                LOG_ERROR("Invalid file version");
+                return WICONNECT_BAD_ARG;
+            }
+        } break;
+        case 'n':
+            name = argv[1];
+        break;
+        case 't': {
+            if(!StringUtil::strHexToUint32((const char*)argv[1], &type))
+            {
+                LOG_ERROR("Invalid file type");
+                return WICONNECT_BAD_ARG;
+            }
+        } break;
+        default:
+            LOG_ERROR("Unknown command option: %c", argv[0][1]);
+            return WICONNECT_BAD_ARG;
+        }
+
+        argc -= 2;
+        argv += 2;
+    }
+
+
+    if(!WICONNECT_FAILED(result, wiconnect->listFiles(fileList, name, (FileType)type, version)))
+    {
+        printFileList(fileList);
+    }
+
+    return result;
+
+}
+
+/*************************************************************************************************/
+static void printFileList(const FileList &fileList)
+{
+    int i = 1;
+
+    LOG_INFO("File count: %d", fileList.getCount());
+    for(const File *file = fileList.getListHead(); file != NULL; file = file->getNext(), ++i)
+    {
+        LOG_INFO("------------------------\r\n"
+                 "%d: %s\r\n"
+                "\tVersion: %s\r\n"
+                "\tSize: %d\r\n"
+                "\tType: %s\r\n"
+                "\tFlags: %s\r\n",
+                i, file->getName(),
+                file->getVersionStr(),
+                file->getSize(),
+                Wiconnect::fileTypeToStr(file->getType()),
+                Wiconnect::fileFlagsToStr(file->getFlags()));
+    }
+}
+