3 Replies Latest reply on Apr 21, 2015 7:48 AM by javipe

    Read large amount of data from a TCP socket



      I'm newbie in WICED SDK and I'm trying to read all the packets received from an streaming radio. I only receive a few packets, after this the socket is closed. I'm using SDK 2.4.1 (the last suported for the SN8200 platform). I read and print the packet data with this (modified) source code:


          uint16_t amount_to_read;
          uint16_t total_available;
          uint8_t* packet_data     = NULL;
          uint16_t space_available = 0;
          rx_result = wiced_tcp_receive( &socket, &rx_packet, timeout );
          if ( rx_packet == NULL ){
              rx_result = wiced_tcp_receive( &socket, &rx_packet, timeout );
              if ( result != WICED_SUCCESS){
                  WPRINT_APP_INFO(( "Error\r\n" ));
          wiced_packet_get_data( rx_packet, 0, &packet_data, &space_available, &total_available);
          amount_to_read = MIN( BUFFER_LENGTH, space_available );
          memcpy( buffer, packet_data, amount_to_read);
          // Print packet data
          buffer[ BUFFER_LENGTH ] = 0x0;
          WPRINT_APP_INFO(( "%s", buffer ));
          /* Check if we need a new packet */
          if ( amount_to_read == space_available ){
              wiced_packet_delete( rx_packet );
              rx_packet = NULL;
              /* Otherwise update the start of the data for the next read request */
              wiced_packet_set_data_start( rx_packet, packet_data + amount_to_read);
      }while ( rx_result == WICED_SUCCESS );


      I don't know if I'm doing something wrong or if there are any limitation (amount of data received, memory stack...).


      Any suggestion will be appreciated.