8 Replies Latest reply on Dec 7, 2015 5:07 PM by VikramR_26

    Initializing BT stack under 3.4.0-AWS

      Hi,

       

      I'm trying to add BLE functionality to the the demo/aws_iot/shadow app.  The issue I'm seeing is once I enable the BT stack, the Wi-Fi side of things stops working.  In fact, the BT side doesn't work either outside of successfully broadcasting ADVs.  I'm targeting the BCM4343W_AVN platform.

       

      Note that I'm able to work with the BLE-standalone snips that don't use Wi-Fi such as ble_proximity_reporter.  They behave as expected.

       

      Question:  When enabling both BT and Wi-FI, what's the appropriate procedure for doing this?  What order do I need to call the enabling APIs (ie, wiced_bt_stack_init(), wiced_network_up(), etc) and when do I call them?  Are there any rules I need to follow in terms of allowing time for the stacks to initialize?

        • 1. Re: Initializing BT stack under 3.4.0-AWS
          VikramR_26

          Try referring to the following application under demo -->bt_smartbridge

          • 2. Re: Initializing BT stack under 3.4.0-AWS

            Is bt_smartbridge even supported? I thought bt_internet_gateway or BIG would be supported for this function moving forward?

             

            At this point I'm wondering if something else is going on with my code.  If I don't enable Bluetooth, the aws_iot/shadow app I'm starting from works fine:

             

             

            If I enable the Bluetooth stack, here's what happens:

             

             

            Not exactly sure what's happening but it's going off into the weeds in aws_common.c. 

            • 3. Re: Initializing BT stack under 3.4.0-AWS
              MichaelF_56

              I confirmed yesterday that both BIG and SmartBridge will be supported moving forward.

               

              ankr_1205151

              • 4. Re: Initializing BT stack under 3.4.0-AWS
                VikramR_26

                Since you have enabled the bluetooth stack, the memory section is getting corrupted. Due to this the certificates are not getting loaded properly in DCT. I would suggest you to read the certificates during compilation by. You would have to remove the section of code to enter AP mode.

                Use the below approach in order to load the certificates, and also print out them to make sure the certificates are intact.

                 

                resource_get_readonly_buffer( &resources_apps_DIR_aws_iot_DIR_rootca_cer, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.ca_cert );
                resource_get_readonly_buffer( &resources_apps_DIR_aws_iot_DIR_privkey_cer, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.key );
                resource_get_readonly_buffer( &resources_apps_DIR_aws_iot_DIR_client_cer, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.cert );
                • 5. Re: Initializing BT stack under 3.4.0-AWS

                  Hi vikram,

                   

                  Your approach is exactly what I did - and I did print the certificates out to the console to verify they were correct.  To be clear, I added in the certs under the resources section of the .mk file and I modified aws_config_dct.c such that .is_configured = WICED_TRUE along with my thing name.  I did this specifically so the design would boot directly into STA mode and bypass the standard AWS/AP configuration cycle. 

                   

                  /* Read security parameters from DCT */

                      resource_get_readonly_buffer( &resources_apps_DIR_aws_iot_DIR_rootca_cer, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.ca_cert );

                      // AK added these two lines

                      resource_get_readonly_buffer( &resources_apps_DIR_aws_iot_DIR_privkey_cer, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.key );

                      resource_get_readonly_buffer( &resources_apps_DIR_aws_iot_DIR_client_cer, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.cert );

                   

                      /* Lock the DCT to allow us to access the certificate and key */

                      WPRINT_APP_INFO(( "Reading the certificate and private key from DCT...\n" ));

                      ret = wiced_dct_read_lock( (void**) &dct_security, WICED_FALSE, DCT_SECURITY_SECTION, 0, sizeof( *dct_security ) );

                      if ( ret != WICED_SUCCESS )

                      {

                          WPRINT_APP_INFO(("Unable to lock DCT to read certificate\n"));

                          return ret;

                      }

                      //security.cert = dct_security->certificate;

                      //security.key = dct_security->private_key;



                  • 6. Re: Initializing BT stack under 3.4.0-AWS
                    VikramR_26

                    let me look at it and get back to you.

                    • 8. Re: Initializing BT stack under 3.4.0-AWS
                      VikramR_26

                      hey ankr_1205151

                       

                      on porting the existing smart_bridge api's over the aws iot application I did not see any issue initializing the ble stack

                       

                      /* Initialise WICED Bluetooth Framework */
                      wiced_bt_init( WICED_BT_HCI_MODE, "SmartBridge Device" );

                       

                      /* Initialise WICED SmartBridge */
                      wiced_bt_smartbridge_init();

                       

                      /* Set maximum concurrent connections */
                      //wiced_bt_smartbridge_set_max_concurrent_connections( MAX_CONCURRENT_CONNECTIONS );

                       

                      /* Enable Attribute Cache and set maximum number of caches */

                      wiced_bt_smartbridge_enable_attribute_cache( MAX_CONCURRENT_CONNECTIONS );

                       

                       

                       

                      Could you kindly try the same.

                       

                      -vik86