From 50073ed5d61a89af95f1497c24965e50e95e6e9d Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 10 May 2014 21:28:40 +0100 Subject: [PATCH] stmhal/cc3k: Remove spaces and tabs at end of lines. --- stmhal/cc3k/cc3000_common.c | 22 +- stmhal/cc3k/cc3000_common.h | 80 +++--- stmhal/cc3k/ccspi.c | 28 +- stmhal/cc3k/ccspi.h | 4 +- stmhal/cc3k/evnt_handler.h | 24 +- stmhal/cc3k/hci.c | 74 ++--- stmhal/cc3k/hci.h | 32 +-- stmhal/cc3k/host_driver_version.h | 16 +- stmhal/cc3k/netapp.c | 168 +++++------ stmhal/cc3k/netapp.h | 102 +++---- stmhal/cc3k/nvmem.c | 144 +++++----- stmhal/cc3k/nvmem.h | 80 +++--- stmhal/cc3k/security.c | 74 ++--- stmhal/cc3k/security.h | 32 +-- stmhal/cc3k/socket.c | 456 +++++++++++++++--------------- stmhal/cc3k/socket.h | 232 +++++++-------- stmhal/cc3k/wlan.h | 202 ++++++------- 17 files changed, 885 insertions(+), 885 deletions(-) diff --git a/stmhal/cc3k/cc3000_common.c b/stmhal/cc3k/cc3000_common.c index 8d9bd7d03a..400b56a9ca 100644 --- a/stmhal/cc3k/cc3000_common.c +++ b/stmhal/cc3k/cc3000_common.c @@ -3,9 +3,9 @@ * cc3000_common.c.c - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -173,7 +173,7 @@ uint16_t STREAM_TO_UINT16_f(char* cp, uint16_t offset) uint32_t STREAM_TO_UINT32_f(char * cp, uint16_t offset) { uint8_t *p = (uint8_t *)cp; - + /* DEBUGPRINT_F("\tStream2u32: "); DEBUGPRINT_HEX(cp[offset+3]); DEBUGPRINT_F(" + "); diff --git a/stmhal/cc3k/cc3000_common.h b/stmhal/cc3k/cc3000_common.h index 4297d249bf..b074cb3e5b 100644 --- a/stmhal/cc3k/cc3000_common.h +++ b/stmhal/cc3k/cc3000_common.h @@ -3,9 +3,9 @@ * cc3000_common.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -70,9 +70,9 @@ extern "C" { //***************************************************************************** // COMMON DEFINES //***************************************************************************** -#define ERROR_SOCKET_INACTIVE -57 +#define ERROR_SOCKET_INACTIVE -57 -#define WLAN_ENABLE (1) +#define WLAN_ENABLE (1) #define WLAN_DISABLE (0) #define MAC_ADDR_LEN (6) @@ -80,8 +80,8 @@ extern "C" { #define SP_PORTION_SIZE (32) // #define CC3000_TINY_DRIVER - -/*Defines for minimal and maximal RX buffer size. This size includes the spi + +/*Defines for minimal and maximal RX buffer size. This size includes the spi header and hci header. The maximal buffer size derives from: MTU + HCI header + SPI header + sendto() agrs size @@ -89,26 +89,26 @@ extern "C" { HCI header + SPI header + max args size This buffer is used for receiving events and data. - The packet can not be longer than MTU size and CC3000 does not support - fragmentation. Note that the same buffer is used for reception of the data - and events from CC3000. That is why the minimum is defined. + The packet can not be longer than MTU size and CC3000 does not support + fragmentation. Note that the same buffer is used for reception of the data + and events from CC3000. That is why the minimum is defined. The calculation for the actual size of buffer for reception is: Given the maximal data size MAX_DATA that is expected to be received by application, the required buffer is: Using recv() or recvfrom(): - + max(CC3000_MINIMAL_RX_SIZE, MAX_DATA + HEADERS_SIZE_DATA + fromlen + ucArgsize + 1) - + Using gethostbyname() with minimal buffer size will limit the host name returned to 99 bytes only. - The 1 is used for the overrun detection + The 1 is used for the overrun detection Buffer size increased to 130 following the add_profile() with WEP security - which requires TX buffer size of 130 bytes: + which requires TX buffer size of 130 bytes: HEADERS_SIZE_EVNT + WLAN_ADD_PROFILE_WEP_PARAM_LEN + MAX SSID LEN + 4 * MAX KEY LEN = 130 - MAX SSID LEN = 32 - MAX SSID LEN = 13 (with add_profile only ascii key setting is supported, + MAX SSID LEN = 32 + MAX SSID LEN = 13 (with add_profile only ascii key setting is supported, therfore maximum key size is 13) */ @@ -117,24 +117,24 @@ extern "C" { /*Defines for minimal and maximal TX buffer size. This buffer is used for sending events and data. - The packet can not be longer than MTU size and CC3000 does not support + The packet can not be longer than MTU size and CC3000 does not support fragmentation. Note that the same buffer is used for transmission of the data and commands. That is why the minimum is defined. The calculation for the actual size of buffer for transmission is: Given the maximal data size MAX_DATA, the required buffer is: Using Sendto(): - + max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE + SOCKET_SENDTO_PARAMS_LEN + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1) - + Using Send(): - + max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE + HCI_CMND_SEND_ARG_LENGTH + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1) - - The 1 is used for the overrun detection */ -#define CC3000_MINIMAL_TX_SIZE (130 + 1) + The 1 is used for the overrun detection */ + +#define CC3000_MINIMAL_TX_SIZE (130 + 1) #define CC3000_MAXIMAL_TX_SIZE (1519 + 1) //TX and RX buffer sizes, allow to receive and transmit maximum data at length 8. @@ -143,26 +143,26 @@ extern "C" { #define TINY_CC3000_MAXIMAL_TX_SIZE 59 #endif -/*In order to determine your preferred buffer size, +/*In order to determine your preferred buffer size, change CC3000_MAXIMAL_RX_SIZE and CC3000_MAXIMAL_TX_SIZE to a value between - the minimal and maximal specified above. + the minimal and maximal specified above. Note that the buffers are allocated by SPI. In case you change the size of those buffers, you might need also to change the linker file, since for example on MSP430 FRAM devices the buffers are allocated in the FRAM section that is allocated manually and not by IDE. */ - + #ifndef CC3000_TINY_DRIVER - + #define CC3000_RX_BUFFER_SIZE (CC3000_MINIMAL_RX_SIZE) #define CC3000_TX_BUFFER_SIZE (CC3000_MINIMAL_TX_SIZE) - + //if defined TINY DRIVER we use smaller RX and TX buffer in order to minimize RAM consumption #else #define CC3000_RX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_RX_SIZE) #define CC3000_TX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_TX_SIZE) -#endif +#endif //***************************************************************************** // Compound Types @@ -177,7 +177,7 @@ typedef long suseconds_t; typedef struct timeval timeval; -struct timeval +struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ @@ -263,7 +263,7 @@ extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams); //! @return none //! //! @brief Wait for data, pass it to the hci_event_handler -//! and update in a global variable that there is +//! and update in a global variable that there is //! data to read. // //***************************************************************************** @@ -295,7 +295,7 @@ extern uint8_t* UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32); //! //! \return pointer to the new stream //! -//! \brief This function is used for copying 16 bit to stream +//! \brief This function is used for copying 16 bit to stream //! while converting to little endian format. // //***************************************************************************** @@ -311,7 +311,7 @@ extern uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16); //! //! \return pointer to the new 16 bit //! -//! \brief This function is used for copying received stream to +//! \brief This function is used for copying received stream to //! 16 bit in little endian format. // //***************************************************************************** diff --git a/stmhal/cc3k/ccspi.c b/stmhal/cc3k/ccspi.c index 133b17d030..359fdaa9b2 100644 --- a/stmhal/cc3k/ccspi.c +++ b/stmhal/cc3k/ccspi.c @@ -3,9 +3,9 @@ * spi.c - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -141,7 +141,7 @@ void SpiInit(void) void SpiClose(void) { DEBUGPRINT_F("\tCC3000: SpiClose"); - + if (sSpiInformation.pRxPacket) { sSpiInformation.pRxPacket = 0; @@ -159,7 +159,7 @@ void SpiClose(void) void SpiOpen(gcSpiHandleRx pfRxHandler) { DEBUGPRINT_F("\tCC3000: SpiOpen"); - + sSpiInformation.ulSpiState = eSPI_STATE_POWERUP; memset(spi_buffer, 0, sizeof(spi_buffer)); @@ -170,7 +170,7 @@ void SpiOpen(gcSpiHandleRx pfRxHandler) sSpiInformation.pTxPacket = NULL; sSpiInformation.pRxPacket = (unsigned char *)spi_buffer; sSpiInformation.usRxPacketLength = 0; - + spi_buffer[CC3000_RX_BUFFER_SIZE - 1] = CC3000_BUFFER_MAGIC_NUMBER; wlan_tx_buffer[CC3000_TX_BUFFER_SIZE - 1] = CC3000_BUFFER_MAGIC_NUMBER; @@ -192,7 +192,7 @@ int init_spi(void) { DEBUGPRINT_F("\tCC3000: init_spi\n\r"); - + /* Set POWER_EN pin to output and disable the CC3000 by default */ pinMode(g_vbatPin, OUTPUT); digitalWrite(g_vbatPin, 0); @@ -214,7 +214,7 @@ int init_spi(void) SPI.setDataMode(SPI_MODE1); SPI.setBitOrder(MSBFIRST); SPI.setClockDivider(g_SPIspeed); - + // Newly-initialized SPI is in the same state that ASSERT_CS will set it // to. Invoke DEASSERT (which also restores SPI registers) so the next // ASSERT call won't clobber the ccspi_old* values -- we need those! @@ -223,7 +223,7 @@ int init_spi(void) /* ToDo: Configure IRQ interrupt! */ DEBUGPRINT_F("\tCC3000: Finished init_spi\n\r"); - + return(ESUCCESS); } #endif @@ -236,7 +236,7 @@ int init_spi(void) long SpiFirstWrite(unsigned char *ucBuf, unsigned short usLength) { DEBUGPRINT_F("\tCC3000: SpiWriteFirst\n\r"); - + /* Workaround for the first transaction */ CC3000_ASSERT_CS(); @@ -268,7 +268,7 @@ long SpiWrite(unsigned char *pUserBuffer, unsigned short usLength) unsigned char ucPad = 0; DEBUGPRINT_F("\tCC3000: SpiWrite\n\r"); - + /* Figure out the total length of the packet in order to figure out if there is padding or not */ if(!(usLength & 0x0001)) { @@ -510,7 +510,7 @@ void SpiTriggerRxProcessing(void) void SSIContReadOperation(void) { DEBUGPRINT_F("\tCC3000: SpiContReadOperation\n\r"); - + /* The header was read - continue with the payload read */ if (!SpiReadDataCont()) { @@ -527,7 +527,7 @@ void SSIContReadOperation(void) */ /**************************************************************************/ void WriteWlanPin( unsigned char val ) -{ +{ #if 0 if (DEBUG_MODE) { @@ -688,7 +688,7 @@ void SPI_IRQ(void) ccspi_is_in_irq = 1; DEBUGPRINT_F("\tCC3000: Entering SPI_IRQ\n\r"); - + if (sSpiInformation.ulSpiState == eSPI_STATE_POWERUP) { /* IRQ line was low ... perform a callback on the HCI Layer */ @@ -697,7 +697,7 @@ void SPI_IRQ(void) else if (sSpiInformation.ulSpiState == eSPI_STATE_IDLE) { //DEBUGPRINT_F("IDLE\n\r"); - sSpiInformation.ulSpiState = eSPI_STATE_READ_IRQ; + sSpiInformation.ulSpiState = eSPI_STATE_READ_IRQ; /* IRQ line goes down - start reception */ CC3000_ASSERT_CS(); diff --git a/stmhal/cc3k/ccspi.h b/stmhal/cc3k/ccspi.h index 70805ec38e..66408a9db5 100644 --- a/stmhal/cc3k/ccspi.h +++ b/stmhal/cc3k/ccspi.h @@ -3,9 +3,9 @@ * spi.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing diff --git a/stmhal/cc3k/evnt_handler.h b/stmhal/cc3k/evnt_handler.h index 1391752bd8..5452d6f121 100644 --- a/stmhal/cc3k/evnt_handler.h +++ b/stmhal/cc3k/evnt_handler.h @@ -3,9 +3,9 @@ * evnt_handler.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -100,7 +100,7 @@ extern long hci_unsol_event_handler(char *event_hdr); //! //! @return ESUCCESS if successful, EFAIL if an error occurred //! -//! @brief Parse the incoming unsolicited event packets and issues +//! @brief Parse the incoming unsolicited event packets and issues //! corresponding event handler. // //***************************************************************************** @@ -126,7 +126,7 @@ typedef struct _bsd_accept_return_t long iSocketDescriptor; long iStatus; sockaddr tSocketAddress; - + } tBsdReturnParams; diff --git a/stmhal/cc3k/hci.c b/stmhal/cc3k/hci.c index 533311f175..f111166074 100644 --- a/stmhal/cc3k/hci.c +++ b/stmhal/cc3k/hci.c @@ -3,9 +3,9 @@ * hci.c - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -76,21 +76,21 @@ //! @brief Initiate an HCI command. // //***************************************************************************** -unsigned short +unsigned short hci_command_send(unsigned short usOpcode, unsigned char *pucBuff, unsigned char ucArgsLength) -{ +{ unsigned char *stream; - + stream = (pucBuff + SPI_HEADER_SIZE); - + UINT8_TO_STREAM(stream, HCI_TYPE_CMND); stream = UINT16_TO_STREAM(stream, usOpcode); UINT8_TO_STREAM(stream, ucArgsLength); - + //Update the opcode of the event we will be waiting for SpiWrite(pucBuff, ucArgsLength + SIMPLE_LINK_HCI_CMND_HEADER_SIZE); - + return(0); } @@ -110,25 +110,25 @@ hci_command_send(unsigned short usOpcode, unsigned char *pucBuff, // //***************************************************************************** long -hci_data_send(unsigned char ucOpcode, +hci_data_send(unsigned char ucOpcode, unsigned char *ucArgs, - unsigned short usArgsLength, + unsigned short usArgsLength, unsigned short usDataLength, const unsigned char *ucTail, unsigned short usTailLength) { unsigned char *stream; - + stream = ((ucArgs) + SPI_HEADER_SIZE); - + UINT8_TO_STREAM(stream, HCI_TYPE_DATA); UINT8_TO_STREAM(stream, ucOpcode); UINT8_TO_STREAM(stream, usArgsLength); stream = UINT16_TO_STREAM(stream, usArgsLength + usDataLength + usTailLength); - + // Send the packet over the SPI SpiWrite(ucArgs, SIMPLE_LINK_HCI_DATA_HEADER_SIZE + usArgsLength + usDataLength + usTailLength); - + return(ESUCCESS); } @@ -149,17 +149,17 @@ hci_data_send(unsigned char ucOpcode, //***************************************************************************** void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuff, unsigned char ucArgsLength,unsigned short ucDataLength) -{ +{ unsigned char *stream = (pucBuff + SPI_HEADER_SIZE); - + UINT8_TO_STREAM(stream, HCI_TYPE_DATA); UINT8_TO_STREAM(stream, usOpcode); UINT8_TO_STREAM(stream, ucArgsLength); stream = UINT16_TO_STREAM(stream, ucArgsLength + ucDataLength); - + // Send the command over SPI on data channel SpiWrite(pucBuff, ucArgsLength + ucDataLength + SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE); - + return; } @@ -169,7 +169,7 @@ void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuff, //! //! @param usOpcode command operation code //! @param pucBuff pointer to the command's arguments buffer -//! @param patch pointer to patch content buffer +//! @param patch pointer to patch content buffer //! @param usDataLength data length //! //! @return none @@ -179,37 +179,37 @@ void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuff, //***************************************************************************** void hci_patch_send(unsigned char ucOpcode, unsigned char *pucBuff, char *patch, unsigned short usDataLength) -{ +{ unsigned char *data_ptr = (pucBuff + SPI_HEADER_SIZE); unsigned short usTransLength; unsigned char *stream = (pucBuff + SPI_HEADER_SIZE); - + UINT8_TO_STREAM(stream, HCI_TYPE_PATCH); UINT8_TO_STREAM(stream, ucOpcode); stream = UINT16_TO_STREAM(stream, usDataLength + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE); - + if (usDataLength <= SL_PATCH_PORTION_SIZE) { UINT16_TO_STREAM(stream, usDataLength); stream = UINT16_TO_STREAM(stream, usDataLength); memcpy((pucBuff + SPI_HEADER_SIZE) + HCI_PATCH_HEADER_SIZE, patch, usDataLength); - + // Update the opcode of the event we will be waiting for SpiWrite(pucBuff, usDataLength + HCI_PATCH_HEADER_SIZE); } else { - + usTransLength = (usDataLength/SL_PATCH_PORTION_SIZE); UINT16_TO_STREAM(stream, usDataLength + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE + usTransLength*SIMPLE_LINK_HCI_PATCH_HEADER_SIZE); stream = UINT16_TO_STREAM(stream, SL_PATCH_PORTION_SIZE); memcpy(pucBuff + SPI_HEADER_SIZE + HCI_PATCH_HEADER_SIZE, patch, SL_PATCH_PORTION_SIZE); usDataLength -= SL_PATCH_PORTION_SIZE; patch += SL_PATCH_PORTION_SIZE; - + // Update the opcode of the event we will be waiting for SpiWrite(pucBuff, SL_PATCH_PORTION_SIZE + HCI_PATCH_HEADER_SIZE); - + while (usDataLength) { cc3k_int_poll(); @@ -218,18 +218,18 @@ hci_patch_send(unsigned char ucOpcode, unsigned char *pucBuff, char *patch, unsi { usTransLength = usDataLength; usDataLength = 0; - + } else { usTransLength = SL_PATCH_PORTION_SIZE; usDataLength -= usTransLength; } - + *(unsigned short *)data_ptr = usTransLength; memcpy(data_ptr + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE, patch, usTransLength); patch += usTransLength; - + // Update the opcode of the event we will be waiting for SpiWrite((unsigned char *)data_ptr, usTransLength + sizeof(usTransLength)); } diff --git a/stmhal/cc3k/hci.h b/stmhal/cc3k/hci.h index 3466a9cfe6..dcbbda5af6 100644 --- a/stmhal/cc3k/hci.h +++ b/stmhal/cc3k/hci.h @@ -3,9 +3,9 @@ * hci.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -175,7 +175,7 @@ extern "C" { #define HCI_EVNT_GETSOCKOPT HCI_CMND_GETSOCKOPT #define HCI_EVNT_BSD_GETHOSTBYNAME HCI_CMND_GETHOSTNAME #define HCI_EVNT_MDNS_ADVERTISE HCI_CMND_MDNS_ADVERTISE - + #define HCI_EVNT_SEND 0x1003 #define HCI_EVNT_WRITE 0x100E #define HCI_EVNT_SENDTO 0x100F @@ -238,8 +238,8 @@ extern "C" { #define HCI_EVENT_LENGTH_OFFSET (3) #define HCI_EVENT_STATUS_OFFSET (4) #define HCI_DATA_LENGTH_OFFSET (3) - - + + //***************************************************************************** @@ -261,10 +261,10 @@ extern "C" { //! @brief Initiate an HCI command. // //***************************************************************************** -extern unsigned short hci_command_send(unsigned short usOpcode, +extern unsigned short hci_command_send(unsigned short usOpcode, unsigned char *ucArgs, unsigned char ucArgsLength); - + //***************************************************************************** // @@ -312,7 +312,7 @@ extern void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuf //! //! @param usOpcode command operation code //! @param pucBuff pointer to the command's arguments buffer -//! @param patch pointer to patch content buffer +//! @param patch pointer to patch content buffer //! @param usDataLength data length //! //! @return none diff --git a/stmhal/cc3k/host_driver_version.h b/stmhal/cc3k/host_driver_version.h index c218704a2e..2a894bbc5f 100644 --- a/stmhal/cc3k/host_driver_version.h +++ b/stmhal/cc3k/host_driver_version.h @@ -12,23 +12,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ diff --git a/stmhal/cc3k/netapp.c b/stmhal/cc3k/netapp.c index cdeccefc46..d5333d235d 100644 --- a/stmhal/cc3k/netapp.c +++ b/stmhal/cc3k/netapp.c @@ -3,9 +3,9 @@ * netapp.c - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -68,13 +68,13 @@ // //! netapp_config_mac_adrress //! -//! @param mac device mac address, 6 bytes. Saved: yes +//! @param mac device mac address, 6 bytes. Saved: yes //! //! @return return on success 0, otherwise error. //! -//! @brief Configure device MAC address and store it in NVMEM. +//! @brief Configure device MAC address and store it in NVMEM. //! The value of the MAC address configured through the API will -//! be stored in CC3000 non volatile memory, thus preserved +//! be stored in CC3000 non volatile memory, thus preserved //! over resets. // //***************************************************************************** @@ -87,26 +87,26 @@ long netapp_config_mac_adrress(unsigned char * mac) // //! netapp_dhcp //! -//! @param aucIP device mac address, 6 bytes. Saved: yes -//! @param aucSubnetMask device mac address, 6 bytes. Saved: yes -//! @param aucDefaultGateway device mac address, 6 bytes. Saved: yes -//! @param aucDNSServer device mac address, 6 bytes. Saved: yes +//! @param aucIP device mac address, 6 bytes. Saved: yes +//! @param aucSubnetMask device mac address, 6 bytes. Saved: yes +//! @param aucDefaultGateway device mac address, 6 bytes. Saved: yes +//! @param aucDNSServer device mac address, 6 bytes. Saved: yes //! //! @return return on success 0, otherwise error. //! -//! @brief netapp_dhcp is used to configure the network interface, -//! static or dynamic (DHCP).\n In order to activate DHCP mode, +//! @brief netapp_dhcp is used to configure the network interface, +//! static or dynamic (DHCP).\n In order to activate DHCP mode, //! aucIP, aucSubnetMask, aucDefaultGateway must be 0. //! The default mode of CC3000 is DHCP mode. //! Note that the configuration is saved in non volatile memory //! and thus preserved over resets. -//! -//! @note If the mode is altered a reset of CC3000 device is required -//! in order to apply changes.\nAlso note that asynchronous event -//! of DHCP_EVENT, which is generated when an IP address is -//! allocated either by the DHCP server or due to static -//! allocation is generated only upon a connection to the -//! AP was established. +//! +//! @note If the mode is altered a reset of CC3000 device is required +//! in order to apply changes.\nAlso note that asynchronous event +//! of DHCP_EVENT, which is generated when an IP address is +//! allocated either by the DHCP server or due to static +//! allocation is generated only upon a connection to the +//! AP was established. //! //***************************************************************************** long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned long *aucDefaultGateway, unsigned long *aucDNSServer) @@ -114,24 +114,24 @@ long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned lon signed char scRet; unsigned char *ptr; unsigned char *args; - + scRet = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in temporary command buffer ARRAY_TO_STREAM(args,aucIP,4); ARRAY_TO_STREAM(args,aucSubnetMask,4); ARRAY_TO_STREAM(args,aucDefaultGateway,4); args = UINT32_TO_STREAM(args, 0); ARRAY_TO_STREAM(args,aucDNSServer,4); - + // Initiate a HCI command hci_command_send(HCI_NETAPP_DHCP, ptr, NETAPP_DHCP_PARAMS_LEN); - + // Wait for command complete event SimpleLinkWaitEvent(HCI_NETAPP_DHCP, &scRet); - + return(scRet); } @@ -140,22 +140,22 @@ long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned lon // //! netapp_timeout_values //! -//! @param aucDHCP DHCP lease time request, also impact +//! @param aucDHCP DHCP lease time request, also impact //! the DHCP renew timeout. Range: [0-0xffffffff] seconds, //! 0 or 0xffffffff == infinity lease timeout. -//! Resolution:10 seconds. Influence: only after -//! reconnecting to the AP. +//! Resolution:10 seconds. Influence: only after +//! reconnecting to the AP. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds. -//! The parameter is saved into the CC3000 NVMEM. +//! The parameter is saved into the CC3000 NVMEM. //! The default value on CC3000 is 14400 seconds. -//! +//! //! @param aucARP ARP refresh timeout, if ARP entry is not updated by //! incoming packet, the ARP entry will be deleted by -//! the end of the timeout. +//! the end of the timeout. //! Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout //! Resolution: 10 seconds. Influence: on runtime. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds -//! The parameter is saved into the CC3000 NVMEM. +//! The parameter is saved into the CC3000 NVMEM. //! The default value on CC3000 is 3600 seconds. //! //! @param aucKeepalive Keepalive event sent by the end of keepalive timeout @@ -163,7 +163,7 @@ long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned lon //! Resolution: 10 seconds. //! Influence: on runtime. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec -//! The parameter is saved into the CC3000 NVMEM. +//! The parameter is saved into the CC3000 NVMEM. //! The default value on CC3000 is 10 seconds. //! //! @param aucInactivity Socket inactivity timeout, socket timeout is @@ -172,50 +172,50 @@ long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned lon //! Range: [0-0xffffffff] sec, 0 == infinity timeout. //! Resolution: 10 seconds. Influence: on runtime. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec -//! The parameter is saved into the CC3000 NVMEM. +//! The parameter is saved into the CC3000 NVMEM. //! The default value on CC3000 is 60 seconds. //! //! @return return on success 0, otherwise error. //! -//! @brief Set new timeout values. Function set new timeout values for: -//! DHCP lease timeout, ARP refresh timeout, keepalive event -//! timeout and socket inactivity timeout -//! +//! @brief Set new timeout values. Function set new timeout values for: +//! DHCP lease timeout, ARP refresh timeout, keepalive event +//! timeout and socket inactivity timeout +//! //! @note If a parameter set to non zero value which is less than 20s, //! it will be set automatically to 20s. //! //***************************************************************************** #ifndef CC3000_TINY_DRIVER -long +long netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP,unsigned long *aucKeepalive, unsigned long *aucInactivity) { signed char scRet; unsigned char *ptr; unsigned char *args; - + scRet = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - - // Set minimal values of timers + + // Set minimal values of timers MIN_TIMER_SET(*aucDHCP) MIN_TIMER_SET(*aucARP) MIN_TIMER_SET(*aucKeepalive) MIN_TIMER_SET(*aucInactivity) - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, *aucDHCP); args = UINT32_TO_STREAM(args, *aucARP); args = UINT32_TO_STREAM(args, *aucKeepalive); args = UINT32_TO_STREAM(args, *aucInactivity); - + // Initiate a HCI command hci_command_send(HCI_NETAPP_SET_TIMERS, ptr, NETAPP_SET_TIMER_PARAMS_LEN); - + // Wait for command complete event SimpleLinkWaitEvent(HCI_NETAPP_SET_TIMERS, &scRet); - + return(scRet); } #endif @@ -227,18 +227,18 @@ netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP,unsigned lon //! //! @param ip destination IP address //! @param pingAttempts number of echo requests to send -//! @param pingSize send buffer size which may be up to 1400 bytes +//! @param pingSize send buffer size which may be up to 1400 bytes //! @param pingTimeout Time to wait for a response,in milliseconds. //! //! @return return on success 0, otherwise error. //! -//! @brief send ICMP ECHO_REQUEST to network hosts -//! -//! @note If an operation finished successfully asynchronous ping report +//! @brief send ICMP ECHO_REQUEST to network hosts +//! +//! @note If an operation finished successfully asynchronous ping report //! event will be generated. The report structure is as defined //! by structure netapp_pingreport_args_t. //! -//! @warning Calling this function while a previous Ping Requests are in +//! @warning Calling this function while a previous Ping Requests are in //! progress will stop the previous ping request. //***************************************************************************** @@ -248,11 +248,11 @@ netapp_ping_send(uint32_t *ip, uint32_t ulPingAttempts, uint32_t ulPingSize, uin { signed char scRet; unsigned char *ptr, *args; - + scRet = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, *ip); args = UINT32_TO_STREAM(args, ulPingAttempts); @@ -270,10 +270,10 @@ netapp_ping_send(uint32_t *ip, uint32_t ulPingAttempts, uint32_t ulPingSize, uin // Initiate a HCI command hci_command_send(HCI_NETAPP_PING_SEND, ptr, NETAPP_PING_SEND_PARAMS_LEN); - + // Wait for command complete event SimpleLinkWaitEvent(HCI_NETAPP_PING_SEND, &scRet); - + return(scRet); } #endif @@ -286,7 +286,7 @@ netapp_ping_send(uint32_t *ip, uint32_t ulPingAttempts, uint32_t ulPingSize, uin //! //! @return none //! -//! @brief Request for ping status. This API triggers the CC3000 to send +//! @brief Request for ping status. This API triggers the CC3000 to send //! asynchronous events: HCI_EVNT_WLAN_ASYNC_PING_REPORT. //! This event will carry the report structure: //! netapp_pingreport_args_t. This structure is filled in with ping @@ -295,8 +295,8 @@ netapp_ping_send(uint32_t *ip, uint32_t ulPingAttempts, uint32_t ulPingSize, uin //! packets_received - echo reply, min_round_time - minimum //! round time, max_round_time - max round time, //! avg_round_time - average round time -//! -//! @note When a ping operation is not active, the returned structure +//! +//! @note When a ping operation is not active, the returned structure //! fields are 0. //! //***************************************************************************** @@ -308,14 +308,14 @@ void netapp_ping_report() unsigned char *ptr; ptr = tSLInformation.pucTxCommandBuffer; signed char scRet; - + scRet = EFAIL; - + // Initiate a HCI command hci_command_send(HCI_NETAPP_PING_REPORT, ptr, 0); - + // Wait for command complete event - SimpleLinkWaitEvent(HCI_NETAPP_PING_REPORT, &scRet); + SimpleLinkWaitEvent(HCI_NETAPP_PING_REPORT, &scRet); } #endif @@ -325,10 +325,10 @@ void netapp_ping_report() //! //! @param none //! -//! @return On success, zero is returned. On error, -1 is returned. +//! @return On success, zero is returned. On error, -1 is returned. //! //! @brief Stop any ping request. -//! +//! //! //***************************************************************************** @@ -337,16 +337,16 @@ long netapp_ping_stop() { signed char scRet; unsigned char *ptr; - + scRet = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; - + // Initiate a HCI command hci_command_send(HCI_NETAPP_PING_STOP, ptr, 0); - + // Wait for command complete event SimpleLinkWaitEvent(HCI_NETAPP_PING_STOP, &scRet); - + return(scRet); } #endif @@ -355,7 +355,7 @@ long netapp_ping_stop() // //! netapp_ipconfig //! -//! @param[out] ipconfig This argument is a pointer to a +//! @param[out] ipconfig This argument is a pointer to a //! tNetappIpconfigRetArgs structure. This structure is //! filled in with the network interface configuration. //! tNetappIpconfigRetArgs:\n aucIP - ip address, @@ -370,7 +370,7 @@ long netapp_ping_stop() //! Note that the information is available only after the WLAN //! connection was established. Calling this function before //! associated, will cause non-defined values to be returned. -//! +//! //! @note The function is useful for figuring out the IP Configuration of //! the device when DHCP is used and for figuring out the SSID of //! the Wireless network the device is associated with. @@ -381,15 +381,15 @@ long netapp_ping_stop() void netapp_ipconfig( tNetappIpconfigRetArgs * ipconfig ) { unsigned char *ptr; - + ptr = tSLInformation.pucTxCommandBuffer; - + // Initiate a HCI command hci_command_send(HCI_NETAPP_IPCONFIG, ptr, 0); - + // Wait for command complete event SimpleLinkWaitEvent(HCI_NETAPP_IPCONFIG, ipconfig ); - + } #else void netapp_ipconfig( tNetappIpconfigRetArgs * ipconfig ) @@ -415,16 +415,16 @@ long netapp_arp_flush(void) { signed char scRet; unsigned char *ptr; - + scRet = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; - + // Initiate a HCI command hci_command_send(HCI_NETAPP_ARP_FLUSH, ptr, 0); - + // Wait for command complete event SimpleLinkWaitEvent(HCI_NETAPP_ARP_FLUSH, &scRet); - + return(scRet); } #endif diff --git a/stmhal/cc3k/netapp.h b/stmhal/cc3k/netapp.h index 747ae64ede..a3b33a386a 100644 --- a/stmhal/cc3k/netapp.h +++ b/stmhal/cc3k/netapp.h @@ -3,9 +3,9 @@ * netapp.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -96,13 +96,13 @@ typedef struct _netapp_pingreport_args // //! netapp_config_mac_adrress //! -//! @param mac device mac address, 6 bytes. Saved: yes +//! @param mac device mac address, 6 bytes. Saved: yes //! //! @return return on success 0, otherwise error. //! -//! @brief Configure device MAC address and store it in NVMEM. +//! @brief Configure device MAC address and store it in NVMEM. //! The value of the MAC address configured through the API will -//! be stored in CC3000 non volatile memory, thus preserved +//! be stored in CC3000 non volatile memory, thus preserved //! over resets. // //***************************************************************************** @@ -112,26 +112,26 @@ extern long netapp_config_mac_adrress( unsigned char *mac ); // //! netapp_dhcp //! -//! @param aucIP device mac address, 6 bytes. Saved: yes -//! @param aucSubnetMask device mac address, 6 bytes. Saved: yes -//! @param aucDefaultGateway device mac address, 6 bytes. Saved: yes -//! @param aucDNSServer device mac address, 6 bytes. Saved: yes +//! @param aucIP device mac address, 6 bytes. Saved: yes +//! @param aucSubnetMask device mac address, 6 bytes. Saved: yes +//! @param aucDefaultGateway device mac address, 6 bytes. Saved: yes +//! @param aucDNSServer device mac address, 6 bytes. Saved: yes //! //! @return return on success 0, otherwise error. //! -//! @brief netapp_dhcp is used to configure the network interface, -//! static or dynamic (DHCP).\n In order to activate DHCP mode, +//! @brief netapp_dhcp is used to configure the network interface, +//! static or dynamic (DHCP).\n In order to activate DHCP mode, //! aucIP, aucSubnetMask, aucDefaultGateway must be 0. //! The default mode of CC3000 is DHCP mode. //! Note that the configuration is saved in non volatile memory //! and thus preserved over resets. -//! -//! @note If the mode is altered a reset of CC3000 device is required -//! in order to apply changes.\nAlso note that asynchronous event -//! of DHCP_EVENT, which is generated when an IP address is -//! allocated either by the DHCP server or due to static -//! allocation is generated only upon a connection to the -//! AP was established. +//! +//! @note If the mode is altered a reset of CC3000 device is required +//! in order to apply changes.\nAlso note that asynchronous event +//! of DHCP_EVENT, which is generated when an IP address is +//! allocated either by the DHCP server or due to static +//! allocation is generated only upon a connection to the +//! AP was established. //! //***************************************************************************** extern long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned long *aucDefaultGateway, unsigned long *aucDNSServer); @@ -142,22 +142,22 @@ extern long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsi // //! netapp_timeout_values //! -//! @param aucDHCP DHCP lease time request, also impact +//! @param aucDHCP DHCP lease time request, also impact //! the DHCP renew timeout. Range: [0-0xffffffff] seconds, //! 0 or 0xffffffff == infinity lease timeout. -//! Resolution:10 seconds. Influence: only after -//! reconnecting to the AP. +//! Resolution:10 seconds. Influence: only after +//! reconnecting to the AP. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds. -//! The parameter is saved into the CC3000 NVMEM. +//! The parameter is saved into the CC3000 NVMEM. //! The default value on CC3000 is 14400 seconds. -//! +//! //! @param aucARP ARP refresh timeout, if ARP entry is not updated by //! incoming packet, the ARP entry will be deleted by -//! the end of the timeout. +//! the end of the timeout. //! Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout //! Resolution: 10 seconds. Influence: on runtime. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds -//! The parameter is saved into the CC3000 NVMEM. +//! The parameter is saved into the CC3000 NVMEM. //! The default value on CC3000 is 3600 seconds. //! //! @param aucKeepalive Keepalive event sent by the end of keepalive timeout @@ -165,7 +165,7 @@ extern long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsi //! Resolution: 10 seconds. //! Influence: on runtime. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec -//! The parameter is saved into the CC3000 NVMEM. +//! The parameter is saved into the CC3000 NVMEM. //! The default value on CC3000 is 10 seconds. //! //! @param aucInactivity Socket inactivity timeout, socket timeout is @@ -174,15 +174,15 @@ extern long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsi //! Range: [0-0xffffffff] sec, 0 == infinity timeout. //! Resolution: 10 seconds. Influence: on runtime. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec -//! The parameter is saved into the CC3000 NVMEM. +//! The parameter is saved into the CC3000 NVMEM. //! The default value on CC3000 is 60 seconds. //! //! @return return on success 0, otherwise error. //! -//! @brief Set new timeout values. Function set new timeout values for: -//! DHCP lease timeout, ARP refresh timeout, keepalive event -//! timeout and socket inactivity timeout -//! +//! @brief Set new timeout values. Function set new timeout values for: +//! DHCP lease timeout, ARP refresh timeout, keepalive event +//! timeout and socket inactivity timeout +//! //! @note If a parameter set to non zero value which is less than 20s, //! it will be set automatically to 20s. //! @@ -197,18 +197,18 @@ extern long netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP, //! //! @param ip destination IP address //! @param pingAttempts number of echo requests to send -//! @param pingSize send buffer size which may be up to 1400 bytes +//! @param pingSize send buffer size which may be up to 1400 bytes //! @param pingTimeout Time to wait for a response,in milliseconds. //! //! @return return on success 0, otherwise error. //! -//! @brief send ICMP ECHO_REQUEST to network hosts -//! -//! @note If an operation finished successfully asynchronous ping report +//! @brief send ICMP ECHO_REQUEST to network hosts +//! +//! @note If an operation finished successfully asynchronous ping report //! event will be generated. The report structure is as defined //! by structure netapp_pingreport_args_t. //! -//! @warning Calling this function while a previous Ping Requests are in +//! @warning Calling this function while a previous Ping Requests are in //! progress will stop the previous ping request. //***************************************************************************** @@ -222,10 +222,10 @@ extern long netapp_ping_send(uint32_t *ip, uint32_t ulPingAttempts, uint32_t ulP //! //! @param none //! -//! @return On success, zero is returned. On error, -1 is returned. +//! @return On success, zero is returned. On error, -1 is returned. //! //! @brief Stop any ping request. -//! +//! //! //***************************************************************************** @@ -240,7 +240,7 @@ extern long netapp_ping_stop(); //! //! @return none //! -//! @brief Request for ping status. This API triggers the CC3000 to send +//! @brief Request for ping status. This API triggers the CC3000 to send //! asynchronous events: HCI_EVNT_WLAN_ASYNC_PING_REPORT. //! This event will carry the report structure: //! netapp_pingreport_args_t. This structure is filled in with ping @@ -249,8 +249,8 @@ extern long netapp_ping_stop(); //! packets_received - echo reply, min_round_time - minimum //! round time, max_round_time - max round time, //! avg_round_time - average round time -//! -//! @note When a ping operation is not active, the returned structure +//! +//! @note When a ping operation is not active, the returned structure //! fields are 0. //! //***************************************************************************** @@ -263,7 +263,7 @@ extern void netapp_ping_report(); // //! netapp_ipconfig //! -//! @param[out] ipconfig This argument is a pointer to a +//! @param[out] ipconfig This argument is a pointer to a //! tNetappIpconfigRetArgs structure. This structure is //! filled in with the network interface configuration. //! tNetappIpconfigRetArgs:\n aucIP - ip address, @@ -278,7 +278,7 @@ extern void netapp_ping_report(); //! Note that the information is available only after the WLAN //! connection was established. Calling this function before //! associated, will cause non-defined values to be returned. -//! +//! //! @note The function is useful for figuring out the IP Configuration of //! the device when DHCP is used and for figuring out the SSID of //! the Wireless network the device is associated with. diff --git a/stmhal/cc3k/nvmem.c b/stmhal/cc3k/nvmem.c index 774759c41f..9da95f5d0b 100644 --- a/stmhal/cc3k/nvmem.c +++ b/stmhal/cc3k/nvmem.c @@ -3,9 +3,9 @@ * nvmem.c - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -82,45 +82,45 @@ //! NVMEM_IP_CONFIG_FILEID, NVMEM_IP_CONFIG_SHADOW_FILEID, //! NVMEM_BOOTLOADER_SP_FILEID, NVMEM_RM_FILEID, //! and user files 12-15. -//! @param ulLength number of bytes to read -//! @param ulOffset ulOffset in file from where to read +//! @param ulLength number of bytes to read +//! @param ulOffset ulOffset in file from where to read //! @param buff output buffer pointer //! //! @return number of bytes read, otherwise error. //! -//! @brief Reads data from the file referred by the ulFileId parameter. +//! @brief Reads data from the file referred by the ulFileId parameter. //! Reads data from file ulOffset till length. Err if the file can't -//! be used, is invalid, or if the read is out of bounds. -//! +//! be used, is invalid, or if the read is out of bounds. +//! //***************************************************************************** -signed long +signed long nvmem_read(unsigned long ulFileId, unsigned long ulLength, unsigned long ulOffset, unsigned char *buff) { unsigned char ucStatus = 0xFF; unsigned char *ptr; unsigned char *args; - + ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in HCI packet structure args = UINT32_TO_STREAM(args, ulFileId); args = UINT32_TO_STREAM(args, ulLength); args = UINT32_TO_STREAM(args, ulOffset); - + // Initiate a HCI command hci_command_send(HCI_CMND_NVMEM_READ, ptr, NVMEM_READ_PARAMS_LEN); SimpleLinkWaitEvent(HCI_CMND_NVMEM_READ, &ucStatus); - + // In case there is data - read it - even if an error code is returned // Note: It is the user responsibility to ignore the data in case of an error code - - // Wait for the data in a synchronous way. Here we assume that the buffer is + + // Wait for the data in a synchronous way. Here we assume that the buffer is // big enough to store also parameters of nvmem - + SimpleLinkWaitData(buff, 0, 0); - + return(ucStatus); } @@ -132,40 +132,40 @@ nvmem_read(unsigned long ulFileId, unsigned long ulLength, unsigned long ulOffse //! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, //! NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID, //! and user files 12-15. -//! @param ulLength number of bytes to write -//! @param ulEntryOffset offset in file to start write operation from +//! @param ulLength number of bytes to write +//! @param ulEntryOffset offset in file to start write operation from //! @param buff data to write //! //! @return on success 0, error otherwise. //! //! @brief Write data to nvmem. -//! writes data to file referred by the ulFileId parameter. -//! Writes data to file ulOffset till ulLength.The file id will be +//! writes data to file referred by the ulFileId parameter. +//! Writes data to file ulOffset till ulLength.The file id will be //! marked invalid till the write is done. The file entry doesn't //! need to be valid - only allocated. -//! +//! //***************************************************************************** -signed long -nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long +signed long +nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long ulEntryOffset, unsigned char *buff) { long iRes; unsigned char *ptr; unsigned char *args; - + iRes = EFAIL; - + ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE); - + // Fill in HCI packet structure args = UINT32_TO_STREAM(args, ulFileId); args = UINT32_TO_STREAM(args, 12); args = UINT32_TO_STREAM(args, ulLength); args = UINT32_TO_STREAM(args, ulEntryOffset); - - memcpy((ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE + + + memcpy((ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE + NVMEM_WRITE_PARAMS_LEN),buff,ulLength); #if (DEBUG_MODE == 1) PRINT_F("Writing:\t"); @@ -179,9 +179,9 @@ nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long // Initiate a HCI command but it will come on data channel hci_data_command_send(HCI_CMND_NVMEM_WRITE, ptr, NVMEM_WRITE_PARAMS_LEN, ulLength); - + SimpleLinkWaitEvent(HCI_EVNT_NVMEM_WRITE, &iRes); - + return(iRes); } @@ -194,9 +194,9 @@ nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long //! //! @return on success 0, error otherwise. //! -//! @brief Write MAC address to EEPROM. +//! @brief Write MAC address to EEPROM. //! mac address as appears over the air (OUI first) -//! +//! //***************************************************************************** unsigned char nvmem_set_mac_address(unsigned char *mac) @@ -208,13 +208,13 @@ unsigned char nvmem_set_mac_address(unsigned char *mac) // //! nvmem_get_mac_address //! -//! @param[out] mac mac address +//! @param[out] mac mac address //! //! @return on success 0, error otherwise. //! -//! @brief Read MAC address from EEPROM. +//! @brief Read MAC address from EEPROM. //! mac address as appears over the air (OUI first) -//! +//! //***************************************************************************** unsigned char nvmem_get_mac_address(unsigned char *mac) @@ -228,16 +228,16 @@ unsigned char nvmem_get_mac_address(unsigned char *mac) //! //! @param ulFileId nvmem file id:\n //! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, -//! @param spLength number of bytes to write +//! @param spLength number of bytes to write //! @param spData SP data to write //! //! @return on success 0, error otherwise. //! -//! @brief program a patch to a specific file ID. +//! @brief program a patch to a specific file ID. //! The SP data is assumed to be organized in 2-dimensional. -//! Each line is SP_PORTION_SIZE bytes long. Actual programming is +//! Each line is SP_PORTION_SIZE bytes long. Actual programming is //! applied in SP_PORTION_SIZE bytes portions. -//! +//! //***************************************************************************** unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, const uint8_t *spData) @@ -262,19 +262,19 @@ unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, spLength -= SP_PORTION_SIZE; spDataPtr += SP_PORTION_SIZE; } - + if (status !=0) { // NVMEM error occurred return status; } - + if (spLength != 0) { // if reached here, a reminder is left status = nvmem_write(ulFileId, spLength, offset, spDataPtr); } - + return status; } @@ -282,14 +282,14 @@ unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, // //! nvmem_read_sp_version //! -//! @param[out] patchVer first number indicates package ID and the second -//! number indicates package build number +//! @param[out] patchVer first number indicates package ID and the second +//! number indicates package build number //! //! @return on success 0, error otherwise. //! -//! @brief Read patch version. read package version (WiFi FW patch, +//! @brief Read patch version. read package version (WiFi FW patch, //! driver-supplicant-NS patch, bootloader patch) -//! +//! //***************************************************************************** #ifndef CC3000_TINY_DRIVER @@ -297,19 +297,19 @@ uint8_t nvmem_read_sp_version(uint8_t* patchVer) { uint8_t *ptr; // 1st byte is the status and the rest is the SP version - uint8_t retBuf[5]; - + uint8_t retBuf[5]; + ptr = tSLInformation.pucTxCommandBuffer; - + // Initiate a HCI command, no args are required - hci_command_send(HCI_CMND_READ_SP_VERSION, ptr, 0); + hci_command_send(HCI_CMND_READ_SP_VERSION, ptr, 0); SimpleLinkWaitEvent(HCI_CMND_READ_SP_VERSION, retBuf); - + // package ID - *patchVer = retBuf[3]; + *patchVer = retBuf[3]; // package build number - *(patchVer+1) = retBuf[4]; - + *(patchVer+1) = retBuf[4]; + return(retBuf[0]); } #endif @@ -322,38 +322,38 @@ uint8_t nvmem_read_sp_version(uint8_t* patchVer) //! * NVMEM_AES128_KEY_FILEID: 12 //! * NVMEM_SHARED_MEM_FILEID: 13 //! * and fileIDs 14 and 15 -//! @param ulNewLen entry ulLength +//! @param ulNewLen entry ulLength //! //! @return on success 0, error otherwise. //! -//! @brief Create new file entry and allocate space on the NVMEM. +//! @brief Create new file entry and allocate space on the NVMEM. //! Applies only to user files. //! Modify the size of file. -//! If the entry is unallocated - allocate it to size +//! If the entry is unallocated - allocate it to size //! ulNewLen (marked invalid). //! If it is allocated then deallocate it first. -//! To just mark the file as invalid without resizing - +//! To just mark the file as invalid without resizing - //! set ulNewLen=0. -//! +//! //***************************************************************************** int8_t nvmem_create_entry(unsigned long ulFileId, unsigned long ulNewLen) { - unsigned char *ptr; + unsigned char *ptr; unsigned char *args; int8_t retval; - + ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in HCI packet structure args = UINT32_TO_STREAM(args, ulFileId); args = UINT32_TO_STREAM(args, ulNewLen); - + // Initiate a HCI command hci_command_send(HCI_CMND_NVMEM_CREATE_ENTRY,ptr, NVMEM_CREATE_PARAMS_LEN); - + SimpleLinkWaitEvent(HCI_CMND_NVMEM_CREATE_ENTRY, &retval); return(retval); } diff --git a/stmhal/cc3k/nvmem.h b/stmhal/cc3k/nvmem.h index 8a035f5608..a95e9e3bc2 100644 --- a/stmhal/cc3k/nvmem.h +++ b/stmhal/cc3k/nvmem.h @@ -3,9 +3,9 @@ * nvmem.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -67,7 +67,7 @@ extern "C" { /**************************************************************************** ** ** Definitions for File IDs -** +** ****************************************************************************/ /* NVMEM file ID - system files*/ #define NVMEM_NVS_FILEID (0) @@ -103,16 +103,16 @@ extern "C" { //! NVMEM_IP_CONFIG_FILEID, NVMEM_IP_CONFIG_SHADOW_FILEID, //! NVMEM_BOOTLOADER_SP_FILEID, NVMEM_RM_FILEID, //! and user files 12-15. -//! @param ulLength number of bytes to read -//! @param ulOffset ulOffset in file from where to read +//! @param ulLength number of bytes to read +//! @param ulOffset ulOffset in file from where to read //! @param buff output buffer pointer //! //! @return number of bytes read, otherwise error. //! -//! @brief Reads data from the file referred by the ulFileId parameter. +//! @brief Reads data from the file referred by the ulFileId parameter. //! Reads data from file ulOffset till length. Err if the file can't -//! be used, is invalid, or if the read is out of bounds. -//! +//! be used, is invalid, or if the read is out of bounds. +//! //***************************************************************************** extern signed long nvmem_read(unsigned long file_id, unsigned long length, unsigned long offset, unsigned char *buff); @@ -125,18 +125,18 @@ extern signed long nvmem_read(unsigned long file_id, unsigned long length, unsig //! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, //! NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID, //! and user files 12-15. -//! @param ulLength number of bytes to write -//! @param ulEntryOffset offset in file to start write operation from +//! @param ulLength number of bytes to write +//! @param ulEntryOffset offset in file to start write operation from //! @param buff data to write //! //! @return on success 0, error otherwise. //! //! @brief Write data to nvmem. -//! writes data to file referred by the ulFileId parameter. -//! Writes data to file ulOffset till ulLength.The file id will be +//! writes data to file referred by the ulFileId parameter. +//! Writes data to file ulOffset till ulLength.The file id will be //! marked invalid till the write is done. The file entry doesn't //! need to be valid - only allocated. -//! +//! //***************************************************************************** extern signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long ulEntryOffset, unsigned char *buff); @@ -150,9 +150,9 @@ extern signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength, u //! //! @return on success 0, error otherwise. //! -//! @brief Write MAC address to EEPROM. +//! @brief Write MAC address to EEPROM. //! mac address as appears over the air (OUI first) -//! +//! //***************************************************************************** extern unsigned char nvmem_set_mac_address(unsigned char *mac); @@ -161,13 +161,13 @@ extern unsigned char nvmem_set_mac_address(unsigned char *mac); // //! nvmem_get_mac_address //! -//! @param[out] mac mac address +//! @param[out] mac mac address //! //! @return on success 0, error otherwise. //! -//! @brief Read MAC address from EEPROM. +//! @brief Read MAC address from EEPROM. //! mac address as appears over the air (OUI first) -//! +//! //***************************************************************************** extern unsigned char nvmem_get_mac_address(unsigned char *mac); @@ -178,16 +178,16 @@ extern unsigned char nvmem_get_mac_address(unsigned char *mac); //! //! @param ulFileId nvmem file id:\n //! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, -//! @param spLength number of bytes to write +//! @param spLength number of bytes to write //! @param spData SP data to write //! //! @return on success 0, error otherwise. //! -//! @brief program a patch to a specific file ID. +//! @brief program a patch to a specific file ID. //! The SP data is assumed to be organized in 2-dimensional. -//! Each line is SP_PORTION_SIZE bytes long. Actual programming is +//! Each line is SP_PORTION_SIZE bytes long. Actual programming is //! applied in SP_PORTION_SIZE bytes portions. -//! +//! //***************************************************************************** extern unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, const unsigned char *spData); @@ -196,16 +196,16 @@ extern unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spL // //! nvmem_read_sp_version //! -//! @param[out] patchVer first number indicates package ID and the second -//! number indicates package build number +//! @param[out] patchVer first number indicates package ID and the second +//! number indicates package build number //! //! @return on success 0, error otherwise. //! -//! @brief Read patch version. read package version (WiFi FW patch, +//! @brief Read patch version. read package version (WiFi FW patch, //! driver-supplicant-NS patch, bootloader patch) -//! +//! //***************************************************************************** -#ifndef CC3000_TINY_DRIVER +#ifndef CC3000_TINY_DRIVER extern unsigned char nvmem_read_sp_version(unsigned char* patchVer); #endif @@ -217,19 +217,19 @@ extern unsigned char nvmem_read_sp_version(unsigned char* patchVer); //! * NVMEM_AES128_KEY_FILEID: 12 //! * NVMEM_SHARED_MEM_FILEID: 13 //! * and fileIDs 14 and 15 -//! @param ulNewLen entry ulLength +//! @param ulNewLen entry ulLength //! //! @return on success 0, error otherwise. //! -//! @brief Create new file entry and allocate space on the NVMEM. +//! @brief Create new file entry and allocate space on the NVMEM. //! Applies only to user files. //! Modify the size of file. -//! If the entry is unallocated - allocate it to size +//! If the entry is unallocated - allocate it to size //! ulNewLen (marked invalid). //! If it is allocated then deallocate it first. -//! To just mark the file as invalid without resizing - +//! To just mark the file as invalid without resizing - //! set ulNewLen=0. -//! +//! //***************************************************************************** extern int8_t nvmem_create_entry(unsigned long file_id, unsigned long newlen); diff --git a/stmhal/cc3k/security.c b/stmhal/cc3k/security.c index c52d7f67e6..dfd8d94322 100644 --- a/stmhal/cc3k/security.c +++ b/stmhal/cc3k/security.c @@ -12,23 +12,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -49,7 +49,7 @@ #ifndef CC3000_UNENCRYPTED_SMART_CONFIG // foreward sbox -const unsigned char sbox[256] = { +const unsigned char sbox[256] = { //0 1 2 3 4 5 6 7 8 9 A B C D E F 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, //0 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, //1 @@ -66,7 +66,7 @@ const unsigned char sbox[256] = { 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //C 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E -0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F +0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F // inverse sbox const unsigned char rsbox[256] = { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb @@ -130,7 +130,7 @@ void expandKey(unsigned char *expandedKey, expandedKey[ii*16 +14] = expandedKey[(ii-1)*16 +14]^expandedKey[ii*16 +10]; expandedKey[ii*16 +15] = expandedKey[(ii-1)*16 +15]^expandedKey[ii*16 +11]; } - + } //***************************************************************************** @@ -171,18 +171,18 @@ unsigned char galois_mul2(unsigned char value) //! - subbytes //! - shiftrows //! - mixcolums -//! is executed 9 times, after this addroundkey to finish the 9th +//! is executed 9 times, after this addroundkey to finish the 9th //! round, after that the 10th round without mixcolums //! no further subfunctions to save cycles for function calls //! no structuring with "for (....)" to save cycles. -//! +//! //! //***************************************************************************** void aes_encr(unsigned char *state, unsigned char *expandedKey) { unsigned char buf1, buf2, buf3, round; - + for (round = 0; round < 9; round ++){ // addroundkey, sbox and shiftrows // row 0 @@ -209,7 +209,7 @@ void aes_encr(unsigned char *state, unsigned char *expandedKey) state[11] = sbox[(state[ 7] ^ expandedKey[(round*16) + 7])]; state[ 7] = sbox[(state[ 3] ^ expandedKey[(round*16) + 3])]; state[ 3] = sbox[buf1]; - + // mixcolums ////////// // col1 buf1 = state[0] ^ state[1] ^ state[2] ^ state[3]; @@ -238,8 +238,8 @@ void aes_encr(unsigned char *state, unsigned char *expandedKey) buf3 = state[12]^state[13]; buf3=galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1; buf3 = state[13]^state[14]; buf3=galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1; buf3 = state[14]^state[15]; buf3=galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1; - buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1; - + buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1; + } // 10th round without mixcols state[ 0] = sbox[(state[ 0] ^ expandedKey[(round*16) ])]; @@ -280,9 +280,9 @@ void aes_encr(unsigned char *state, unsigned char *expandedKey) state[11]^=expandedKey[171]; state[12]^=expandedKey[172]; state[13]^=expandedKey[173]; - state[14]^=expandedKey[174]; + state[14]^=expandedKey[174]; state[15]^=expandedKey[175]; -} +} //***************************************************************************** // @@ -311,7 +311,7 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey) unsigned char buf1, buf2, buf3; signed char round; round = 9; - + // initial addroundkey state[ 0]^=expandedKey[160]; state[ 1]^=expandedKey[161]; @@ -327,9 +327,9 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey) state[11]^=expandedKey[171]; state[12]^=expandedKey[172]; state[13]^=expandedKey[173]; - state[14]^=expandedKey[174]; + state[14]^=expandedKey[174]; state[15]^=expandedKey[175]; - + // 10th round without mixcols state[ 0] = rsbox[state[ 0]] ^ expandedKey[(round*16) ]; state[ 4] = rsbox[state[ 4]] ^ expandedKey[(round*16) + 4]; @@ -354,7 +354,7 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey) state[ 7] = rsbox[state[11]] ^ expandedKey[(round*16) + 7]; state[11] = rsbox[state[15]] ^ expandedKey[(round*16) + 11]; state[15] = buf1; - + for (round = 8; round >= 0; round--){ // barreto //col1 @@ -401,8 +401,8 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey) buf3 = state[12]^state[13]; buf3=galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1; buf3 = state[13]^state[14]; buf3=galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1; buf3 = state[14]^state[15]; buf3=galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1; - buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1; - + buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1; + // addroundkey, rsbox and shiftrows // row 0 state[ 0] = rsbox[state[ 0]] ^ expandedKey[(round*16) ]; @@ -429,8 +429,8 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey) state[11] = rsbox[state[15]] ^ expandedKey[(round*16) + 11]; state[15] = buf1; } - -} + +} //***************************************************************************** // @@ -443,9 +443,9 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey) //! //! @brief AES128 encryption: //! Given AES128 key and 16 bytes plain text, cipher text of 16 bytes -//! is computed. The AES implementation is in mode ECB (Electronic -//! Code Book). -//! +//! is computed. The AES implementation is in mode ECB (Electronic +//! Code Book). +//! //! //***************************************************************************** @@ -453,7 +453,7 @@ void aes_encrypt(unsigned char *state, unsigned char *key) { // expand the key into 176 bytes - expandKey(expandedKey, key); + expandKey(expandedKey, key); aes_encr(state, expandedKey); } @@ -468,9 +468,9 @@ void aes_encrypt(unsigned char *state, //! //! @brief AES128 decryption: //! Given AES128 key and 16 bytes cipher text, plain text of 16 bytes -//! is computed The AES implementation is in mode ECB +//! is computed The AES implementation is in mode ECB //! (Electronic Code Book). -//! +//! //! //***************************************************************************** @@ -491,15 +491,15 @@ void aes_decrypt(unsigned char *state, //! //! @brief Reads AES128 key from EEPROM //! Reads the AES128 key from fileID #12 in EEPROM -//! returns an error if the key does not exist. -//! +//! returns an error if the key does not exist. +//! //! //***************************************************************************** signed long aes_read_key(unsigned char *key) { signed long returnValue; - + returnValue = nvmem_read(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key); return returnValue; @@ -515,7 +515,7 @@ signed long aes_read_key(unsigned char *key) //! //! @brief writes AES128 key from EEPROM //! Writes the AES128 key to fileID #12 in EEPROM -//! +//! //! //***************************************************************************** diff --git a/stmhal/cc3k/security.h b/stmhal/cc3k/security.h index 02214272e7..35f27763aa 100644 --- a/stmhal/cc3k/security.h +++ b/stmhal/cc3k/security.h @@ -12,23 +12,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -64,9 +64,9 @@ extern "C" { //! //! @brief AES128 encryption: //! Given AES128 key and 16 bytes plain text, cipher text of 16 bytes -//! is computed. The AES implementation is in mode ECB (Electronic -//! Code Book). -//! +//! is computed. The AES implementation is in mode ECB (Electronic +//! Code Book). +//! //! //***************************************************************************** extern void aes_encrypt(unsigned char *state, unsigned char *key); @@ -82,9 +82,9 @@ extern void aes_encrypt(unsigned char *state, unsigned char *key); //! //! @brief AES128 decryption: //! Given AES128 key and 16 bytes cipher text, plain text of 16 bytes -//! is computed The AES implementation is in mode ECB +//! is computed The AES implementation is in mode ECB //! (Electronic Code Book). -//! +//! //! //***************************************************************************** extern void aes_decrypt(unsigned char *state, unsigned char *key); @@ -100,8 +100,8 @@ extern void aes_decrypt(unsigned char *state, unsigned char *key); //! //! @brief Reads AES128 key from EEPROM //! Reads the AES128 key from fileID #12 in EEPROM -//! returns an error if the key does not exist. -//! +//! returns an error if the key does not exist. +//! //! //***************************************************************************** extern signed long aes_read_key(unsigned char *key); @@ -116,7 +116,7 @@ extern signed long aes_read_key(unsigned char *key); //! //! @brief writes AES128 key from EEPROM //! Writes the AES128 key to fileID #12 in EEPROM -//! +//! //! //***************************************************************************** extern signed long aes_write_key(unsigned char *key); diff --git a/stmhal/cc3k/socket.c b/stmhal/cc3k/socket.c index 86a4549ecf..977f3b0dce 100644 --- a/stmhal/cc3k/socket.c +++ b/stmhal/cc3k/socket.c @@ -3,9 +3,9 @@ * socket.c - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -62,13 +62,13 @@ extern int errno; -//Enable this flag if and only if you must comply with BSD socket +//Enable this flag if and only if you must comply with BSD socket //close() function #ifdef _API_USE_BSD_CLOSE #define close(sd) closesocket(sd) #endif -//Enable this flag if and only if you must comply with BSD socket read() and +//Enable this flag if and only if you must comply with BSD socket read() and //write() functions #ifdef _API_USE_BSD_READ_WRITE #define read(sd, buf, len, flags) recv(sd, buf, len, flags) @@ -90,7 +90,7 @@ extern int errno; #define SOCKET_MDNS_ADVERTISE_PARAMS_LEN (12) -// The legnth of arguments for the SEND command: sd + buff_offset + len + flags, +// The legnth of arguments for the SEND command: sd + buff_offset + len + flags, // while size of each parameter is 32 bit - so the total length is 16 bytes; #define HCI_CMND_SEND_ARG_LENGTH (16) @@ -111,13 +111,13 @@ extern int errno; //! //! @param sd socket descriptor //! -//! @return 0 in case there are buffers available, +//! @return 0 in case there are buffers available, //! -1 in case of bad socket -//! -2 if there are no free buffers present (only when +//! -2 if there are no free buffers present (only when //! SEND_NON_BLOCKING is enabled) //! -//! @brief if SEND_NON_BLOCKING not define - block until have free buffer -//! becomes available, else return immediately with correct status +//! @brief if SEND_NON_BLOCKING not define - block until have free buffer +//! becomes available, else return immediately with correct status //! regarding the buffers available. // //***************************************************************************** @@ -128,7 +128,7 @@ HostFlowControlConsumeBuff(int sd) /* wait in busy loop */ do { - // In case last transmission failed then we will return the last failure + // In case last transmission failed then we will return the last failure // reason here. // Note that the buffer will not be allocated in this case if (tSLInformation.slTransmitDataError != 0) @@ -137,17 +137,17 @@ HostFlowControlConsumeBuff(int sd) tSLInformation.slTransmitDataError = 0; return errno; } - + if(SOCKET_STATUS_ACTIVE != get_socket_active_status(sd)) return -1; } while(0 == tSLInformation.usNumberOfFreeBuffers); - + tSLInformation.usNumberOfFreeBuffers--; - + return 0; #else - - // In case last transmission failed then we will return the last failure + + // In case last transmission failed then we will return the last failure // reason here. // Note that the buffer will not be allocated in this case if (tSLInformation.slTransmitDataError != 0) @@ -158,8 +158,8 @@ HostFlowControlConsumeBuff(int sd) } if(SOCKET_STATUS_ACTIVE != get_socket_active_status(sd)) return -1; - - //If there are no available buffers, return -2. It is recommended to use + + //If there are no available buffers, return -2. It is recommended to use // select or receive to see if there is any buffer occupied with received data // If so, call receive() to release the buffer. if(0 == tSLInformation.usNumberOfFreeBuffers) @@ -178,20 +178,20 @@ HostFlowControlConsumeBuff(int sd) // //! socket //! -//! @param domain selects the protocol family which will be used for +//! @param domain selects the protocol family which will be used for //! communication. On this version only AF_INET is supported -//! @param type specifies the communication semantics. On this version +//! @param type specifies the communication semantics. On this version //! only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported -//! @param protocol specifies a particular protocol to be used with the -//! socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are +//! @param protocol specifies a particular protocol to be used with the +//! socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are //! supported. //! -//! @return On success, socket handle that is used for consequent socket +//! @return On success, socket handle that is used for consequent socket //! operations. On error, -1 is returned. //! //! @brief create an endpoint for communication -//! The socket function creates a socket that is bound to a specific -//! transport service provider. This function is called by the +//! The socket function creates a socket that is bound to a specific +//! transport service provider. This function is called by the //! application layer to obtain a socket handle. // //***************************************************************************** @@ -201,27 +201,27 @@ socket(long domain, long type, long protocol) { long ret; unsigned char *ptr, *args; - + ret = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in HCI packet structure args = UINT32_TO_STREAM(args, domain); args = UINT32_TO_STREAM(args, type); args = UINT32_TO_STREAM(args, protocol); - + // Initiate a HCI command hci_command_send(HCI_CMND_SOCKET, ptr, SOCKET_OPEN_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_CMND_SOCKET, &ret); - - // Process the event + + // Process the event errno = ret; - + set_socket_active_status(ret, SOCKET_STATUS_ACTIVE); - + return(ret); } @@ -242,25 +242,25 @@ closesocket(long sd) { long ret; unsigned char *ptr, *args; - + ret = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in HCI packet structure args = UINT32_TO_STREAM(args, sd); - + // Initiate a HCI command hci_command_send(HCI_CMND_CLOSE_SOCKET, ptr, SOCKET_CLOSE_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_CMND_CLOSE_SOCKET, &ret); errno = ret; - - // since 'close' call may result in either OK (and then it closed) or error - // mark this socket as invalid + + // since 'close' call may result in either OK (and then it closed) or error + // mark this socket as invalid set_socket_active_status(sd, SOCKET_STATUS_INACTIVE); - + return(ret); } @@ -268,15 +268,15 @@ closesocket(long sd) // //! accept //! -//! @param[in] sd socket descriptor (handle) +//! @param[in] sd socket descriptor (handle) //! @param[out] addr the argument addr is a pointer to a sockaddr structure -//! This structure is filled in with the address of the -//! peer socket, as known to the communications layer. -//! determined. The exact format of the address returned -//! addr is by the socket's address sockaddr. +//! This structure is filled in with the address of the +//! peer socket, as known to the communications layer. +//! determined. The exact format of the address returned +//! addr is by the socket's address sockaddr. //! On this version only AF_INET is supported. //! This argument returns in network order. -//! @param[out] addrlen the addrlen argument is a value-result argument: +//! @param[out] addrlen the addrlen argument is a value-result argument: //! it should initially contain the size of the structure //! pointed to by addr. //! @@ -288,21 +288,21 @@ closesocket(long sd) //! - On failure, SOC_ERROR (-1) //! //! @brief accept a connection on a socket: -//! This function is used with connection-based socket types -//! (SOCK_STREAM). It extracts the first connection request on the +//! This function is used with connection-based socket types +//! (SOCK_STREAM). It extracts the first connection request on the //! queue of pending connections, creates a new connected socket, and //! returns a new file descriptor referring to that socket. -//! The newly created socket is not in the listening state. -//! The original socket sd is unaffected by this call. +//! The newly created socket is not in the listening state. +//! The original socket sd is unaffected by this call. //! The argument sd is a socket that has been created with socket(), -//! bound to a local address with bind(), and is listening for -//! connections after a listen(). The argument addr is a pointer -//! to a sockaddr structure. This structure is filled in with the +//! bound to a local address with bind(), and is listening for +//! connections after a listen(). The argument addr is a pointer +//! to a sockaddr structure. This structure is filled in with the //! address of the peer socket, as known to the communications layer. -//! The exact format of the address returned addr is determined by the +//! The exact format of the address returned addr is determined by the //! socket's address family. The addrlen argument is a value-result //! argument: it should initially contain the size of the structure -//! pointed to by addr, on return it will contain the actual +//! pointed to by addr, on return it will contain the actual //! length (in bytes) of the address returned. //! //! @sa socket ; bind ; listen @@ -315,29 +315,29 @@ accept(long sd, sockaddr *addr, socklen_t *addrlen) long ret; unsigned char *ptr, *args; tBsdReturnParams tAcceptReturnArguments; - + ret = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, sd); - + // Initiate a HCI command hci_command_send(HCI_CMND_ACCEPT, ptr, SOCKET_ACCEPT_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_CMND_ACCEPT, &tAcceptReturnArguments); - - + + // need specify return parameters!!! memcpy(addr, &tAcceptReturnArguments.tSocketAddress, ASIC_ADDR_LEN); *addrlen = ASIC_ADDR_LEN; - errno = tAcceptReturnArguments.iStatus; + errno = tAcceptReturnArguments.iStatus; ret = errno; - - // if succeeded, iStatus = new socket descriptor. otherwise - error number + + // if succeeded, iStatus = new socket descriptor. otherwise - error number if(M_IS_VALID_SD(ret)) { set_socket_active_status(ret, SOCKET_STATUS_ACTIVE); @@ -346,7 +346,7 @@ accept(long sd, sockaddr *addr, socklen_t *addrlen) { set_socket_active_status(sd, SOCKET_STATUS_INACTIVE); } - + return(ret); } @@ -354,8 +354,8 @@ accept(long sd, sockaddr *addr, socklen_t *addrlen) // //! bind //! -//! @param[in] sd socket descriptor (handle) -//! @param[out] addr specifies the destination address. On this version +//! @param[in] sd socket descriptor (handle) +//! @param[out] addr specifies the destination address. On this version //! only AF_INET is supported. //! @param[out] addrlen contains the size of the structure pointed to by addr. //! @@ -363,8 +363,8 @@ accept(long sd, sockaddr *addr, socklen_t *addrlen) //! //! @brief assign a name to a socket //! This function gives the socket the local address addr. -//! addr is addrlen bytes long. Traditionally, this is called when a -//! socket is created with socket, it exists in a name space (address +//! addr is addrlen bytes long. Traditionally, this is called when a +//! socket is created with socket, it exists in a name space (address //! family) but has no name assigned. //! It is necessary to assign a local address before a SOCK_STREAM //! socket may receive connections. @@ -378,28 +378,28 @@ bind(long sd, const sockaddr *addr, long addrlen) { long ret; unsigned char *ptr, *args; - + ret = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + addrlen = ASIC_ADDR_LEN; - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, sd); args = UINT32_TO_STREAM(args, 0x00000008); args = UINT32_TO_STREAM(args, addrlen); ARRAY_TO_STREAM(args, ((unsigned char *)addr), addrlen); - + // Initiate a HCI command hci_command_send(HCI_CMND_BIND, ptr, SOCKET_BIND_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_CMND_BIND, &ret); - + errno = ret; - + return(ret); } @@ -407,7 +407,7 @@ bind(long sd, const sockaddr *addr, long addrlen) // //! listen //! -//! @param[in] sd socket descriptor (handle) +//! @param[in] sd socket descriptor (handle) //! @param[in] backlog specifies the listen queue depth. On this version //! backlog is not supported. //! @return On success, zero is returned. On error, -1 is returned. @@ -418,7 +418,7 @@ bind(long sd, const sockaddr *addr, long addrlen) //! and then the connections are accepted with accept. //! The listen() call applies only to sockets of type SOCK_STREAM //! The backlog parameter defines the maximum length the queue of -//! pending connections may grow to. +//! pending connections may grow to. //! //! @sa socket ; accept ; bind //! @@ -431,23 +431,23 @@ listen(long sd, long backlog) { long ret; unsigned char *ptr, *args; - + ret = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, sd); args = UINT32_TO_STREAM(args, backlog); - + // Initiate a HCI command hci_command_send(HCI_CMND_LISTEN, ptr, SOCKET_LISTEN_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_CMND_LISTEN, &ret); errno = ret; - + return(ret); } @@ -455,14 +455,14 @@ listen(long sd, long backlog) // //! gethostbyname //! -//! @param[in] hostname host name -//! @param[in] usNameLen name length -//! @param[out] out_ip_addr This parameter is filled in with host IP address. -//! In case that host name is not resolved, -//! out_ip_addr is zero. +//! @param[in] hostname host name +//! @param[in] usNameLen name length +//! @param[out] out_ip_addr This parameter is filled in with host IP address. +//! In case that host name is not resolved, +//! out_ip_addr is zero. //! @return On success, positive is returned. On error, negative is returned //! -//! @brief Get host IP by name. Obtain the IP Address of machine on network, +//! @brief Get host IP by name. Obtain the IP Address of machine on network, //! by its name. //! //! @note On this version, only blocking mode is supported. Also note that @@ -471,40 +471,40 @@ listen(long sd, long backlog) //***************************************************************************** #ifndef CC3000_TINY_DRIVER -int +int gethostbyname(const char * hostname, uint8_t usNameLen, uint32_t * out_ip_addr) { tBsdGethostbynameParams ret; unsigned char *ptr, *args; - + errno = EFAIL; - + if (usNameLen > HOSTNAME_MAX_LENGTH) { return errno; } - + ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE); - + // Fill in HCI packet structure args = UINT32_TO_STREAM(args, 8); args = UINT32_TO_STREAM(args, usNameLen); ARRAY_TO_STREAM(args, hostname, usNameLen); - + // Initiate a HCI command hci_command_send(HCI_CMND_GETHOSTNAME, ptr, SOCKET_GET_HOST_BY_NAME_PARAMS_LEN + usNameLen - 1); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_EVNT_BSD_GETHOSTBYNAME, &ret); - + errno = ret.retVal; //Dprinter->print("errno: "); Dprinter->println(errno); (*((uint32_t *)out_ip_addr)) = ret.outputAddress; - + return (errno); - + } #endif @@ -512,25 +512,25 @@ gethostbyname(const char * hostname, uint8_t usNameLen, uint32_t * out_ip_addr) // //! connect //! -//! @param[in] sd socket descriptor (handle) +//! @param[in] sd socket descriptor (handle) //! @param[in] addr specifies the destination addr. On this version //! only AF_INET is supported. -//! @param[out] addrlen contains the size of the structure pointed to by addr +//! @param[out] addrlen contains the size of the structure pointed to by addr //! @return On success, zero is returned. On error, -1 is returned //! -//! @brief initiate a connection on a socket -//! Function connects the socket referred to by the socket descriptor -//! sd, to the address specified by addr. The addrlen argument -//! specifies the size of addr. The format of the address in addr is -//! determined by the address space of the socket. If it is of type -//! SOCK_DGRAM, this call specifies the peer with which the socket is +//! @brief initiate a connection on a socket +//! Function connects the socket referred to by the socket descriptor +//! sd, to the address specified by addr. The addrlen argument +//! specifies the size of addr. The format of the address in addr is +//! determined by the address space of the socket. If it is of type +//! SOCK_DGRAM, this call specifies the peer with which the socket is //! to be associated; this address is that to which datagrams are to be -//! sent, and the only address from which datagrams are to be received. -//! If the socket is of type SOCK_STREAM, this call attempts to make a -//! connection to another socket. The other socket is specified by +//! sent, and the only address from which datagrams are to be received. +//! If the socket is of type SOCK_STREAM, this call attempts to make a +//! connection to another socket. The other socket is specified by //! address, which is an address in the communications space of the -//! socket. Note that the function implements only blocking behavior -//! thus the caller will be waiting either for the connection +//! socket. Note that the function implements only blocking behavior +//! thus the caller will be waiting either for the connection //! establishment or for the connection establishment failure. //! //! @sa socket @@ -542,27 +542,27 @@ connect(long sd, const sockaddr *addr, long addrlen) { long int ret; unsigned char *ptr, *args; - + ret = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE); addrlen = 8; - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, sd); args = UINT32_TO_STREAM(args, 0x00000008); args = UINT32_TO_STREAM(args, addrlen); ARRAY_TO_STREAM(args, ((unsigned char *)addr), addrlen); - + // Initiate a HCI command hci_command_send(HCI_CMND_CONNECT, ptr, SOCKET_CONNECT_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_CMND_CONNECT, &ret); - + errno = ret; - + return((long)ret); } @@ -572,12 +572,12 @@ connect(long sd, const sockaddr *addr, long addrlen) //! select //! //! @param[in] nfds the highest-numbered file descriptor in any of the -//! three sets, plus 1. +//! three sets, plus 1. //! @param[out] writesds socket descriptors list for write monitoring -//! @param[out] readsds socket descriptors list for read monitoring +//! @param[out] readsds socket descriptors list for read monitoring //! @param[out] exceptsds socket descriptors list for exception monitoring //! @param[in] timeout is an upper bound on the amount of time elapsed -//! before select() returns. Null means infinity +//! before select() returns. Null means infinity //! timeout. The minimum timeout is 5 milliseconds, //! less than 5 milliseconds will be set //! automatically to 5 milliseconds. @@ -589,14 +589,14 @@ connect(long sd, const sockaddr *addr, long addrlen) //! On error, -1 is returned. //! *readsds - return the sockets on which Read request will //! return without delay with valid data. -//! *writesds - return the sockets on which Write request +//! *writesds - return the sockets on which Write request //! will return without delay. //! *exceptsds - return the sockets which closed recently. //! -//! @brief Monitor socket activity +//! @brief Monitor socket activity //! Select allow a program to monitor multiple file descriptors, -//! waiting until one or more of the file descriptors become -//! "ready" for some class of I/O operation +//! waiting until one or more of the file descriptors become +//! "ready" for some class of I/O operation //! //! @Note If the timeout value set to less than 5ms it will automatically set //! to 5ms to prevent overload of the system @@ -606,13 +606,13 @@ connect(long sd, const sockaddr *addr, long addrlen) //***************************************************************************** int -select(long nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, +select(long nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, struct timeval *timeout) { unsigned char *ptr, *args; tBsdSelectRecvParams tParams; unsigned long is_blocking; - + if( timeout == NULL) { is_blocking = 1; /* blocking , infinity timeout */ @@ -621,11 +621,11 @@ select(long nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, { is_blocking = 0; /* no blocking, timeout */ } - + // Fill in HCI packet structure ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, nfds); args = UINT32_TO_STREAM(args, 0x00000014); @@ -636,10 +636,10 @@ select(long nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, args = UINT32_TO_STREAM(args, ((readsds) ? *(unsigned long*)readsds : 0)); args = UINT32_TO_STREAM(args, ((writesds) ? *(unsigned long*)writesds : 0)); args = UINT32_TO_STREAM(args, ((exceptsds) ? *(unsigned long*)exceptsds : 0)); - + if (timeout) { - if ( 0 == timeout->tv_sec && timeout->tv_usec < + if ( 0 == timeout->tv_sec && timeout->tv_usec < SELECT_TIMEOUT_MIN_MICRO_SECONDS) { timeout->tv_usec = SELECT_TIMEOUT_MIN_MICRO_SECONDS; @@ -647,13 +647,13 @@ select(long nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, args = UINT32_TO_STREAM(args, timeout->tv_sec); args = UINT32_TO_STREAM(args, timeout->tv_usec); } - + // Initiate a HCI command hci_command_send(HCI_CMND_BSD_SELECT, ptr, SOCKET_SELECT_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_EVNT_SELECT, &tParams); - + // Update actually read FD if (tParams.iStatus >= 0) { @@ -661,19 +661,19 @@ select(long nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, { memcpy(readsds, &tParams.uiRdfd, sizeof(tParams.uiRdfd)); } - + if (writesds) { - memcpy(writesds, &tParams.uiWrfd, sizeof(tParams.uiWrfd)); + memcpy(writesds, &tParams.uiWrfd, sizeof(tParams.uiWrfd)); } - + if (exceptsds) { - memcpy(exceptsds, &tParams.uiExfd, sizeof(tParams.uiExfd)); + memcpy(exceptsds, &tParams.uiExfd, sizeof(tParams.uiExfd)); } - + return(tParams.iStatus); - + } else { @@ -697,31 +697,31 @@ select(long nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, //! This function manipulate the options associated with a socket. //! Options may exist at multiple protocol levels; they are always //! present at the uppermost socket level. -//! When manipulating socket options the level at which the option -//! resides and the name of the option must be specified. -//! To manipulate options at the socket level, level is specified as -//! SOL_SOCKET. To manipulate options at any other level the protocol -//! number of the appropriate protocol controlling the option is -//! supplied. For example, to indicate that an option is to be -//! interpreted by the TCP protocol, level should be set to the -//! protocol number of TCP; -//! The parameters optval and optlen are used to access optval - +//! When manipulating socket options the level at which the option +//! resides and the name of the option must be specified. +//! To manipulate options at the socket level, level is specified as +//! SOL_SOCKET. To manipulate options at any other level the protocol +//! number of the appropriate protocol controlling the option is +//! supplied. For example, to indicate that an option is to be +//! interpreted by the TCP protocol, level should be set to the +//! protocol number of TCP; +//! The parameters optval and optlen are used to access optval - //! use for setsockopt(). For getsockopt() they identify a buffer -//! in which the value for the requested option(s) are to -//! be returned. For getsockopt(), optlen is a value-result -//! parameter, initially containing the size of the buffer -//! pointed to by option_value, and modified on return to -//! indicate the actual size of the value returned. If no option +//! in which the value for the requested option(s) are to +//! be returned. For getsockopt(), optlen is a value-result +//! parameter, initially containing the size of the buffer +//! pointed to by option_value, and modified on return to +//! indicate the actual size of the value returned. If no option //! value is to be supplied or returned, option_value may be NULL. //! //! @Note On this version the following two socket options are enabled: //! The only protocol level supported in this version //! is SOL_SOCKET (level). //! 1. SOCKOPT_RECV_TIMEOUT (optname) -//! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout +//! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout //! in milliseconds. //! In that case optval should be pointer to unsigned long. -//! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on +//! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on //! or off. //! In that case optval should be SOCK_ON or SOCK_OFF (optval). //! @@ -736,10 +736,10 @@ setsockopt(long sd, long level, long optname, const void *optval, { long ret; unsigned char *ptr, *args; - + ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, sd); args = UINT32_TO_STREAM(args, level); @@ -747,14 +747,14 @@ setsockopt(long sd, long level, long optname, const void *optval, args = UINT32_TO_STREAM(args, 0x00000008); args = UINT32_TO_STREAM(args, optlen); ARRAY_TO_STREAM(args, ((unsigned char *)optval), optlen); - + // Initiate a HCI command hci_command_send(HCI_CMND_SETSOCKOPT, ptr, SOCKET_SET_SOCK_OPT_PARAMS_LEN + optlen); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_CMND_SETSOCKOPT, &ret); - + if (ret >= 0) { return (0); @@ -782,31 +782,31 @@ setsockopt(long sd, long level, long optname, const void *optval, //! This function manipulate the options associated with a socket. //! Options may exist at multiple protocol levels; they are always //! present at the uppermost socket level. -//! When manipulating socket options the level at which the option -//! resides and the name of the option must be specified. -//! To manipulate options at the socket level, level is specified as -//! SOL_SOCKET. To manipulate options at any other level the protocol -//! number of the appropriate protocol controlling the option is -//! supplied. For example, to indicate that an option is to be -//! interpreted by the TCP protocol, level should be set to the -//! protocol number of TCP; -//! The parameters optval and optlen are used to access optval - +//! When manipulating socket options the level at which the option +//! resides and the name of the option must be specified. +//! To manipulate options at the socket level, level is specified as +//! SOL_SOCKET. To manipulate options at any other level the protocol +//! number of the appropriate protocol controlling the option is +//! supplied. For example, to indicate that an option is to be +//! interpreted by the TCP protocol, level should be set to the +//! protocol number of TCP; +//! The parameters optval and optlen are used to access optval - //! use for setsockopt(). For getsockopt() they identify a buffer -//! in which the value for the requested option(s) are to -//! be returned. For getsockopt(), optlen is a value-result -//! parameter, initially containing the size of the buffer -//! pointed to by option_value, and modified on return to -//! indicate the actual size of the value returned. If no option +//! in which the value for the requested option(s) are to +//! be returned. For getsockopt(), optlen is a value-result +//! parameter, initially containing the size of the buffer +//! pointed to by option_value, and modified on return to +//! indicate the actual size of the value returned. If no option //! value is to be supplied or returned, option_value may be NULL. //! //! @Note On this version the following two socket options are enabled: //! The only protocol level supported in this version //! is SOL_SOCKET (level). //! 1. SOCKOPT_RECV_TIMEOUT (optname) -//! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout +//! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout //! in milliseconds. //! In that case optval should be pointer to unsigned long. -//! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on +//! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on //! or off. //! In that case optval should be SOCK_ON or SOCK_OFF (optval). //! @@ -819,22 +819,22 @@ getsockopt (long sd, long level, long optname, void *optval, socklen_t *optlen) { unsigned char *ptr, *args; tBsdGetSockOptReturnParams tRetParams; - + ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, sd); args = UINT32_TO_STREAM(args, level); args = UINT32_TO_STREAM(args, optname); - + // Initiate a HCI command hci_command_send(HCI_CMND_GETSOCKOPT, ptr, SOCKET_GET_SOCK_OPT_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_CMND_GETSOCKOPT, &tRetParams); - + if (((signed char)tRetParams.iStatus) >= 0) { *optlen = 4; @@ -875,18 +875,18 @@ simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from, { unsigned char *ptr, *args; tBsdReadReturnParams tSocketReadEvent; - + ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); - + // Fill in HCI packet structure args = UINT32_TO_STREAM(args, sd); args = UINT32_TO_STREAM(args, len); args = UINT32_TO_STREAM(args, flags); - // Generate the read command, and wait for the + // Generate the read command, and wait for the hci_command_send(opcode, ptr, SOCKET_RECV_FROM_PARAMS_LEN); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(opcode, &tSocketReadEvent); @@ -901,11 +901,11 @@ simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from, // In case the number of bytes is more then zero - read data if (tSocketReadEvent.iNumberOfBytes > 0) { - // Wait for the data in a synchronous way. Here we assume that the bug is + // Wait for the data in a synchronous way. Here we assume that the bug is // big enough to store also parameters of receive from too.... SimpleLinkWaitData((unsigned char *)buf, (unsigned char *)from, (unsigned char *)fromlen); } - + errno = tSocketReadEvent.iNumberOfBytes; #if (DEBUG_MODE == 1) @@ -913,7 +913,7 @@ simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from, putchar(((unsigned char *)buf)[i]); } #endif - + return(tSocketReadEvent.iNumberOfBytes); } @@ -923,9 +923,9 @@ simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from, //! //! @param[in] sd socket handle //! @param[out] buf Points to the buffer where the message should be stored -//! @param[in] len Specifies the length in bytes of the buffer pointed to +//! @param[in] len Specifies the length in bytes of the buffer pointed to //! by the buffer argument. -//! @param[in] flags Specifies the type of message reception. +//! @param[in] flags Specifies the type of message reception. //! On this version, this parameter is not supported. //! //! @return Return the number of bytes received, or -1 if an error @@ -951,9 +951,9 @@ recv(long sd, void *buf, long len, long flags) //! //! @param[in] sd socket handle //! @param[out] buf Points to the buffer where the message should be stored -//! @param[in] len Specifies the length in bytes of the buffer pointed to +//! @param[in] len Specifies the length in bytes of the buffer pointed to //! by the buffer argument. -//! @param[in] flags Specifies the type of message reception. +//! @param[in] flags Specifies the type of message reception. //! On this version, this parameter is not supported. //! @param[in] from pointer to an address structure indicating the source //! address: sockaddr. On this version only AF_INET is @@ -1004,29 +1004,29 @@ recvfrom(long sd, void *buf, long len, long flags, sockaddr *from, int simple_link_send(long sd, const void *buf, long len, long flags, const sockaddr *to, long tolen, long opcode) -{ +{ unsigned char uArgSize = 0, addrlen; unsigned char *ptr, *pDataPtr = NULL, *args; unsigned long addr_offset = 0; int res; tBsdReadReturnParams tSocketSendEvent; - + // Check the bsd_arguments if (0 != (res = HostFlowControlConsumeBuff(sd))) { return res; } - + //Update the number of sent packets tSLInformation.NumberOfSentPackets++; - + // Allocate a buffer and construct a packet and send it over spi ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_DATA); - + // Update the offset of data and parameters according to the command switch(opcode) - { + { case HCI_CMND_SENDTO: { addr_offset = len + sizeof(len) + sizeof(len); @@ -1035,7 +1035,7 @@ simple_link_send(long sd, const void *buf, long len, long flags, pDataPtr = ptr + HEADERS_SIZE_DATA + SOCKET_SENDTO_PARAMS_LEN; break; } - + case HCI_CMND_SEND: { tolen = 0; @@ -1044,42 +1044,42 @@ simple_link_send(long sd, const void *buf, long len, long flags, pDataPtr = ptr + HEADERS_SIZE_DATA + HCI_CMND_SEND_ARG_LENGTH; break; } - + default: { break; } } - + // Fill in temporary command buffer args = UINT32_TO_STREAM(args, sd); args = UINT32_TO_STREAM(args, uArgSize - sizeof(sd)); args = UINT32_TO_STREAM(args, len); args = UINT32_TO_STREAM(args, flags); - + if (opcode == HCI_CMND_SENDTO) { args = UINT32_TO_STREAM(args, addr_offset); args = UINT32_TO_STREAM(args, addrlen); } - + // Copy the data received from user into the TX Buffer ARRAY_TO_STREAM(pDataPtr, ((unsigned char *)buf), len); - + // In case we are using SendTo, copy the to parameters if (opcode == HCI_CMND_SENDTO) - { + { ARRAY_TO_STREAM(pDataPtr, ((unsigned char *)to), tolen); } - + // Initiate a HCI command hci_data_send(opcode, ptr, uArgSize, len,(unsigned char*)to, tolen); - + if (opcode == HCI_CMND_SENDTO) SimpleLinkWaitEvent(HCI_EVNT_SENDTO, &tSocketSendEvent); else SimpleLinkWaitEvent(HCI_EVNT_SEND, &tSocketSendEvent); - + return (len); } @@ -1097,7 +1097,7 @@ simple_link_send(long sd, const void *buf, long len, long flags, //! error occurred //! //! @brief Write data to TCP socket -//! This function is used to transmit a message to another +//! This function is used to transmit a message to another //! socket. //! //! @Note On this version, only blocking mode is supported. @@ -1129,7 +1129,7 @@ send(long sd, const void *buf, long len, long flags) //! error occurred //! //! @brief Write data to TCP socket -//! This function is used to transmit a message to another +//! This function is used to transmit a message to another //! socket. //! //! @Note On this version, only blocking mode is supported. @@ -1153,9 +1153,9 @@ sendto(long sd, const void *buf, long len, long flags, const sockaddr *to, //! @param[in] deviceServiceName Service name as part of the published //! canonical domain name //! @param[in] deviceServiceNameLength Length of the service name -//! //! -//! @return On success, zero is returned, return SOC_ERROR if socket was not +//! +//! @return On success, zero is returned, return SOC_ERROR if socket was not //! opened successfully, or if an error occurred. //! //! @brief Set CC3000 in mDNS advertiser mode in order to advertise itself. @@ -1167,29 +1167,29 @@ mdnsAdvertiser(unsigned short mdnsEnabled, char * deviceServiceName, unsigned sh { char ret; unsigned char *pTxBuffer, *pArgs; - + if (deviceServiceNameLength > MDNS_DEVICE_SERVICE_MAX_LENGTH) { return EFAIL; } - + pTxBuffer = tSLInformation.pucTxCommandBuffer; pArgs = (pTxBuffer + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE); - + // Fill in HCI packet structure pArgs = UINT32_TO_STREAM(pArgs, mdnsEnabled); pArgs = UINT32_TO_STREAM(pArgs, 8); pArgs = UINT32_TO_STREAM(pArgs, deviceServiceNameLength); ARRAY_TO_STREAM(pArgs, deviceServiceName, deviceServiceNameLength); - + // Initiate a HCI command hci_command_send(HCI_CMND_MDNS_ADVERTISE, pTxBuffer, SOCKET_MDNS_ADVERTISE_PARAMS_LEN + deviceServiceNameLength); - + // Since we are in blocking state - wait for event complete SimpleLinkWaitEvent(HCI_EVNT_MDNS_ADVERTISE, &ret); - + return ret; - + } #endif // MICROPY_HW_ENABLE_CC3K diff --git a/stmhal/cc3k/socket.h b/stmhal/cc3k/socket.h index 58e7ef13be..149b512663 100644 --- a/stmhal/cc3k/socket.h +++ b/stmhal/cc3k/socket.h @@ -3,9 +3,9 @@ * socket.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,23 +20,23 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ @@ -91,7 +91,7 @@ extern "C" { //----------- Socket retunr codes ----------- -#define SOC_ERROR (-1) // error +#define SOC_ERROR (-1) // error #define SOC_IN_PROGRESS (-2) // socket in progress //----------- Socket Options ----------- @@ -99,7 +99,7 @@ extern "C" { #define SOCKOPT_RECV_NONBLOCK 0 // recv non block mode, set SOCK_ON or SOCK_OFF (default block mode) #define SOCKOPT_RECV_TIMEOUT 1 // optname to configure recv and recvfromtimeout #define SOCKOPT_ACCEPT_NONBLOCK 2 // accept non block mode, set SOCK_ON or SOCK_OFF (default block mode) -#define SOCK_ON 0 // socket non-blocking mode is enabled +#define SOCK_ON 0 // socket non-blocking mode is enabled #define SOCK_OFF 1 // socket blocking mode is enabled #define TCP_NODELAY 0x0001 @@ -118,10 +118,10 @@ extern "C" { #define __FD_SETSIZE 32 #define ASIC_ADDR_LEN 8 - + #define NO_QUERY_RECIVED -3 - - + + typedef struct _in_addr_t { unsigned long s_addr; // load with inet_aton() @@ -194,7 +194,7 @@ typedef struct #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp) //Use in case of Big Endian only - + #define htonl(A) ((((unsigned long)(A) & 0xff000000) >> 24) | \ (((unsigned long)(A) & 0x00ff0000) >> 8) | \ (((unsigned long)(A) & 0x0000ff00) << 8) | \ @@ -209,13 +209,13 @@ typedef struct #define ntohs htons -// mDNS port - 5353 mDNS multicast address - 224.0.0.251 +// mDNS port - 5353 mDNS multicast address - 224.0.0.251 #define SET_mDNS_ADD(sockaddr) sockaddr.sa_data[0] = 0x14; \ sockaddr.sa_data[1] = 0xe9; \ sockaddr.sa_data[2] = 0xe0; \ sockaddr.sa_data[3] = 0x0; \ sockaddr.sa_data[4] = 0x0; \ - sockaddr.sa_data[5] = 0xfb; + sockaddr.sa_data[5] = 0xfb; //***************************************************************************** @@ -228,20 +228,20 @@ typedef struct // //! socket //! -//! @param domain selects the protocol family which will be used for +//! @param domain selects the protocol family which will be used for //! communication. On this version only AF_INET is supported -//! @param type specifies the communication semantics. On this version +//! @param type specifies the communication semantics. On this version //! only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported -//! @param protocol specifies a particular protocol to be used with the -//! socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are +//! @param protocol specifies a particular protocol to be used with the +//! socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are //! supported. //! -//! @return On success, socket handle that is used for consequent socket +//! @return On success, socket handle that is used for consequent socket //! operations. On error, -1 is returned. //! //! @brief create an endpoint for communication -//! The socket function creates a socket that is bound to a specific -//! transport service provider. This function is called by the +//! The socket function creates a socket that is bound to a specific +//! transport service provider. This function is called by the //! application layer to obtain a socket handle. // //***************************************************************************** @@ -264,15 +264,15 @@ extern long closesocket(long sd); // //! accept //! -//! @param[in] sd socket descriptor (handle) +//! @param[in] sd socket descriptor (handle) //! @param[out] addr the argument addr is a pointer to a sockaddr structure -//! This structure is filled in with the address of the -//! peer socket, as known to the communications layer. -//! determined. The exact format of the address returned -//! addr is by the socket's address sockaddr. +//! This structure is filled in with the address of the +//! peer socket, as known to the communications layer. +//! determined. The exact format of the address returned +//! addr is by the socket's address sockaddr. //! On this version only AF_INET is supported. //! This argument returns in network order. -//! @param[out] addrlen the addrlen argument is a value-result argument: +//! @param[out] addrlen the addrlen argument is a value-result argument: //! it should initially contain the size of the structure //! pointed to by addr. //! @@ -284,21 +284,21 @@ extern long closesocket(long sd); //! - On failure, SOC_ERROR (-1) //! //! @brief accept a connection on a socket: -//! This function is used with connection-based socket types -//! (SOCK_STREAM). It extracts the first connection request on the +//! This function is used with connection-based socket types +//! (SOCK_STREAM). It extracts the first connection request on the //! queue of pending connections, creates a new connected socket, and //! returns a new file descriptor referring to that socket. -//! The newly created socket is not in the listening state. -//! The original socket sd is unaffected by this call. +//! The newly created socket is not in the listening state. +//! The original socket sd is unaffected by this call. //! The argument sd is a socket that has been created with socket(), -//! bound to a local address with bind(), and is listening for -//! connections after a listen(). The argument addr is a pointer -//! to a sockaddr structure. This structure is filled in with the +//! bound to a local address with bind(), and is listening for +//! connections after a listen(). The argument addr is a pointer +//! to a sockaddr structure. This structure is filled in with the //! address of the peer socket, as known to the communications layer. -//! The exact format of the address returned addr is determined by the +//! The exact format of the address returned addr is determined by the //! socket's address family. The addrlen argument is a value-result //! argument: it should initially contain the size of the structure -//! pointed to by addr, on return it will contain the actual +//! pointed to by addr, on return it will contain the actual //! length (in bytes) of the address returned. //! //! @sa socket ; bind ; listen @@ -310,8 +310,8 @@ extern long accept(long sd, sockaddr *addr, socklen_t *addrlen); // //! bind //! -//! @param[in] sd socket descriptor (handle) -//! @param[out] addr specifies the destination address. On this version +//! @param[in] sd socket descriptor (handle) +//! @param[out] addr specifies the destination address. On this version //! only AF_INET is supported. //! @param[out] addrlen contains the size of the structure pointed to by addr. //! @@ -319,8 +319,8 @@ extern long accept(long sd, sockaddr *addr, socklen_t *addrlen); //! //! @brief assign a name to a socket //! This function gives the socket the local address addr. -//! addr is addrlen bytes long. Traditionally, this is called when a -//! socket is created with socket, it exists in a name space (address +//! addr is addrlen bytes long. Traditionally, this is called when a +//! socket is created with socket, it exists in a name space (address //! family) but has no name assigned. //! It is necessary to assign a local address before a SOCK_STREAM //! socket may receive connections. @@ -334,7 +334,7 @@ extern long bind(long sd, const sockaddr *addr, long addrlen); // //! listen //! -//! @param[in] sd socket descriptor (handle) +//! @param[in] sd socket descriptor (handle) //! @param[in] backlog specifies the listen queue depth. On this version //! backlog is not supported. //! @return On success, zero is returned. On error, -1 is returned. @@ -345,7 +345,7 @@ extern long bind(long sd, const sockaddr *addr, long addrlen); //! and then the connections are accepted with accept. //! The listen() call applies only to sockets of type SOCK_STREAM //! The backlog parameter defines the maximum length the queue of -//! pending connections may grow to. +//! pending connections may grow to. //! //! @sa socket ; accept ; bind //! @@ -358,21 +358,21 @@ extern long listen(long sd, long backlog); // //! gethostbyname //! -//! @param[in] hostname host name -//! @param[in] usNameLen name length -//! @param[out] out_ip_addr This parameter is filled in with host IP address. -//! In case that host name is not resolved, -//! out_ip_addr is zero. +//! @param[in] hostname host name +//! @param[in] usNameLen name length +//! @param[out] out_ip_addr This parameter is filled in with host IP address. +//! In case that host name is not resolved, +//! out_ip_addr is zero. //! @return On success, positive is returned. On error, negative is returned //! -//! @brief Get host IP by name. Obtain the IP Address of machine on network, +//! @brief Get host IP by name. Obtain the IP Address of machine on network, //! by its name. //! //! @note On this version, only blocking mode is supported. Also note that //! the function requires DNS server to be configured prior to its usage. // //***************************************************************************** -#ifndef CC3000_TINY_DRIVER +#ifndef CC3000_TINY_DRIVER extern int gethostbyname(const char * hostname, uint8_t usNameLen, uint32_t* out_ip_addr); #endif @@ -381,25 +381,25 @@ extern int gethostbyname(const char * hostname, uint8_t usNameLen, uint32_t* out // //! connect //! -//! @param[in] sd socket descriptor (handle) +//! @param[in] sd socket descriptor (handle) //! @param[in] addr specifies the destination addr. On this version //! only AF_INET is supported. -//! @param[out] addrlen contains the size of the structure pointed to by addr +//! @param[out] addrlen contains the size of the structure pointed to by addr //! @return On success, zero is returned. On error, -1 is returned //! -//! @brief initiate a connection on a socket -//! Function connects the socket referred to by the socket descriptor -//! sd, to the address specified by addr. The addrlen argument -//! specifies the size of addr. The format of the address in addr is -//! determined by the address space of the socket. If it is of type -//! SOCK_DGRAM, this call specifies the peer with which the socket is +//! @brief initiate a connection on a socket +//! Function connects the socket referred to by the socket descriptor +//! sd, to the address specified by addr. The addrlen argument +//! specifies the size of addr. The format of the address in addr is +//! determined by the address space of the socket. If it is of type +//! SOCK_DGRAM, this call specifies the peer with which the socket is //! to be associated; this address is that to which datagrams are to be -//! sent, and the only address from which datagrams are to be received. -//! If the socket is of type SOCK_STREAM, this call attempts to make a -//! connection to another socket. The other socket is specified by +//! sent, and the only address from which datagrams are to be received. +//! If the socket is of type SOCK_STREAM, this call attempts to make a +//! connection to another socket. The other socket is specified by //! address, which is an address in the communications space of the -//! socket. Note that the function implements only blocking behavior -//! thus the caller will be waiting either for the connection +//! socket. Note that the function implements only blocking behavior +//! thus the caller will be waiting either for the connection //! establishment or for the connection establishment failure. //! //! @sa socket @@ -412,12 +412,12 @@ extern long connect(long sd, const sockaddr *addr, long addrlen); //! select //! //! @param[in] nfds the highest-numbered file descriptor in any of the -//! three sets, plus 1. +//! three sets, plus 1. //! @param[out] writesds socket descriptors list for write monitoring -//! @param[out] readsds socket descriptors list for read monitoring +//! @param[out] readsds socket descriptors list for read monitoring //! @param[out] exceptsds socket descriptors list for exception monitoring //! @param[in] timeout is an upper bound on the amount of time elapsed -//! before select() returns. Null means infinity +//! before select() returns. Null means infinity //! timeout. The minimum timeout is 5 milliseconds, //! less than 5 milliseconds will be set //! automatically to 5 milliseconds. @@ -429,14 +429,14 @@ extern long connect(long sd, const sockaddr *addr, long addrlen); //! On error, -1 is returned. //! *readsds - return the sockets on which Read request will //! return without delay with valid data. -//! *writesds - return the sockets on which Write request +//! *writesds - return the sockets on which Write request //! will return without delay. //! *exceptsds - return the sockets which closed recently. //! -//! @brief Monitor socket activity +//! @brief Monitor socket activity //! Select allow a program to monitor multiple file descriptors, -//! waiting until one or more of the file descriptors become -//! "ready" for some class of I/O operation +//! waiting until one or more of the file descriptors become +//! "ready" for some class of I/O operation //! //! @Note If the timeout value set to less than 5ms it will automatically set //! to 5ms to prevent overload of the system @@ -462,38 +462,38 @@ extern int select(long nfds, fd_set *readsds, fd_set *writesds, //! This function manipulate the options associated with a socket. //! Options may exist at multiple protocol levels; they are always //! present at the uppermost socket level. -//! When manipulating socket options the level at which the option -//! resides and the name of the option must be specified. -//! To manipulate options at the socket level, level is specified as -//! SOL_SOCKET. To manipulate options at any other level the protocol -//! number of the appropriate protocol controlling the option is -//! supplied. For example, to indicate that an option is to be -//! interpreted by the TCP protocol, level should be set to the -//! protocol number of TCP; -//! The parameters optval and optlen are used to access optval - +//! When manipulating socket options the level at which the option +//! resides and the name of the option must be specified. +//! To manipulate options at the socket level, level is specified as +//! SOL_SOCKET. To manipulate options at any other level the protocol +//! number of the appropriate protocol controlling the option is +//! supplied. For example, to indicate that an option is to be +//! interpreted by the TCP protocol, level should be set to the +//! protocol number of TCP; +//! The parameters optval and optlen are used to access optval - //! use for setsockopt(). For getsockopt() they identify a buffer -//! in which the value for the requested option(s) are to -//! be returned. For getsockopt(), optlen is a value-result -//! parameter, initially containing the size of the buffer -//! pointed to by option_value, and modified on return to -//! indicate the actual size of the value returned. If no option +//! in which the value for the requested option(s) are to +//! be returned. For getsockopt(), optlen is a value-result +//! parameter, initially containing the size of the buffer +//! pointed to by option_value, and modified on return to +//! indicate the actual size of the value returned. If no option //! value is to be supplied or returned, option_value may be NULL. //! //! @Note On this version the following two socket options are enabled: //! The only protocol level supported in this version //! is SOL_SOCKET (level). //! 1. SOCKOPT_RECV_TIMEOUT (optname) -//! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout +//! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout //! in milliseconds. //! In that case optval should be pointer to unsigned long. -//! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on +//! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on //! or off. //! In that case optval should be SOCK_ON or SOCK_OFF (optval). //! //! @sa getsockopt // //***************************************************************************** -#ifndef CC3000_TINY_DRIVER +#ifndef CC3000_TINY_DRIVER extern int setsockopt(long sd, long level, long optname, const void *optval, socklen_t optlen); #endif @@ -512,31 +512,31 @@ extern int setsockopt(long sd, long level, long optname, const void *optval, //! This function manipulate the options associated with a socket. //! Options may exist at multiple protocol levels; they are always //! present at the uppermost socket level. -//! When manipulating socket options the level at which the option -//! resides and the name of the option must be specified. -//! To manipulate options at the socket level, level is specified as -//! SOL_SOCKET. To manipulate options at any other level the protocol -//! number of the appropriate protocol controlling the option is -//! supplied. For example, to indicate that an option is to be -//! interpreted by the TCP protocol, level should be set to the -//! protocol number of TCP; -//! The parameters optval and optlen are used to access optval - +//! When manipulating socket options the level at which the option +//! resides and the name of the option must be specified. +//! To manipulate options at the socket level, level is specified as +//! SOL_SOCKET. To manipulate options at any other level the protocol +//! number of the appropriate protocol controlling the option is +//! supplied. For example, to indicate that an option is to be +//! interpreted by the TCP protocol, level should be set to the +//! protocol number of TCP; +//! The parameters optval and optlen are used to access optval - //! use for setsockopt(). For getsockopt() they identify a buffer -//! in which the value for the requested option(s) are to -//! be returned. For getsockopt(), optlen is a value-result -//! parameter, initially containing the size of the buffer -//! pointed to by option_value, and modified on return to -//! indicate the actual size of the value returned. If no option +//! in which the value for the requested option(s) are to +//! be returned. For getsockopt(), optlen is a value-result +//! parameter, initially containing the size of the buffer +//! pointed to by option_value, and modified on return to +//! indicate the actual size of the value returned. If no option //! value is to be supplied or returned, option_value may be NULL. //! //! @Note On this version the following two socket options are enabled: //! The only protocol level supported in this version //! is SOL_SOCKET (level). //! 1. SOCKOPT_RECV_TIMEOUT (optname) -//! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout +//! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout //! in milliseconds. //! In that case optval should be pointer to unsigned long. -//! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on +//! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on //! or off. //! In that case optval should be SOCK_ON or SOCK_OFF (optval). //! @@ -552,9 +552,9 @@ extern int getsockopt(long sd, long level, long optname, void *optval, //! //! @param[in] sd socket handle //! @param[out] buf Points to the buffer where the message should be stored -//! @param[in] len Specifies the length in bytes of the buffer pointed to +//! @param[in] len Specifies the length in bytes of the buffer pointed to //! by the buffer argument. -//! @param[in] flags Specifies the type of message reception. +//! @param[in] flags Specifies the type of message reception. //! On this version, this parameter is not supported. //! //! @return Return the number of bytes received, or -1 if an error @@ -575,9 +575,9 @@ extern int recv(long sd, void *buf, long len, long flags); //! //! @param[in] sd socket handle //! @param[out] buf Points to the buffer where the message should be stored -//! @param[in] len Specifies the length in bytes of the buffer pointed to +//! @param[in] len Specifies the length in bytes of the buffer pointed to //! by the buffer argument. -//! @param[in] flags Specifies the type of message reception. +//! @param[in] flags Specifies the type of message reception. //! On this version, this parameter is not supported. //! @param[in] from pointer to an address structure indicating the source //! address: sockaddr. On this version only AF_INET is @@ -597,7 +597,7 @@ extern int recv(long sd, void *buf, long len, long flags); //! @Note On this version, only blocking mode is supported. // //***************************************************************************** -extern int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from, +extern int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from, socklen_t *fromlen); //***************************************************************************** @@ -613,7 +613,7 @@ extern int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from, //! error occurred //! //! @brief Write data to TCP socket -//! This function is used to transmit a message to another +//! This function is used to transmit a message to another //! socket. //! //! @Note On this version, only blocking mode is supported. @@ -641,7 +641,7 @@ extern int send(long sd, const void *buf, long len, long flags); //! error occurred //! //! @brief Write data to TCP socket -//! This function is used to transmit a message to another +//! This function is used to transmit a message to another //! socket. //! //! @Note On this version, only blocking mode is supported. @@ -650,7 +650,7 @@ extern int send(long sd, const void *buf, long len, long flags); // //***************************************************************************** -extern int sendto(long sd, const void *buf, long len, long flags, +extern int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to, socklen_t tolen); //***************************************************************************** @@ -661,9 +661,9 @@ extern int sendto(long sd, const void *buf, long len, long flags, //! @param[in] deviceServiceName Service name as part of the published //! canonical domain name //! @param[in] deviceServiceNameLength Length of the service name -//! //! -//! @return On success, zero is returned, return SOC_ERROR if socket was not +//! +//! @return On success, zero is returned, return SOC_ERROR if socket was not //! opened successfully, or if an error occurred. //! //! @brief Set CC3000 in mDNS advertiser mode in order to advertise itself. diff --git a/stmhal/cc3k/wlan.h b/stmhal/cc3k/wlan.h index d5ccd363f5..6dadb6452a 100644 --- a/stmhal/cc3k/wlan.h +++ b/stmhal/cc3k/wlan.h @@ -3,9 +3,9 @@ * wlan.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * -* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) +* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend) * & Limor Fried for Adafruit Industries -* This library works with the Adafruit CC3000 breakout +* This library works with the Adafruit CC3000 breakout * ----> https://www.adafruit.com/products/1469 * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -20,28 +20,28 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Adapted for use with the Arduino/AVR by KTOWN for Adafruit Industries -This library works with the Adafruit CC3000 breakout +This library works with the Adafruit CC3000 breakout ----> https://www.adafruit.com/products/1469 Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing @@ -79,41 +79,41 @@ extern "C" { // //! wlan_init //! -//! @param sWlanCB Asynchronous events callback. +//! @param sWlanCB Asynchronous events callback. //! 0 no event call back. //! -call back parameters: //! 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event, //! HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event, //! HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done, -//! HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, -//! HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR +//! HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, +//! HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR //! HCI_EVNT_WLAN_KEEPALIVE keepalive. //! 2) data: pointer to extra data that received by the event //! (NULL no data). //! 3) length: data length. //! -Events with extra data: -//! HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, +//! HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, //! 4 bytes default gateway, 4 bytes DHCP server and 4 bytes //! for DNS server. -//! HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, -//! 4 bytes Packets received, 4 bytes Min round time, +//! HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, +//! 4 bytes Packets received, 4 bytes Min round time, //! 4 bytes Max round time and 4 bytes for Avg round time. //! -//! @param sFWPatches 0 no patch or pointer to FW patches +//! @param sFWPatches 0 no patch or pointer to FW patches //! @param sDriverPatches 0 no patch or pointer to driver patches //! @param sBootLoaderPatches 0 no patch or pointer to bootloader patches -//! @param sReadWlanInterruptPin init callback. the callback read wlan +//! @param sReadWlanInterruptPin init callback. the callback read wlan //! interrupt status. -//! @param sWlanInterruptEnable init callback. the callback enable wlan +//! @param sWlanInterruptEnable init callback. the callback enable wlan //! interrupt. //! @param sWlanInterruptDisable init callback. the callback disable wlan //! interrupt. -//! @param sWriteWlanPin init callback. the callback write value -//! to device pin. +//! @param sWriteWlanPin init callback. the callback write value +//! to device pin. //! //! @return none //! -//! @sa wlan_set_event_mask , wlan_start , wlan_stop +//! @sa wlan_set_event_mask , wlan_start , wlan_stop //! //! @brief Initialize wlan driver //! @@ -136,22 +136,22 @@ extern void wlan_init( tWlanCB sWlanCB, //! wlan_start //! //! @param usPatchesAvailableAtHost - flag to indicate if patches available -//! from host or from EEPROM. Due to the +//! from host or from EEPROM. Due to the //! fact the patches are burn to the EEPROM -//! using the patch programmer utility, the +//! using the patch programmer utility, the //! patches will be available from the EEPROM //! and not from the host. //! //! @return none //! -//! @brief Start WLAN device. This function asserts the enable pin of +//! @brief Start WLAN device. This function asserts the enable pin of //! the device (WLAN_EN), starting the HW initialization process. //! The function blocked until device Initialization is completed. -//! Function also configure patches (FW, driver or bootloader) +//! Function also configure patches (FW, driver or bootloader) //! and calls appropriate device callbacks. //! //! @Note Prior calling the function wlan_init shall be called. -//! @Warning This function must be called after wlan_init and before any +//! @Warning This function must be called after wlan_init and before any //! other wlan API //! @sa wlan_init , wlan_stop //! @@ -179,23 +179,23 @@ extern void wlan_stop(void); //! wlan_connect //! //! @param sec_type security options: -//! WLAN_SEC_UNSEC, +//! WLAN_SEC_UNSEC, //! WLAN_SEC_WEP (ASCII support only), //! WLAN_SEC_WPA or WLAN_SEC_WPA2 //! @param ssid up to 32 bytes and is ASCII SSID of the AP //! @param ssid_len length of the SSID //! @param bssid 6 bytes specified the AP bssid //! @param key up to 16 bytes specified the AP security key -//! @param key_len key length +//! @param key_len key length //! -//! @return On success, zero is returned. On error, negative is returned. +//! @return On success, zero is returned. On error, negative is returned. //! Note that even though a zero is returned on success to trigger //! connection operation, it does not mean that CCC3000 is already -//! connected. An asynchronous "Connected" event is generated when +//! connected. An asynchronous "Connected" event is generated when //! actual association process finishes and CC3000 is connected to -//! the AP. If DHCP is set, An asynchronous "DHCP" event is +//! the AP. If DHCP is set, An asynchronous "DHCP" event is //! generated when DHCP process is finish. -//! +//! //! //! @brief Connect to AP //! @warning Please Note that when connection to AP configured with security @@ -216,9 +216,9 @@ extern long wlan_connect(const char *ssid, long ssid_len); // //! wlan_disconnect //! -//! @return 0 disconnected done, other CC3000 already disconnected +//! @return 0 disconnected done, other CC3000 already disconnected //! -//! @brief Disconnect connection from AP. +//! @brief Disconnect connection from AP. //! //! @sa wlan_connect // @@ -237,25 +237,25 @@ extern long wlan_disconnect(void); //! @param ulPriority ulPriority profile priority. Lowest priority:0. //! @param ulPairwiseCipher_Or_TxKeyLen key length for WEP security //! @param ulGroupCipher_TxKeyIndex key index -//! @param ulKeyMgmt KEY management +//! @param ulKeyMgmt KEY management //! @param ucPf_OrKey security key //! @param ulPassPhraseLen security key length for WPA\WPA2 //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! //! @brief When auto start is enabled, the device connects to -//! station from the profiles table. Up to 7 profiles are supported. -//! If several profiles configured the device choose the highest -//! priority profile, within each priority group, device will choose -//! profile based on security policy, signal strength, etc +//! station from the profiles table. Up to 7 profiles are supported. +//! If several profiles configured the device choose the highest +//! priority profile, within each priority group, device will choose +//! profile based on security policy, signal strength, etc //! parameters. All the profiles are stored in CC3000 NVMEM. //! -//! @sa wlan_ioctl_del_profile +//! @sa wlan_ioctl_del_profile // //***************************************************************************** extern long wlan_add_profile(unsigned long ulSecType, unsigned char* ucSsid, - unsigned long ulSsidLen, + unsigned long ulSsidLen, unsigned char *ucBssid, unsigned long ulPriority, unsigned long ulPairwiseCipher_Or_Key, @@ -272,13 +272,13 @@ extern long wlan_add_profile(unsigned long ulSecType, unsigned char* ucSsid, //! //! @param index number of profile to delete //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! -//! @brief Delete WLAN profile +//! @brief Delete WLAN profile //! //! @Note In order to delete all stored profile, set index to 255. //! -//! @sa wlan_add_profile +//! @sa wlan_add_profile // //***************************************************************************** extern long wlan_ioctl_del_profile(unsigned long ulIndex); @@ -298,10 +298,10 @@ extern long wlan_ioctl_del_profile(unsigned long ulIndex); //! HCI_EVNT_WLAN_TX_COMPLETE - disable information on end of transmission //! Saved: no. //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! -//! @brief Mask event according to bit mask. In case that event is -//! masked (1), the device will not send the masked event to host. +//! @brief Mask event according to bit mask. In case that event is +//! masked (1), the device will not send the masked event to host. // //***************************************************************************** extern long wlan_set_event_mask(unsigned long ulMask); @@ -310,10 +310,10 @@ extern long wlan_set_event_mask(unsigned long ulMask); // //! wlan_ioctl_statusget //! -//! @param none +//! @param none //! -//! @return WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING, -//! STATUS_CONNECTING or WLAN_STATUS_CONNECTED +//! @return WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING, +//! STATUS_CONNECTING or WLAN_STATUS_CONNECTED //! //! @brief get wlan status: disconnected, scanning, connecting or connected // @@ -325,31 +325,31 @@ extern long wlan_ioctl_statusget(void); // //! wlan_ioctl_set_connection_policy //! -//! @param should_connect_to_open_ap enable(1), disable(0) connect to any -//! available AP. This parameter corresponds to the configuration of +//! @param should_connect_to_open_ap enable(1), disable(0) connect to any +//! available AP. This parameter corresponds to the configuration of //! item # 3 in the brief description. -//! @param should_use_fast_connect enable(1), disable(0). if enabled, tries -//! to connect to the last connected AP. This parameter corresponds +//! @param should_use_fast_connect enable(1), disable(0). if enabled, tries +//! to connect to the last connected AP. This parameter corresponds //! to the configuration of item # 1 in the brief description. -//! @param auto_start enable(1), disable(0) auto connect -//! after reset and periodically reconnect if needed. This +//! @param auto_start enable(1), disable(0) auto connect +//! after reset and periodically reconnect if needed. This //! configuration configures option 2 in the above description. //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! -//! @brief When auto is enabled, the device tries to connect according +//! @brief When auto is enabled, the device tries to connect according //! the following policy: -//! 1) If fast connect is enabled and last connection is valid, -//! the device will try to connect to it without the scanning +//! 1) If fast connect is enabled and last connection is valid, +//! the device will try to connect to it without the scanning //! procedure (fast). The last connection will be marked as -//! invalid, due to adding/removing profile. -//! 2) If profile exists, the device will try to connect it +//! invalid, due to adding/removing profile. +//! 2) If profile exists, the device will try to connect it //! (Up to seven profiles). //! 3) If fast and profiles are not found, and open mode is //! enabled, the device will try to connect to any AP. //! * Note that the policy settings are stored in the CC3000 NVMEM. //! -//! @sa wlan_add_profile , wlan_ioctl_del_profile +//! @sa wlan_add_profile , wlan_ioctl_del_profile // //***************************************************************************** extern long wlan_ioctl_set_connection_policy( @@ -364,30 +364,30 @@ extern long wlan_ioctl_set_connection_policy( //! @param[in] scan_timeout parameter not supported //! @param[out] ucResults scan result (_wlan_full_scan_results_args_t) //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! //! @brief Gets entry from scan result table. -//! The scan results are returned one by one, and each entry -//! represents a single AP found in the area. The following is a -//! format of the scan result: +//! The scan results are returned one by one, and each entry +//! represents a single AP found in the area. The following is a +//! format of the scan result: //! - 4 Bytes: number of networks found //! - 4 Bytes: The status of the scan: 0 - aged results, //! 1 - results valid, 2 - no results //! - 42 bytes: Result entry, where the bytes are arranged as follows: -//! +//! //! - 1 bit isValid - is result valid or not -//! - 7 bits rssi - RSSI value; +//! - 7 bits rssi - RSSI value; //! - 2 bits: securityMode - security mode of the AP: //! 0 - Open, 1 - WEP, 2 WPA, 3 WPA2 //! - 6 bits: SSID name length -//! - 2 bytes: the time at which the entry has entered into +//! - 2 bytes: the time at which the entry has entered into //! scans result table //! - 32 bytes: SSID name -//! - 6 bytes: BSSID +//! - 6 bytes: BSSID //! //! @Note scan_timeout, is not supported on this version. //! -//! @sa wlan_ioctl_set_scan_params +//! @sa wlan_ioctl_set_scan_params // //***************************************************************************** @@ -399,59 +399,59 @@ extern long wlan_ioctl_get_scan_results(unsigned long ulScanTimeout, // //! wlan_ioctl_set_scan_params //! -//! @param uiEnable - start/stop application scan: -//! 1 = start scan with default interval value of 10 min. -//! in order to set a different scan interval value apply the value +//! @param uiEnable - start/stop application scan: +//! 1 = start scan with default interval value of 10 min. +//! in order to set a different scan interval value apply the value //! in milliseconds. minimum 1 second. 0=stop). Wlan reset //! (wlan_stop() wlan_start()) is needed when changing scan interval //! value. Saved: No -//! @param uiMinDwellTime minimum dwell time value to be used for each +//! @param uiMinDwellTime minimum dwell time value to be used for each //! channel, in milliseconds. Saved: yes //! Recommended Value: 100 (Default: 20) //! @param uiMaxDwellTime maximum dwell time value to be used for each //! channel, in milliseconds. Saved: yes //! Recommended Value: 100 (Default: 30) -//! @param uiNumOfProbeRequests max probe request between dwell time. +//! @param uiNumOfProbeRequests max probe request between dwell time. //! Saved: yes. Recommended Value: 5 (Default:2) -//! @param uiChannelMask bitwise, up to 13 channels (0x1fff). +//! @param uiChannelMask bitwise, up to 13 channels (0x1fff). //! Saved: yes. Default: 0x7ff //! @param uiRSSIThreshold RSSI threshold. Saved: yes (Default: -80) //! @param uiSNRThreshold NSR threshold. Saved: yes (Default: 0) //! @param uiDefaultTxPower probe Tx power. Saved: yes (Default: 205) -//! @param aiIntervalList pointer to array with 16 entries (16 channels) -//! each entry (unsigned long) holds timeout between periodic scan +//! @param aiIntervalList pointer to array with 16 entries (16 channels) +//! each entry (unsigned long) holds timeout between periodic scan //! (connection scan) - in milliseconds. Saved: yes. Default 2000ms. //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! -//! @brief start and stop scan procedure. Set scan parameters. +//! @brief start and stop scan procedure. Set scan parameters. //! //! @Note uiDefaultTxPower, is not supported on this version. //! -//! @sa wlan_ioctl_get_scan_results +//! @sa wlan_ioctl_get_scan_results // //***************************************************************************** -extern long wlan_ioctl_set_scan_params(unsigned long uiEnable, unsigned long +extern long wlan_ioctl_set_scan_params(unsigned long uiEnable, unsigned long uiMinDwellTime,unsigned long uiMaxDwellTime, unsigned long uiNumOfProbeRequests, unsigned long uiChannelMask, long iRSSIThreshold,unsigned long uiSNRThreshold, - unsigned long uiDefaultTxPower, + unsigned long uiDefaultTxPower, unsigned long *aiIntervalList); - + //***************************************************************************** // //! wlan_smart_config_start //! //! @param algoEncryptedFlag indicates whether the information is encrypted //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! -//! @brief Start to acquire device profile. The device acquire its own +//! @brief Start to acquire device profile. The device acquire its own //! profile, if profile message is found. The acquired AP information //! is stored in CC3000 EEPROM only in case AES128 encryption is used. -//! In case AES128 encryption is not used, a profile is created by +//! In case AES128 encryption is not used, a profile is created by //! CC3000 internally. //! //! @Note An asynchronous event - Smart Config Done will be generated as soon @@ -459,7 +459,7 @@ extern long wlan_ioctl_set_scan_params(unsigned long uiEnable, unsigned long //! //! @sa wlan_smart_config_set_prefix , wlan_smart_config_stop // -//***************************************************************************** +//***************************************************************************** extern long wlan_smart_config_start(unsigned long algoEncryptedFlag); @@ -469,9 +469,9 @@ extern long wlan_smart_config_start(unsigned long algoEncryptedFlag); //! //! @param algoEncryptedFlag indicates whether the information is encrypted //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! -//! @brief Stop the acquire profile procedure +//! @brief Stop the acquire profile procedure //! //! @sa wlan_smart_config_start , wlan_smart_config_set_prefix // @@ -482,11 +482,11 @@ extern long wlan_smart_config_stop(void); // //! wlan_smart_config_set_prefix //! -//! @param newPrefix 3 bytes identify the SSID prefix for the Smart Config. +//! @param newPrefix 3 bytes identify the SSID prefix for the Smart Config. //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! -//! @brief Configure station ssid prefix. The prefix is used internally +//! @brief Configure station ssid prefix. The prefix is used internally //! in CC3000. It should always be TTT. //! //! @Note The prefix is stored in CC3000 NVMEM @@ -500,11 +500,11 @@ extern long wlan_smart_config_set_prefix(char* cNewPrefix); // //! wlan_smart_config_process //! -//! @param none +//! @param none //! -//! @return On success, zero is returned. On error, -1 is returned +//! @return On success, zero is returned. On error, -1 is returned //! -//! @brief process the acquired data and store it as a profile. The acquired +//! @brief process the acquired data and store it as a profile. The acquired //! AP information is stored in CC3000 EEPROM encrypted. //! The encrypted data is decrypted and stored as a profile. //! behavior is as defined by connection policy.