cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Studio Wi-Fi Combo

CrDe_3090586
New Contributor II

We're having an issue with connecting to Google IOT Cloud using the MQTT bridge​ and TLS on CYW943907AEVAL1F running the latest Wiced Studio 6.1 (WICED-Studio-6.1.0.85-IDE-Installer). 

I've narrowed down the issue to a couple methods, but cannot for the life of me figure out what the code is supposed to be doing.

in wiced_tls.c, there is this method (~line 625):

  static int ssl_receive_packet( void *ctx, unsigned char **buf, size_t len )

... which (~line 710):invokes wiced_packet_get_data .... which returns 4

else

    {

        WPRINT_SECURITY_DEBUG (("Skip [%d] no of bytes from TCP received packet with length : [%d]\n",

                socket->tls_context->context.received_packet_bytes_skipped,

                socket->tls_context->context.received_packet_length ));

        result = wiced_packet_get_data( (wiced_packet_t*)socket->tls_context->context.received_packet,

                socket->tls_context->context.received_packet_bytes_skipped, (uint8_t**) ( buf ),

                (uint16_t*)&length, &available_data_length );

        if ( result != WICED_SUCCESS )

        {

            WPRINT_SECURITY_DEBUG (("wiced_packet_get_data failed with result : [%d] \n",  result ));

            return result;

        }

Therefore, with debugging turned on results in:

Skip [33] no of bytes from TCP received packet with length : [33]

wiced_packet_get_data failed with result : [4]

According to the MQTT protocol, it looks to me like everything went fine during the MQTT Connect (Connect ACK) return indicates success.

WICED/security/BESL/mbedtls_open/library/ssl_tls.c:1939: dumping 'raw buffer after decryption' (4 bytes)

WICED/security/BESL/mbedtls_open/library/ssl_tls.c:1939: 0000:  20 02 00 00 

I've attached a log with debugging turned on, along with some additional debugging.

Any help would be appreciated as this is a blocking issue....

Thanks in advance.

============================================================================================================

Highlighted below are the additional logging statements added to the tcp_ip.c module ~(Line 914):

============================================================================================================

wiced_result_t wiced_packet_get_data( wiced_packet_t* packet, uint16_t offset, uint8_t** data,

        uint16_t* fragment_available_data_length, uint16_t *total_available_data_length )

{

    NX_PACKET* first_packet      = packet;

    NX_PACKET* iter              = packet;

    uint16_t   requested_offset  = offset;

    uint16_t   fragment_length;

    wiced_assert( "Bad args", (packet != NULL) && (data != NULL) && (fragment_available_data_length != NULL) &&

            (total_available_data_length != NULL) );

    while ( iter != NULL )

    {

        /* It is more appropriate to use the difference between nx_packet_append_ptr and nx_packet_prepend_ptr rather

         * than nx_packet_length. If the packet was fragmented the nx_packet_length will reflect the sum of the data length of all

         * fragments, not the length of the fragment alone */

        fragment_length = (uint16_t)( iter->nx_packet_append_ptr - iter->nx_packet_prepend_ptr );

        WPRINT_APP_INFO(("[TCPIP] wpgd loop1-frag_len[%u], frag_av_len[%u] offset[%u], nx_PLen:[%lu], nx_app_ptr[%u] nx_pre_ptr[%u]\n",

                 fragment_length, *fragment_available_data_length, offset, iter->nx_packet_length,

                 *iter->nx_packet_append_ptr,  *iter->nx_packet_prepend_ptr ));

        if ( iter->nx_packet_length == 0 )

        {

            *data                           = NULL;

            *fragment_available_data_length = 0;

            *total_available_data_length    = 0;

            return WICED_TCPIP_SUCCESS;

        }

        else if ( offset < fragment_length )

        {

            *data = iter->nx_packet_prepend_ptr + offset;

            *fragment_available_data_length = (uint16_t) ( iter->nx_packet_append_ptr - *data );

            /* This will give number of bytes available after this offset including this packet and further packets in the chain */

            *total_available_data_length    = (uint16_t) ( first_packet->nx_packet_length - requested_offset );

            return WICED_TCPIP_SUCCESS;

        }

        else

        {

            offset = (uint16_t) ( offset - ( iter->nx_packet_append_ptr - iter->nx_packet_prepend_ptr ) );

        }

        WPRINT_APP_INFO(("[TCPIP] wpgd loop - frag_len[%u], frag_avail_len[%u] offset[%u], nx_PLen:[%lu]\n",

                fragment_length, *fragment_available_data_length, offset, iter->nx_packet_length ));

        iter = iter->nx_packet_next;

    }

    WPRINT_APP_INFO(("[TCPIP] wpgd out packet:[lu] offset[%u] data[%d] frag avail[%u] tot[%u]...\n",

            //*packet->dummy,

            offset, **data, *fragment_available_data_length, *total_available_data_length));

    return WICED_TCPIP_ERROR;

}

0 Likes
1 Reply
GauravS_31
Moderator
Moderator

From the logs, the TLS handshake is successful and the data could be encrypted and decrypted. At the end, I could see "... connection success, press button to proceed with publish". The errors that you have shown are also seen in snip.secure_mqtt but publish and subscribe are successful. It is not clear what specific problem you are facing on your side. Please elaborate. Do you get a publish failure when trying to publish?