Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]

humarobotics-wifiblock.h

Go to the documentation of this file.
00001 /*!@addtogroup other
00002  * @{
00003  * @defgroup HRWB HumaRobotics WiFiBlock
00004  * HumaBotics WiFiBlock Sensor
00005  * @{
00006  */
00007 
00008 /*
00009  * $Id: humarobotics-wifiblock.h 133 2013-03-10 15:15:38Z xander $
00010  */
00011 
00012 #ifndef __HRWB_H__
00013 #define __HRWB_H__
00014 /** \file humarobotics-wifiblock.h
00015  * \brief HumaRobotics WiFiBlock driver
00016  *
00017  * humarobotics-wifiblock.h provides an API for the HumaRobotics WiFiBlock Sensor.  This program
00018  * demonstrates how to use that API.
00019  *
00020  * Changelog:
00021  * - 0.1: Initial release
00022  *
00023  * Credits:
00024  * - Big thanks to HumaRobotics for providing me with the hardware necessary to write and test this.
00025  *
00026  * License: You may use this code as you wish, provided you give credit where its due.
00027  *
00028  * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. 
00029 
00030  * \author Xander Soldaat (xander_at_botbench.com)
00031  * \date 02 April 2012
00032  * \version 0.1
00033  * \example humarobotics-wifiblock-test1.c
00034  */
00035 
00036 #pragma systemFile
00037 
00038 #ifndef __COMMON_H__
00039 #include "common.h"
00040 #endif
00041 
00042 
00043 #define HRWB_I2C_ADDR               0x20      /*!< WiFiBlock I2C address */
00044 #define HRWB_SIMPLE_WRITE           0x01      /*!< Command for a simple write */
00045 #define HRWB_MASKED_WRITE           0x02      /*!< Command for a masked write */
00046 
00047 #define HRWB_SENSORTYPE             0x0008    /*!< Register for Sensortype - WIFI */
00048 #define HRWB_BATTLVL                0x000C    /*!< Register for battery level in 0.1V */
00049 
00050 #define HRWB_HTTP_RESULT_CODE       0x001F    /*!< Register for HTTP result code */
00051 
00052 #define HRWB_RESET                  0x000E    /*!< Register to reset the WiFiblock */
00053 #define HRWB_RESET_WIFIBLOCK        0x00      /*!< Command to reset the WiFiblock */
00054 #define HRWB_RESET_ERRORCODE        0x01      /*!< Command to reset the error code WiFiblock */
00055 
00056 // WiFi connection related
00057 #define HRWB_WIFI_STATUS            0x0200    /*!< Register for WiFi Status - see HRWB_WIFI_STATUS_* for bit masks */
00058 #define HRWB_WIFI_SIGNAL            0x0201    /*!< Register for signal strength */
00059 #define HRWB_WIFI_SSID              0x0202    /*!< Register for SSID */
00060 #define HRWB_WIFI_IP_ADDR           0x0222    /*!< Register for IPv4 address */
00061 #define HRWB_WIFI_IP_MASK           0x0226    /*!< Register for Netmask */
00062 #define HRWB_WIFI_IP_GATEWAY        0x022A    /*!< Register for default gateway */
00063 #define HRWB_WIFI_SECURITY_TYPE     0x022E    /*!< Register for WiFi security type - see HRWB_SECURITY_*  for values */
00064 #define HRWB_WIFI_SECURITY_KEY      0x022F    /*!< Register for WiFi key */
00065 #define HRWB_WIFI_SCANRESULT        0x026F    /*!< Register for number of SSIDs found after a scan */
00066 #define HRWB_WIFI_SCANSEL           0x0270    /*!< Register for selecting the SSID to get more info on */
00067 #define HRWB_WIFI_SCANSIGNAL        0x0271    /*!< Register for the signal strength of the specified SSID */
00068 #define HRWB_WIFI_SCANSEC           0x0272    /*!< Register for the security type of the specified SSID */
00069 #define HRWB_WIFI_SCANSSID          0x0273    /*!< Register for specifying the SSID to scan */
00070 
00071 #define HRWB_WIFI_STATUS_ENABLE     0x01      /*!< Bit mask for selecting WiFi status */
00072 #define HRWB_WIFI_STATUS_SAVE_CONF  0x02      /*!< Bit mask for selecting command to save current configuration */
00073 #define HRWB_WIFI_STATUS_START_SCAN 0x04      /*!< Bit mask for selecting command to start scanning network */
00074 #define HRWB_WIFI_STATUS_SCAN_DONE  0x08      /*!< Bit mask for selecting whether scan is done */
00075 #define HRWB_WIFI_STATUS_CONN_STAT  0x10      /*!< Bit mask for selecting status of the current WiFi connection */
00076 #define HRWB_WIFI_STATUS_RESERVED   0x20      /*!< RESERVED */
00077 #define HRWB_WIFI_STATUS_RECONN     0x40      /*!< Bit mask for selecting whether or not to reconnect when disconnected */
00078 #define HRWB_WIFI_STATUS_DEL_CONF   0x80      /*!< Bit mask for selecting command to delete current configuration */
00079 
00080 #define HRWB_SECURITY_OPEN          0x00      /*!< HRWB_WIFI_SECURITY_TYPE value for Open Network (no crypto) */
00081 #define HRWB_SECURITY_WEP           0x01      /*!< HRWB_WIFI_SECURITY_TYPE value for WEP crypto */
00082 #define HRWB_SECURITY_WPA           0x02      /*!< HRWB_WIFI_SECURITY_TYPE value for WPA */
00083 #define HRWB_SECURITY_WPA2          0x03      /*!< HRWB_WIFI_SECURITY_TYPE value for WPA2 */
00084 
00085 // HTTP GET related
00086 #define HRWB_GET_STATUS             0x1000    /*!< Register for status of GET command - see HRWB_GET_STATUS_* for bit masks */
00087 #define HRWB_GET_LENGTH             0x1001    /*!< Register for received data length */
00088 #define HRWB_GET_IP_ADDR            0x1002    /*!< Register for IP address to send request to */
00089 #define HRWB_GET_PORT               0x1006    /*!< Register for port to send request to */
00090 #define HRWB_GET_URL                0x1008    /*!< Register for URL (everything after the host name) */
00091 #define HRWB_GET_DATA               0x1048    /*!< Register for received data */
00092 
00093 #define HRWB_GET_STATUS_READY       0x01      /*!< Bit mask for GET port readiness status */
00094 #define HRWB_GET_STATUS_RESERVED1   0x02      /*!< RESERVED */
00095 #define HRWB_GET_STATUS_SEND_REQ    0x04      /*!< Bit mask for sending the GET request*/
00096 #define HRWB_GET_STATUS_REQ_DONE    0x08      /*!< Bit mask for checking whether GET request is done */
00097 #define HRWB_GET_STATUS_RESERVED2   0x10      /*!< RESERVED */
00098 #define HRWB_GET_STATUS_RESERVED3   0x20      /*!< RESERVED */
00099 #define HRWB_GET_STATUS_RESERVED4   0x40      /*!< RESERVED */
00100 #define HRWB_GET_STATUS_REQ_ERROR   0x80      /*!< Bit mask for checking if an error has occurred */
00101 
00102 // HTTP POST related
00103 #define HRWB_POST_STATUS            0x2000    /*!< Register for status of POST command - see HRWB_POST_STATUS_* for bit masks */
00104 #define HRWB_POST_LENGTH            0x2001    /*!< Register for POST data length */
00105 #define HRWB_POST_IP_ADDR           0x2002    /*!< Register for IP address to send request to */
00106 #define HRWB_POST_PORT              0x2006    /*!< Register for port to send request to */
00107 #define HRWB_POST_URL               0x2008    /*!< Register for URL (everything after the host name) */
00108 #define HRWB_POST_DATA              0x2048    /*!< Register for POST data */
00109 
00110 #define HRWB_POST_STATUS_READY      0x01      /*!< Bit mask for POST port readiness status */
00111 #define HRWB_POST_STATUS_RESERVED1  0x02      /*!< RESERVED */
00112 #define HRWB_POST_STATUS_SEND_REQ   0x04      /*!< Bit mask for sending the POST request*/
00113 #define HRWB_POST_STATUS_REQ_DONE   0x08      /*!< Bit mask for checking whether POST request is done */
00114 #define HRWB_POST_STATUS_EN_FL_STO  0x10      /*!< Bit mask to store POST requests in the dataflash in case of network loss */
00115 #define HRWB_POST_STATUS_EN_FL_RTX  0x20      /*!< Bit mask to store POST requests in the DataFlash in case of network loss
00116                                                    and then automatically retransmits them when the network is up again */
00117 #define HRWB_POST_STATUS_RESERVED2  0x40      /*!< RESERVED */
00118 #define HRWB_POST_STATUS_REQ_ERROR  0x80      /*!< Bit mask for checking if an error has occurred */
00119 
00120 // TCP related
00121 #define HRWB_TCP_STATUS             0x4000    /*!< Register for status of TCP command - see HRWB_TCP_STATUS_* for bit masks */
00122 #define HRWB_TCP_IP_ADDR            0x4001    /*!< Register for IP address to send request to */
00123 #define HRWB_TCP_PORT               0x4005    /*!< Register for port to send request to */
00124 #define HRWB_TCP_TX_LENGTH          0x4007    /*!< Register for tramsmitted data length */
00125 #define HRWB_TCP_TX_DATA            0x4008    /*!< Register for tramsmitted data */
00126 #define HRWB_TCP_RX_LENGTH          0x4028    /*!< Register for received data length */
00127 #define HRWB_TCP_RX_DATA            0x4029    /*!< Register for received data */
00128 
00129 #define HRWB_TCP_STATUS_READY       0x01      /*!< Bit mask for TCP port readiness status */
00130 #define HRWB_TCP_STATUS_SEND_REQ    0x02      /*!< Bit mask for sending the TCP request*/
00131 #define HRWB_TCP_STATUS_REQ_DONE    0x04      /*!< Bit mask for checking whether TCP request is done */
00132 #define HRWB_TCP_STATUS_RESERVED1   0x08      /*!< RESERVED */
00133 #define HRWB_TCP_STATUS_RESERVED2   0x10      /*!< RESERVED */
00134 #define HRWB_TCP_STATUS_RESERVED3   0x20      /*!< RESERVED */
00135 #define HRWB_TCP_STATUS_RESERVED4   0x40      /*!< RESERVED */
00136 #define HRWB_TCP_STATUS_REQ_ERROR   0x80      /*!< Bit mask for checking if an error has occurred */
00137 
00138 // UDP related
00139 #define HRWB_UDP_STATUS             0x3000    /*!< Register for status of UDP command - see HRWB_UDP_STATUS_* for bit masks */
00140 #define HRWB_UDP_IP_ADDR            0x3001    /*!< Register for IP address to send request to */
00141 #define HRWB_UDP_DPORT              0x3005    /*!< Register for port to send request to */
00142 #define HRWB_UDP_SPORT              0x3007    /*!< Register for port to send request from */
00143 #define HRWB_UDP_TX_LENGTH          0x3009    /*!< Register for tramsmitted data length */
00144 #define HRWB_UDP_TX_DATA            0x300A    /*!< Register for tramsmitted data */
00145 #define HRWB_UDP_RX_LENGTH          0x302A    /*!< Register for received data length */
00146 #define HRWB_UDP_RX_DATA            0x302B    /*!< Register for received data */
00147 
00148 #define HRWB_UDP_STATUS_READY       0x01      /*!< Bit mask for UDP port readiness status */
00149 #define HRWB_UDP_STATUS_SEND_REQ    0x02      /*!< Bit mask for sending the UDP request*/
00150 #define HRWB_UDP_STATUS_REQ_DONE    0x04      /*!< Bit mask for checking whether UDP request is done */
00151 #define HRWB_UDP_STATUS_RXD_RDY     0x08      /*!< Bit mask for checking whether UDP data is ready for reading */
00152 #define HRWB_UDP_STATUS_RXD_READ    0x10      /*!< Bit mask start reading UDP data */
00153 #define HRWB_UDP_STATUS_RESERVED1   0x20      /*!< RESERVED */
00154 #define HRWB_UDP_STATUS_RESERVED2   0x40      /*!< RESERVED */
00155 #define HRWB_UDP_STATUS_REQ_ERROR   0x80      /*!< Bit mask for checking if an error has occurred */
00156 
00157 tByteArray HRWB_I2CRequest;       /*!< Array to hold I2C command data */
00158 tByteArray HRWB_I2CReply;         /*!< Array to hold I2C reply data */
00159 tByteArray HRWB_scratch;          /*!< Array to hold scratch data */
00160 tHugeByteArray HRWB_HugeArray;    /*!< Array to hold scratch data, only more of it */
00161 
00162 
00163 typedef struct                    /*!< Struct to hold network config information */
00164 {
00165   string wifi_ssid;               /*!< SSID (network name) to connect to */
00166   string wifi_pass;               /*!< WiFi network pass */
00167   tIPaddr IP;                     /*!< IP address to use */
00168   tIPaddr netmask;                /*!< netmask to use */
00169   tIPaddr gateway;                /*!< defrault gateway to use */
00170   ubyte wifi_type;                /*!< Crypto used on the network, see HRWB_SECURITY_* for options */
00171 } tNetworkInfo;
00172 
00173 /*
00174 typedef struct
00175 {
00176   ubyte SSID[64];
00177   ubyte signalStrength;
00178   ubyte securityType;
00179 } tSSIDInfo;
00180 */
00181 
00182 
00183 typedef struct                    /*!< Struct to hold UDP connection info */
00184 {
00185   tIPaddr IP;                     /*!< IP address to send request to */
00186   int port;                       /*!< port to send request to */
00187   tHugeByteArray URL;             /*!< URL (everything after the host name) */
00188   tBigByteArray RXData;           /*!< Received data */
00189   ubyte RXDataLen;                /*!< Amount of received data */
00190   ubyte result_code;              /*!< HTTP result code */
00191 } tGetRequest;
00192 
00193 
00194 typedef struct
00195 {
00196   tIPaddr IP;                     /*!< IP address to send request to */
00197   int port;                       /*!< port to send request to */
00198   tHugeByteArray URL;             /*!< URL (everything after the host name) */
00199   tBigByteArray TXData;           /*!< Data to be transmitted */
00200   ubyte TXDataLen;                /*!< Amount of data to be transmitted */
00201   ubyte result_code;              /*!< HTTP result code */
00202 } tPostRequest;
00203 
00204 
00205 typedef struct
00206 {
00207   tIPaddr IP;                     /*!< IP address to send request to */
00208   int port;                       /*!< port to send request to */
00209   tHugeByteArray TXData;          /*!< Data to be transmitted */
00210   ubyte TXDataLen;                /*!< Amount of data to be transmitted */
00211   tHugeByteArray RXData;          /*!< Data to be transmitted */
00212   ubyte RXDataLen;                /*!< Amount of data to be transmitted */
00213   ubyte result_code;              /*!< result code: 0 if everything was fine, 1 if there was an error */
00214 } tTCPRequest;
00215 
00216 
00217 typedef struct
00218 {
00219   tIPaddr IP;                     /*!< IP address to send request to */
00220   int sport;                      /*!< port to send request from */
00221   int dport;                      /*!< port to send request to */
00222   tHugeByteArray TXData;          /*!< Data to be transmitted */
00223   ubyte TXDataLen;                /*!< Amount of data to be transmitted */
00224   tHugeByteArray RXData;          /*!< Data to be transmitted */
00225   ubyte RXDataLen;                /*!< Amount of data to be transmitted */
00226   ubyte result_code;              /*!< result code: 0 if everything was fine, 1 if there was an error */
00227 } tUDPRequest;
00228 
00229 // tSSIDInfo SSIDs[8];
00230 
00231 /**
00232  * Calculate the size of a string in an array.  Counts up to the NULL.
00233  * @param array the array to check the length of
00234  * @return length of the string in the array
00235  */
00236 int strsize(tHugeByteArray &array)
00237 {
00238   for (int i = 0; i < sizeof(tHugeByteArray); i++)
00239   {
00240     if((ubyte)array[i] == 0)
00241       return i;
00242   }
00243   return sizeof(tHugeByteArray);
00244 }
00245 
00246 
00247 /**
00248  * Convert a string to a tIPaddr struct. This is an IPv4 address.
00249  * @param address string representation of the IPv4 address
00250  * @param addr tIPaddr struct to hold the IPv4 address
00251  * @return true if no error occured, false if it did
00252  */
00253 void stringToIp(const string address, tIPaddr &addr)
00254 {
00255   string octet;
00256   string copy;
00257   int index = 0;
00258   memcpy(copy, address, 20);
00259 
00260   for (int i = 0; i < 3; i++)
00261   {
00262     octet = "";
00263     index = StringFind(copy, ".");
00264     memcpy(octet, copy, index);
00265     addr[i] = atoi(octet);
00266     StringDelete(copy, 0, index+1);
00267   }
00268   addr[3] = atoi(copy);
00269 }
00270 
00271 
00272 /**
00273  * Perform a masked write, which allows you to select a single bit in a register.
00274  * @param link the port number
00275  * @param reg register to write to
00276  * @param data value to write to the register
00277  * @param mask to use when writing to the register
00278  * @return true if no error occured, false if it did
00279  */
00280 bool HRWBwriteRegMasked(tSensors link, int reg, ubyte data, ubyte mask)
00281 {
00282   // writeDebugStreamLine("writeRegMasked");
00283   memset(HRWB_I2CRequest, 0, sizeof(tByteArray));
00284 
00285   HRWB_I2CRequest[0] =  6;                  //Message Size, here 7 Bytes
00286   HRWB_I2CRequest[1] =  HRWB_I2C_ADDR;
00287   HRWB_I2CRequest[2] =  HRWB_MASKED_WRITE;
00288   HRWB_I2CRequest[3] =  (reg >> 8) & 0xFF;  //Read address register - Msb
00289   HRWB_I2CRequest[4] =  reg & 0xFF;         //Read address register - Lsb
00290   HRWB_I2CRequest[5] =  mask;               //data
00291   HRWB_I2CRequest[6] =  data;               //mask
00292 
00293   return writeI2C(link, HRWB_I2CRequest);
00294 }
00295 
00296 
00297 /**
00298  * Write a single byte to a register
00299  * @param link the port number
00300  * @param reg register to write to
00301  * @param data value to write to the register
00302  * @return true if no error occured, false if it did
00303  */
00304 bool HRWBwriteReg(tSensors link, int reg, ubyte data)
00305 {
00306   // writeDebugStreamLine("writeReg");
00307   memset(HRWB_I2CRequest, 0, sizeof(tByteArray));
00308 
00309   HRWB_I2CRequest[0] =  5;                  //Message Size, here 7 Bytes
00310   HRWB_I2CRequest[1] =  HRWB_I2C_ADDR;
00311   HRWB_I2CRequest[2] =  HRWB_SIMPLE_WRITE;
00312   HRWB_I2CRequest[3] =  (reg >> 8) & 0xFF;  //Read address register - Msb
00313   HRWB_I2CRequest[4] =  reg & 0xFF;         //Read address register - Lsb
00314   HRWB_I2CRequest[5] =  data;                //Msb SensorType Register
00315 
00316   return writeI2C(link, HRWB_I2CRequest);
00317 }
00318 
00319 
00320 /**
00321  * Write data array to a register
00322  *
00323  * Note: this is an internal function and shouldn't be used directly
00324  * @param link the port number
00325  * @param reg register to write to
00326  * @param data value to write to the register
00327  * @param size amount of data to send
00328  * @return true if no error occured, false if it did
00329  */
00330 bool _HRWBwriteRegPrivate(tSensors link, int reg, tByteArray &data, int size)
00331 {
00332   if (size > 12)
00333     return false;
00334 
00335   memset(HRWB_I2CRequest, 0, sizeof(tByteArray));
00336 
00337   HRWB_I2CRequest[0] =  4 + size;                  //Message Size, here 7 Bytes
00338   HRWB_I2CRequest[1] =  HRWB_I2C_ADDR;
00339   HRWB_I2CRequest[2] =  HRWB_SIMPLE_WRITE;
00340   HRWB_I2CRequest[3] =  (reg >> 8) & 0xFF;  //Read address register - Msb
00341   HRWB_I2CRequest[4] =  reg & 0xFF;         //Read address register - Lsb
00342 
00343   memcpy(&HRWB_I2CRequest[5], data, size);
00344 
00345   return writeI2C(link, HRWB_I2CRequest);
00346 }
00347 
00348 
00349 /**
00350  * Write a tByteArray struct to a register
00351  * @param link the port number
00352  * @param reg register to write to
00353  * @param data tByteArray to write to the register
00354  * @param size amount of data to send
00355  * @return true if no error occured, false if it did
00356  */
00357 bool HRWBwriteReg(tSensors link, int reg, tByteArray &data, int size)
00358 {
00359   tByteArray tmpBuff;
00360   // writeDebugStreamLine("writeReg tByteArray");
00361   int bytesleft = size;
00362   int datalen = 0;
00363 
00364   for (int i =  0; i < ((size/12) + 1); i++)
00365         {
00366           datalen = (bytesleft > 12) ? 12 : bytesleft;
00367           memset(tmpBuff, 0, sizeof(tmpBuff));
00368           memcpy(tmpBuff, &data[i*12], datalen);
00369 
00370           if (!_HRWBwriteRegPrivate(link, reg + (i*12), tmpBuff, datalen))
00371             return false;
00372           bytesleft -= 12;
00373         }
00374         return true;
00375 }
00376 
00377 
00378 /**
00379  * Write a tHugeByteArray struct to a register
00380  * @param link the port number
00381  * @param reg register to write to
00382  * @param data tHugeByteArray to write to the register
00383  * @param size amount of data to send
00384  * @return true if no error occured, false if it did
00385  */
00386 bool HRWBwriteReg(tSensors link, int reg, tHugeByteArray &data, int size)
00387 {
00388   tByteArray tmpBuff;
00389   int bytesleft = size;
00390   int datalen = 0;
00391 
00392   for (int i =  0; i < ((size/12) + 1); i++)
00393         {
00394           datalen = (bytesleft > 12) ? 12 : bytesleft;
00395           memset(tmpBuff, 0, sizeof(tmpBuff));
00396           memcpy(tmpBuff, &data[i*12], datalen);
00397 
00398           if (!_HRWBwriteRegPrivate(link, reg + (i*12), tmpBuff, datalen))
00399             return false;
00400           bytesleft -= 12;
00401         }
00402         return true;
00403 }
00404 
00405 
00406 /**
00407  * Write a tBigByteArray struct to a register
00408  * @param link the port number
00409  * @param reg register to write to
00410  * @param data tBigByteArray to write to the register
00411  * @param size amount of data to send
00412  * @return true if no error occured, false if it did
00413  */
00414 bool HRWBwriteReg(tSensors link, int reg, tBigByteArray &data, int size)
00415 {
00416   tByteArray tmpBuff;
00417   int bytesleft = size;
00418   int datalen = 0;
00419 
00420   for (int i =  0; i < ((size/12) + 1); i++)
00421         {
00422           datalen = (bytesleft > 12) ? 12 : bytesleft;
00423           memset(tmpBuff, 0, sizeof(tmpBuff));
00424           memcpy(tmpBuff, &data[i*12], datalen);
00425 
00426           if (!_HRWBwriteRegPrivate(link, reg + (i*12), tmpBuff, datalen))
00427             return false;
00428           bytesleft -= 12;
00429         }
00430         return true;
00431 }
00432 
00433 
00434 /**
00435  * Read a register.  Data read is stored in HRWB_I2CReply
00436  * @param link the port number
00437  * @param reg register to read
00438  * @param size amount of data to read
00439  * @return true if no error occured, false if it did
00440  */
00441 bool HRWBreadReg(tSensors link, int reg, int size)
00442 {
00443   // writeDebugStreamLine("readReg");
00444   memset(HRWB_I2CRequest, 0, sizeof(tByteArray));
00445 
00446   HRWB_I2CRequest[0] =  7;                  //Message Size, here 7 Bytes
00447   HRWB_I2CRequest[1] =  HRWB_I2C_ADDR;
00448   HRWB_I2CRequest[2] =  HRWB_SIMPLE_WRITE;
00449   HRWB_I2CRequest[3] =  0x01;               //Read address register - Msb
00450   HRWB_I2CRequest[4] =  0x00;               //Read address register - Lsb
00451   HRWB_I2CRequest[5] =  (reg >> 8) & 0xFF;  //Msb SensorType Register
00452   HRWB_I2CRequest[6] =  reg & 0xFF;         //Lsb SensorType Register
00453   HRWB_I2CRequest[7] =  size & 0xFF;        //Size of the returned message
00454 
00455   return writeI2C(link, HRWB_I2CRequest, HRWB_I2CReply, size);
00456 }
00457 
00458 
00459 /**
00460  * Read a register.  Data read is stored in HRWB_HugeArray
00461  * @param link the port number
00462  * @param reg register to read
00463  * @param size amount of data to read
00464  * @return true if no error occured, false if it did
00465  */
00466 bool HRWBreadBigReg(tSensors link, int reg, int size)
00467 {
00468   // writeDebugStreamLine("readBigReg");
00469   int bytesleft = size;
00470   int requestlen = 0;
00471   memset(HRWB_I2CRequest, 0, sizeof(tByteArray));
00472   memset(HRWB_HugeArray, 0, sizeof(HRWB_HugeArray));
00473 
00474   for (int i =  0; i < ((size/16) + 1); i++)
00475         {
00476           requestlen = (bytesleft > 16) ? 16 : bytesleft;
00477           if (!HRWBreadReg(link, reg + (i*16), requestlen))
00478             return false;
00479           memcpy(&HRWB_HugeArray[16 * i], HRWB_I2CReply, requestlen);
00480           bytesleft -= 16;
00481           wait1Msec(10);
00482         }
00483         return true;
00484 }
00485 
00486 
00487 /**
00488  * Read the HTTP result code of the last HTTP transaction.
00489  * @param link the port number
00490  * @return the HTTP result code
00491  */
00492 int HRWBreadHTTPCode(tSensors link)
00493 {
00494   string tmpResultCode;
00495   HRWBreadReg(WifiBlockPort, HRWB_HTTP_RESULT_CODE, 3);
00496   HRWB_I2CReply[3] = 0;
00497   memcpy(tmpResultCode, HRWB_I2CReply, 4);
00498   return atoi(tmpResultCode);
00499 }
00500 
00501 
00502 /**
00503  * Reset the WiFiBlock.
00504  * @param link the port number
00505  * @return true if no error occured, false if it did
00506  */
00507 bool HRWBresetWifiBlock(tSensors link)
00508 {
00509   // writeDebugStreamLine("resetWifiBlock");
00510   return HRWBwriteRegMasked(WifiBlockPort, HRWB_RESET, 1, HRWB_RESET_WIFIBLOCK);
00511 }
00512 
00513 
00514 /**
00515  * Read the current voltage level
00516  * @param link the port number
00517  * @return current voltage level
00518  */
00519 float HRWBreadBatt(tSensors link)
00520 {
00521   HRWBreadReg(link, HRWB_BATTLVL, 1);
00522   return (float)HRWB_I2CReply[0]/10.0;
00523 
00524 }
00525 
00526 
00527 /**
00528  * Read the type of sensor. Should be WIFI, unless there's
00529  * something really freaky going on
00530  * @param link the port number
00531  * @param sType string to hold the sensor type string.
00532  * @return true if no error occured, false if it did
00533  */
00534 bool HRWBreadSensorType (tSensors link, string &sType)
00535 {
00536   if (!HRWBreadReg(link, HRWB_SENSORTYPE, 4))
00537     return false;
00538 
00539   StringFromChars(sType, &HRWB_I2CReply);
00540 
00541   return true;
00542 }
00543 
00544 
00545 /**
00546  * Enable the WiFi
00547  * @param link the port number
00548  * @return true if no error occured, false if it did
00549  */
00550 bool HRWBenableWifi(tSensors link)
00551 {
00552   //writeDebugStreamLine("enableWifi");
00553   return HRWBwriteRegMasked(link, HRWB_WIFI_STATUS, 0x01, HRWB_WIFI_STATUS_ENABLE);
00554 }
00555 
00556 
00557 /**
00558  * Disable the WiFi
00559  * @param link the port number
00560  * @return true if no error occured, false if it did
00561  */
00562 bool HRWBdisableWifi(tSensors link)
00563 {
00564   //writeDebugStreamLine("disableWifi");
00565   return HRWBwriteRegMasked(link, HRWB_WIFI_STATUS, 0x00, HRWB_WIFI_STATUS_ENABLE);
00566 }
00567 
00568 
00569 /**
00570  * Save the current network configuration
00571  * @param link the port number
00572  * @return true if no error occured, false if it did
00573  */
00574 bool HRWBsaveConfig(tSensors link)
00575 {
00576   //writeDebugStreamLine("saveConfig");
00577   return HRWBwriteRegMasked(link, HRWB_WIFI_STATUS, 0x02, HRWB_WIFI_STATUS_SAVE_CONF);
00578 }
00579 
00580 
00581 /**
00582  * Erase the current network configuration\n
00583  * Use in combination with HRWBresetWifiBlock()
00584  * to start with a clean configuration
00585  * @param link the port number
00586  * @return true if no error occured, false if it did
00587  */
00588 bool HRWBeraseConfig(tSensors link)
00589 {
00590   //writeDebugStreamLine("eraseConfig");
00591   return HRWBwriteRegMasked(link, HRWB_WIFI_STATUS, 0x80, HRWB_WIFI_STATUS_DEL_CONF);
00592 }
00593 
00594 
00595 /*
00596 bool HRWBscanChannel(tSensors link, ubyte channel) {
00597   string tmpString;
00598   char tmpCharArray[20];
00599   int SSIDcount = 0;
00600   memset(HRWB_I2CRequest, 0, sizeof(tByteArray));
00601 
00602   writeDebugStreamLine("channel: %d", channel);
00603   if (!HRWBwriteReg(link, HRWB_WIFI_SCANSEL, channel))
00604     return false;
00605 
00606   // Start scan
00607   HRWB_I2CRequest[0] =  6;                  //Message Size, here 7 Bytes
00608   HRWB_I2CRequest[1] =  HRWB_I2C_ADDR;
00609   HRWB_I2CRequest[2] =  HRWB_MASKED_WRITE;
00610   HRWB_I2CRequest[3] =  0x02;               //Read address register - Msb
00611   HRWB_I2CRequest[4] =  0x00;               //Read address register - Lsb
00612   HRWB_I2CRequest[5] =  0x04;               //Msb SensorType Register
00613   HRWB_I2CRequest[6] =  0x04;               //Lsb SensorType Register
00614 
00615   if (!writeI2C(link, HRWB_I2CRequest, 0))
00616     return false;
00617 
00618   // Wait for scan to be done
00619   while (true) {
00620           HRWBreadReg(link, HRWB_WIFI_STATUS, 1);
00621           if ((HRWB_I2CReply[0] & 0x08) == 0x08)
00622             break;
00623           wait1Msec(100);
00624         }
00625 
00626   HRWBwriteReg(link, HRWB_WIFI_SCANSEL, channel);
00627   wait1Msec(10);
00628   HRWBreadBigReg(link, HRWB_WIFI_SCANSSID, 64);
00629   StringFromChars(tmpString, HRWB_HugeArray);
00630   writeDebugStream("Found [%d]: ", channel);
00631   writeDebugStreamLine(tmpString);
00632   return true;
00633 }
00634 
00635 
00636 
00637 
00638 bool HRWBscanWifi(tSensors link)
00639 {
00640   char tmpCharArray[20];
00641   int SSIDcount = 0;
00642   memset(HRWB_I2CRequest, 0, sizeof(tByteArray));
00643 
00644   if (!HRWBwriteRegMasked(link, HRWB_WIFI_STATUS, HRWB_WIFI_STATUS_START_SCAN, HRWB_WIFI_STATUS_START_SCAN))
00645     return false;
00646 
00647   // Wait for scan to be done
00648   while (true) {
00649           HRWBreadReg(link, HRWB_WIFI_STATUS, 1);
00650           if ((HRWB_I2CReply[0] &  HRWB_WIFI_STATUS_SCAN_DONE) == HRWB_WIFI_STATUS_SCAN_DONE)
00651             break;
00652           wait1Msec(100);
00653         }
00654 
00655         // Fetch number of SSIDs found.
00656   HRWBreadReg(link, HRWB_WIFI_SCANRESULT, 1);
00657   SSIDcount = HRWB_I2CReply[0];
00658   writeDebugStreamLine("SSID count: %d", SSIDcount);
00659   if (SSIDcount == 0)
00660     return false;
00661 
00662   writeDebugStreamLine("count: %d", SSIDcount);
00663   for (int i = 0; i < SSIDcount; i++) {
00664     if (!HRWBscanChannel(link, i))
00665       return false;
00666     wait1Msec(10);
00667   }
00668   return true;
00669 
00670 
00671 }
00672 */
00673 
00674 
00675 /**
00676  * Configure the IP and WiFi settings
00677  * @param link the port number
00678  * @param netInfo tNetworkInfo struct containing network connection parameters
00679  * @return true if no error occured, false if it did
00680  */
00681 bool HRWBconfigNetwork(tSensors link, tNetworkInfo &netInfo) {
00682   bool done = false;
00683   ubyte status;
00684   memset(HRWB_I2CRequest, 0, sizeof(tByteArray));
00685 
00686   // switch off the wifi
00687   if (!HRWBdisableWifi(link))
00688     return false;
00689 
00690   if (!HRWBeraseConfig(link))
00691     return false;
00692   wait1Msec(100);
00693 
00694   PlaySound(soundBlip);
00695   memcpy(HRWB_scratch, netInfo.IP[0], sizeof(tIPaddr));
00696   if (!HRWBwriteReg(link, HRWB_WIFI_IP_ADDR, HRWB_scratch, sizeof(tIPaddr)))
00697     return false;
00698 
00699         memcpy(HRWB_scratch, netInfo.netmask[0], sizeof(tIPaddr));
00700         if (!HRWBwriteReg(link, HRWB_WIFI_IP_MASK, HRWB_scratch, sizeof(tIPaddr)))
00701           return false;
00702 
00703         memcpy(HRWB_scratch, netInfo.gateway[0], sizeof(tIPaddr));
00704         if (!HRWBwriteReg(link, HRWB_WIFI_IP_GATEWAY, HRWB_scratch, sizeof(tIPaddr)))
00705           return false;
00706 
00707         if (!HRWBwriteReg(link, HRWB_WIFI_SECURITY_TYPE, netInfo.wifi_type))
00708           return false;
00709 
00710         memcpy(HRWB_scratch, netInfo.wifi_ssid, strlen(netInfo.wifi_ssid) + 1);
00711         if (!HRWBwriteReg(link, HRWB_WIFI_SSID, HRWB_scratch, strlen(netInfo.wifi_ssid) + 1))
00712           return false;
00713 
00714   memcpy(HRWB_scratch, netInfo.wifi_pass, strlen(netInfo.wifi_pass) + 1);
00715         if (!HRWBwriteReg(link, HRWB_WIFI_SECURITY_KEY, HRWB_scratch, strlen(netInfo.wifi_pass) + 1))
00716           return false;
00717 
00718         if (!HRWBwriteRegMasked(link, HRWB_WIFI_STATUS, HRWB_WIFI_STATUS_RECONN, HRWB_WIFI_STATUS_RECONN))
00719           return false;
00720 
00721         if (!HRWBsaveConfig(link))
00722           return false;
00723 
00724         if (!HRWBenableWifi(link))
00725           return false;
00726 
00727         while(!done) {
00728           if (!HRWBreadReg(link, HRWB_WIFI_STATUS, 1))
00729             return false;
00730           status = HRWB_I2CReply[0];
00731 
00732           if ((status & HRWB_WIFI_STATUS_CONN_STAT) == HRWB_WIFI_STATUS_CONN_STAT)
00733           {
00734             done = true;
00735           }
00736           wait1Msec(100);
00737         }
00738 
00739   return true;
00740 }
00741 
00742 
00743 /**
00744  * Perform a HTTP GET transaction
00745  * @param link the port number
00746  * @param getrequest tGetRequest struct containing transaction parameters
00747  * @return true if no error occured, false if it did
00748  */
00749 bool HRWBdoGET(tSensors link, tGetRequest &getrequest) {
00750   ubyte status = 0;
00751   bool done = false;
00752   ubyte tmpPort[2];
00753 
00754   tmpPort[0] = (getrequest.port >> 8) & 0xFF;
00755   tmpPort[1] = (getrequest.port >> 0) & 0xFF;
00756 
00757   HRWBreadReg(link, HRWB_GET_STATUS, 1);
00758   status = HRWB_I2CReply[0];
00759 
00760   if (status & HRWB_GET_STATUS_READY != HRWB_GET_STATUS_READY)
00761   {
00762     writeDebugStreamLine("NOT READY");
00763     return false;
00764   }
00765 
00766         memcpy(HRWB_scratch, getrequest.IP[0], sizeof(tIPaddr));
00767         if (!HRWBwriteReg(link, HRWB_GET_IP_ADDR, HRWB_scratch, sizeof(tIPaddr)))
00768           return false;
00769 
00770   memcpy(HRWB_scratch, tmpPort, 2);
00771         if (!HRWBwriteReg(link, HRWB_GET_PORT, HRWB_scratch, 2))
00772           return false;
00773 
00774         if (!HRWBwriteReg(link, HRWB_GET_URL, (tHugeByteArray)getrequest.URL, strsize(getrequest.URL) + 1))
00775           return false;
00776 
00777         if (!HRWBwriteRegMasked(link, HRWB_GET_STATUS, HRWB_GET_STATUS_SEND_REQ, HRWB_GET_STATUS_SEND_REQ))
00778           return false;
00779 
00780         while(!done) {
00781           if (!HRWBreadReg(link, HRWB_GET_STATUS, 1))
00782             return false;
00783 
00784           status = HRWB_I2CReply[0];
00785 
00786           if ((status & HRWB_GET_STATUS_REQ_ERROR) == HRWB_GET_STATUS_REQ_ERROR)
00787           {
00788             //writeDebugStreamLine("ERROR GET: %d", status);
00789             getrequest.result_code = HRWBreadHTTPCode(link);
00790             //writeDebugStreamLine("HTTP CODE: %d", getrequest.result_code);
00791             done = true;
00792           }
00793           else if ((status & HRWB_GET_STATUS_REQ_DONE) == HRWB_GET_STATUS_REQ_DONE)
00794           {
00795             //writeDebugStreamLine("SUCCESS GET");
00796             getrequest.result_code = HRWBreadHTTPCode(link);
00797             //writeDebugStreamLine("HTTP CODE: %d", getrequest.result_code);
00798             done = true;
00799           }
00800           wait1Msec(100);
00801         }
00802 
00803         wait1Msec(1000);
00804         if (!HRWBreadReg(link, HRWB_GET_LENGTH, 1))
00805           return false;
00806   getrequest.RXDataLen = HRWB_I2CReply[0];
00807 
00808   writeDebugStreamLine("res length: %d", getrequest.RXDataLen);
00809   if (!HRWBreadBigReg(link, HRWB_GET_DATA, getrequest.RXDataLen))
00810     return false;
00811 
00812   memcpy(&getrequest.RXData[0], &HRWB_HugeArray[0], sizeof(tBigByteArray));
00813         return true;
00814 
00815 
00816 }
00817 
00818 
00819 /**
00820  * Perform a HTTP POST transaction
00821  * @param link the port number
00822  * @param postrequest tPostRequest struct containing transaction parameters
00823  * @return true if no error occured, false if it did
00824  */
00825 bool HRWBdoPOST(tSensors link, tPostRequest &postrequest) {
00826   ubyte status = 0;
00827   bool done = false;
00828   ubyte tmpPort[2];
00829 
00830   tmpPort[0] = (postrequest.port >> 8) & 0xFF;
00831   tmpPort[1] = (postrequest.port >> 0) & 0xFF;
00832 
00833   HRWBreadReg(link, HRWB_POST_STATUS, 1);
00834   status = HRWB_I2CReply[0];
00835 
00836   if (status & HRWB_POST_STATUS_READY != HRWB_POST_STATUS_READY)
00837     return false;
00838     //writeDebugStreamLine("NOT READY");
00839 
00840         memcpy(HRWB_scratch, postrequest.IP[0], sizeof(tIPaddr));
00841         if (!HRWBwriteReg(link, HRWB_POST_IP_ADDR, HRWB_scratch, sizeof(tIPaddr)))
00842           return false;
00843 
00844   memcpy(HRWB_scratch, tmpPort, 2);
00845         if (!HRWBwriteReg(link, HRWB_POST_PORT, HRWB_scratch, 2))
00846           return false;
00847 
00848         if (!HRWBwriteReg(link, HRWB_POST_URL, (tHugeByteArray)postrequest.URL, strsize(postrequest.URL) + 1))
00849           return false;
00850 
00851         if (!HRWBwriteReg(link, HRWB_POST_DATA, (tBigByteArray)postrequest.TXData[0], postrequest.TXDataLen))
00852           return false;
00853 
00854         if (!HRWBwriteRegMasked(link, HRWB_POST_STATUS, HRWB_POST_STATUS_SEND_REQ, HRWB_POST_STATUS_SEND_REQ))
00855           return false;
00856 
00857         while(!done) {
00858           if (!HRWBreadReg(link, HRWB_POST_STATUS, 1))
00859             return false;
00860           status = HRWB_I2CReply[0];
00861 
00862 
00863           if ((status & HRWB_POST_STATUS_REQ_ERROR) == HRWB_POST_STATUS_REQ_ERROR)
00864           {
00865             //writeDebugStreamLine("ERROR POST: %d", status);
00866             postrequest.result_code = HRWBreadHTTPCode(link);
00867             //writeDebugStreamLine("HTTP CODE: %d", postrequest.result_code);
00868             done = true;
00869           }
00870           else if ((status & HRWB_POST_STATUS_REQ_DONE) == HRWB_POST_STATUS_REQ_DONE)
00871           {
00872             //writeDebugStreamLine("SUCCESS POST");
00873             postrequest.result_code = HRWBreadHTTPCode(link);
00874             //writeDebugStreamLine("HTTP CODE: %d", postrequest.result_code);
00875             done = true;
00876           }
00877           wait1Msec(100);
00878         }
00879         return true;
00880 }
00881 
00882 
00883 /**
00884  * Perform a TCP transaction
00885  * @param link the port number
00886  * @param tcprequest tTCPRequest struct containing transaction parameters
00887  * @return true if no error occured, false if it did
00888  */
00889 bool HRWBdoTCP(tSensors link, tTCPRequest &tcprequest) {
00890   ubyte status = 0;
00891   bool done = false;
00892   HRWBreadReg(link, HRWB_TCP_STATUS, 1);
00893   status = HRWB_I2CReply[0];
00894   ubyte tmpPort[2];
00895 
00896   tmpPort[0] = (tcprequest.port >> 8) & 0xFF;
00897   tmpPort[1] = (tcprequest.port >> 0) & 0xFF;
00898 
00899   if (status & HRWB_TCP_STATUS_READY != HRWB_TCP_STATUS_READY)
00900     return false;
00901     //writeDebugStreamLine("NOT READY");
00902 
00903         memcpy(HRWB_scratch, tcprequest.IP[0], sizeof(tIPaddr));
00904         if (!HRWBwriteReg(link, HRWB_TCP_IP_ADDR, HRWB_scratch, sizeof(tIPaddr )))
00905           return false;
00906 
00907   memcpy(HRWB_scratch, tmpPort, 2);
00908         if (!HRWBwriteReg(link, HRWB_TCP_PORT, HRWB_scratch, 2))
00909           return false;
00910 
00911         writeDebugStreamLine("port: %2x %2x", HRWB_scratch[0], HRWB_scratch[1]);
00912 
00913         if (!HRWBwriteReg(link, HRWB_TCP_TX_DATA, (tBigByteArray)tcprequest.TXData[0], tcprequest.TXDataLen))
00914           return false;
00915 
00916         memcpy(HRWB_scratch, tcprequest.TXDataLen, 1);
00917         if (!HRWBwriteReg(link, HRWB_TCP_TX_LENGTH, HRWB_scratch, 1))
00918           return false;
00919 
00920         if (!HRWBwriteRegMasked(link, HRWB_TCP_STATUS, HRWB_TCP_STATUS_SEND_REQ, HRWB_TCP_STATUS_SEND_REQ))
00921           return false;
00922 
00923         while(!done) {
00924           if (!HRWBreadReg(link, HRWB_TCP_STATUS, 1))
00925             return false;
00926           status = HRWB_I2CReply[0];
00927 
00928           if ((status & HRWB_TCP_STATUS_REQ_ERROR) == HRWB_TCP_STATUS_REQ_ERROR)
00929           {
00930             tcprequest.result_code = status;
00931             done = true;
00932           }
00933           else if ((status & HRWB_TCP_STATUS_REQ_DONE) == HRWB_TCP_STATUS_REQ_DONE)
00934           {
00935             tcprequest.result_code = 0;
00936             done = true;
00937           }
00938           wait1Msec(100);
00939         }
00940 
00941         wait1Msec(100);
00942         if (!HRWBreadReg(link, HRWB_TCP_RX_LENGTH, 1))
00943           return false;
00944   tcprequest.RXDataLen = HRWB_I2CReply[0];
00945 
00946   writeDebugStreamLine("res length: %d", tcprequest.RXDataLen);
00947   if (!HRWBreadBigReg(link, HRWB_TCP_RX_DATA, 32))
00948     return false;
00949 
00950   memcpy(&tcprequest.RXData[0], &HRWB_HugeArray[0], sizeof(tBigByteArray));
00951 
00952   //writeDebugStreamLine(" ");
00953         return true;
00954 }
00955 
00956 
00957 /**
00958  * Perform a UDP transaction
00959  * @param link the port number
00960  * @param udprequest tUDPRequest struct containing transaction parameters
00961  * @return true if no error occured, false if it did
00962  */
00963 bool HRWBdoUDP(tSensors link, tUDPRequest &udprequest) {
00964   ubyte status = 0;
00965   bool done = false;
00966   HRWBreadReg(link, HRWB_UDP_STATUS, 1);
00967   status = HRWB_I2CReply[0];
00968   ubyte tmpsPort[2];
00969   ubyte tmpdPort[2];
00970 
00971 
00972   tmpsPort[0] = (udprequest.sport >> 8) & 0xFF;
00973   tmpsPort[1] = (udprequest.sport >> 0) & 0xFF;
00974 
00975   tmpdPort[0] = (udprequest.dport >> 8) & 0xFF;
00976   tmpdPort[1] = (udprequest.dport >> 0) & 0xFF;
00977 
00978   if (status & HRWB_UDP_STATUS_READY != HRWB_UDP_STATUS_READY)
00979     writeDebugStreamLine("NOT READY");
00980 
00981         memcpy(HRWB_scratch, udprequest.IP[0], sizeof(tIPaddr));
00982         if (!HRWBwriteReg(link, HRWB_UDP_IP_ADDR, HRWB_scratch, sizeof(tIPaddr )))
00983           return false;
00984 
00985   memcpy(HRWB_scratch, tmpsPort, 2);
00986         if (!HRWBwriteReg(link, HRWB_UDP_SPORT, HRWB_scratch, 2))
00987           return false;
00988         //writeDebugStreamLine("sport: %2x %2x", HRWB_scratch[0], HRWB_scratch[1]);
00989 
00990   memcpy(HRWB_scratch, tmpdPort, 2);
00991         if (!HRWBwriteReg(link, HRWB_UDP_DPORT, HRWB_scratch, 2))
00992           return false;
00993         //writeDebugStreamLine("dport: %2x %2x", HRWB_scratch[0], HRWB_scratch[1]);
00994 
00995         if (!HRWBwriteReg(link, HRWB_UDP_TX_DATA, (tBigByteArray)udprequest.TXData[0], udprequest.TXDataLen))
00996           return false;
00997 
00998         memcpy(HRWB_scratch, udprequest.TXDataLen, 1);
00999         if (!HRWBwriteReg(link, HRWB_UDP_TX_LENGTH, HRWB_scratch, 1))
01000           return false;
01001 
01002         if (!HRWBwriteRegMasked(link, HRWB_UDP_STATUS, HRWB_UDP_STATUS_SEND_REQ, HRWB_UDP_STATUS_SEND_REQ))
01003           return false;
01004 
01005         while(!done) {
01006           if (!HRWBreadReg(link, HRWB_UDP_STATUS, 1))
01007             return false;
01008           status = HRWB_I2CReply[0];
01009 
01010           if ((status & HRWB_UDP_STATUS_REQ_ERROR) == HRWB_UDP_STATUS_REQ_ERROR)
01011           {
01012             udprequest.result_code = status;
01013             done = true;
01014           }
01015           else if ((status & HRWB_UDP_STATUS_REQ_DONE) == HRWB_UDP_STATUS_REQ_DONE)
01016           {
01017             udprequest.result_code = status;
01018             done = true;
01019           }
01020           wait1Msec(100);
01021         }
01022 
01023         wait1Msec(100);
01024         if (!HRWBreadReg(link, HRWB_UDP_RX_LENGTH, 1))
01025           return false;
01026   udprequest.RXDataLen = HRWB_I2CReply[0];
01027 
01028   //writeDebugStreamLine("res length: %d", udprequest.RXDataLen);
01029   if (!HRWBreadBigReg(link, HRWB_UDP_RX_DATA, 32))
01030     return false;
01031 
01032   memcpy(&udprequest.RXData[0], &HRWB_HugeArray[0], sizeof(tBigByteArray));
01033 
01034   //writeDebugStreamLine(" ");
01035         return true;
01036 }
01037 
01038 
01039 #endif // __HRWB_H__
01040 
01041 /*
01042  * $Id: humarobotics-wifiblock.h 133 2013-03-10 15:15:38Z xander $
01043  */
01044 /* @} */
01045 /* @} */