Freescale FRDM K64F with DeviceHub.net IoT platform demo code

Dependencies:   EthernetInterface FXOS8700Q MQTTS MbedJSONValue mbed-rtos mbed wolfSSL

Fork of HelloMQTTS by wolf SSL

Revision:
17:25584027fae0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/getline.cpp	Sun Jul 26 09:55:46 2015 +0000
@@ -0,0 +1,43 @@
+
+#include <mbed.h>
+
+int getline(char *prompt, char *buff, int size)
+{
+    int sz ;
+    
+    printf("%s", prompt) ;
+    for(sz = 0 ;  (sz < size) && ((*buff = getchar()) != '\r'); sz++, buff++) {
+        putchar(*buff) ;
+        if(*buff == '\\') {
+            if(++sz >= size)break ;
+            *buff = getchar() ;
+            putchar(*buff) ;
+            switch(*buff) {
+                case 'n' :
+                    *buff = '\n' ;
+                    break ;
+                case 'r' :
+                    *buff = '\r' ;
+                    break ;
+                case 't' :
+                    *buff = '\t' ;
+                    break ;
+                case '\\':
+                    *buff = '\\' ;
+                    break ;
+                default:
+                    buff[1] = buff[0] ;
+                    buff[0] = '\\' ;
+                    buff++ ;
+            }
+        } else if(*buff == '\b') {
+            if(sz >= 2) {
+                buff-=2 ;
+                sz-=2;
+            }
+        }
+    } ;
+    putchar('\n') ;
+    *buff = '\0' ;
+    return sz ;
+}
\ No newline at end of file