3rd Repo, trying to figure this out.

Dependencies:   LPS25H hts221

Fork of SOFT253_Template_Weather_OS_54 by Stage-1 Students SoCEM

Revision:
60:db8c5b7fc548
Parent:
59:a69cd12dafca
Child:
65:3723d2729b68
--- a/main.cpp	Fri Apr 07 11:23:18 2017 +0000
+++ b/main.cpp	Fri Apr 07 11:48:05 2017 +0000
@@ -181,7 +181,7 @@
                 charPos = strtok(command," -,");
                 
                 //Check if it's a "LIST" command
-                if(CompareCommands(charPos, "list",4) == 1)
+                if(CompareCommands(charPos, "read",4) == 1)
                 {
                     charPos = strtok(NULL," -,");
                     //Check if it's a "LIST ALL" command
@@ -189,13 +189,18 @@
                     {
                         printf("\r\n Printing all measures performed so far: \r\n");
                         listBuffer->ListAll();   
-                        printf("\r\n D O N E ! \r\n");
+                        printf("\r\nD O N E ! \r\n");
                     }
                     //Check if it's a "LIST X" command
                     else if(strtol(charPos,NULL,10) != 0)
                     {
+                        printf("\r\n Printing %i measures: \r\n",atoi(charPos));
                         listBuffer->ListX(atoi(charPos));   
-                        printf("\r\n D O N E ! \r\n");
+                        printf("\r\nD O N E ! \r\n");
+                    }
+                    else
+                    {
+                        printf("Expected parameters: \"all\" | \"n\", where n is a number.");   
                     }
                 }
                 //Check if it's a "DELETE" command
@@ -207,18 +212,22 @@
                     {
                         printf("\r\n Deleting all measures performed so far: \r\n");
                         listBuffer->DeleteAll();
-                        printf("\r\n D O N E ! \r\n");
+                        printf("\r\nElements deleted!\r\n");
                     }
                     //Check if it's a "DELETE X" command
                     else if (strtol(charPos,NULL,10) != 0)
                     {
                         listBuffer->DeleteX(atoi(charPos));
-                        printf("\r\nD O N E ! \r\n");
+                        printf("\r\nElements deleted!\r\n");
+                    }
+                    else
+                    {
+                        printf("Expected parameters: \"all\" | \"n\", where n is a number.");     
                     }
                        
                 }
-                //Check if it's a "STATE/STATUS" command
-                else if (CompareCommands(charPos,"status",6) == 1 || CompareCommands(charPos,"state",5) == 1)
+                //Check if it's a "STATUS" command
+                else if (CompareCommands(charPos,"status",6) == 1)
                 {
                     char *ptr = localDate->ToString();
                     if(logging == true)
@@ -254,12 +263,13 @@
                         localDate->hour = h;
                         localDate->min = m;   
                         localDate->sec = s;
-                        printf("\r\n D O N E ! \r\n");
+                        char *ptr = localDate->ToString();
+                        printf("\r\nUpdated Date to: %s \r\n", ptr);
                     } 
                     //If not valid, prompt user
                     else
                     {
-                        printf("\r\nWrong format! \r\n");   
+                        printf("\r\nWrong format! please use HH-MM-SS separated by spaces. \r\n");   
                     }
                 }
                 //Check if it's a "SETDATE" command
@@ -290,28 +300,33 @@
                         localDate->day = d;
                         localDate->month = m;   
                         localDate->year = y;
-                        printf("\r\n D O N E ! \r\n");
+                        char *ptr = localDate->ToString();
+                        printf("\r\nUpdated Date to: %s \r\n", ptr);
                     } 
                     // Prompt user if they are not.
                     else
                     {
-                        printf("\r\nWrong format! \r\n");   
+                        printf("\r\nWrong format! please use DD-MM-YYYY separated by spaces. \r\n");   
                     }
                 }
                 // Check if it's a "LOGGING" command
-                else if(CompareCommands(charPos,"logging",7) == 1)
+                else if(CompareCommands(charPos,"state",5) == 1)
                 {
                     charPos = strtok(NULL," ,");
                     //Check if it should be turned ON / OFF
                     if(CompareCommands(charPos,"on",2) == 1)
                     {
                         logging = true;   
-                        printf("\r\nLogging turned ON!\r\n");
+                        printf("\r\nSampling turned ON!\r\n");
                     }
                     else if (CompareCommands(charPos,"off",3) == 1)
                     {
                         logging = false;   
-                        printf("\r\nLogging turned OFF!\r\n");
+                        printf("\r\Sampling turned OFF!\r\n");
+                    }
+                    else
+                    {
+                        printf("Expected parameters: \"on\" | \"off\"");   
                     }
                 }
                 else if(CompareCommands(charPos,"sett",4) == 1)
@@ -327,10 +342,10 @@
                     }
                     else
                     {
-                        printf("\r\n%f must be between greater than 0.1 or less equal than 60. \r\n", auxRate);    
+                        printf("\r\n Sample rate must be between greater than 0.1 or less equal than 60. \r\n");    
                     }
                 }
-                else if (CompareCommands(charPos,"help",4) == 1)
+                else if (CompareCommands(charPos,"help",4) == 1 || CompareCommands(charPos,"?",1) == 1)
                 {
                     printf("\r\nAvailable Commands:\r\n");
                     printf("    read <ALL|N> - Read ALL or N first measures.\r\n");
@@ -338,9 +353,14 @@
                     printf("    setdate <DD> <MM> <YYYY> Set current date.\r\n");
                     printf("    settime <HH> <MM> <SS> Set current time.\r\n");
                     printf("    sett <T> Set sample rate (in seconds).\r\n");
-                    printf("    state | status - Status report of device.\r\n");
+                    printf("    status - Status report of device.\r\n");
+                    printf("    state - <ON|OFF> - Turn sampling on or OFF.\r\n");
                     printf("    logging <ON|OFF> - Turn logging on or OFF.\r\n");
                 }
+                else
+                {
+                    printf("\r\n Command not recognized. Type \"help\" for more info.\r\n");   
+                }
                 printf("\r\nAwaiting command: \r\n");
                 //Clear command!
                 //* NOTE * Setting first char in array to '\0' WILL NOT RESET IT...for some reason.