Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
3:24c5f0f50bf1
Parent:
2:e67f7c158087
Child:
6:6f002d202f59
--- a/Websocket.h	Tue Jul 24 02:07:23 2012 +0000
+++ b/Websocket.h	Tue Jul 31 04:59:16 2012 +0000
@@ -42,6 +42,8 @@
 #include "dnsresolve.h"
 #endif //target
 
+#define RX_BUF_SIZE   1024
+#define RX_RECV_BYTES 512
 
 /** Websocket client Class. 
  *
@@ -144,18 +146,19 @@
         *
         *@return true if the connection is established, false otherwise
         */
-        bool connect(const uint32_t timeout=3);
+        bool connect(const uint32_t timeout);
         
         /**
         * Send a string according to the websocket format
         *
         * @param str string to be sent
         */
-        void send(char * str);
+        void send(const char * str);
         
         // CJR: add ones for binary data
-        bool sendBinary(const char* hbuf, const uint32_t hlen, char* str, const uint32_t len);
-        bool sendBinary(const char* hbuf, const uint32_t hlen, FILE* f, const uint32_t nbytes);
+        bool sendBinary(const char* str, const uint32_t len, char* const bbuf);
+        bool sendBinary(const char* hbuf, const uint32_t hlen, FILE* f, const uint32_t nbytes,
+                        char* const bbuf);
         
         /**
         * Read a websocket message
@@ -164,7 +167,9 @@
         *
         * @return true if a string has been read, false otherwise
         */
-        bool read(char * message, uint32_t& len_msg, const uint32_t timeout=3);
+        bool read(char * message, uint32_t& len_msg, const uint32_t maxlen,
+                  const uint32_t timeout,
+                  char* const bbuf, const uint32_t bbsize);
         
         /**
         * To see if there is a websocket connection active
@@ -195,7 +200,12 @@
     
     private:
     
-        
+        bool sendBinaryDirect(const char* str, const uint32_t len);
+        bool sendBinaryDirect(const char* hbuf, const uint32_t hlen, FILE* f, const uint32_t nbytes);
+        bool sendBinaryB64txt(const char* str, const uint32_t len, char* const bbuf);
+        bool sendBinaryB64txt(const char* hbuf, const uint32_t hlen, FILE* f, const uint32_t nbytes,
+                              char* const bbuf);
+
         void fillFields(char * url);
         void sendOpcode(uint8_t opcode);
         void sendLength(uint32_t len);
@@ -213,7 +223,7 @@
         bool eth_connected;
         bool eth_readable;
         bool eth_writeable;
-        char eth_rx[1024];
+        char eth_rx[RX_BUF_SIZE];
         bool response_server_eth;
         bool new_msg;
         
@@ -223,7 +233,8 @@
 #endif //target
         
         Type netif;
-
+        
+        static const bool kUseB64;
 };
 
 #endif
\ No newline at end of file