Initializing BT stack under 3.4.0-AWS

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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?

0 Likes
1 Solution

hey andrew997

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

View solution in original post

0 Likes
8 Replies
VikramR_26
Employee
Employee
25 sign-ins 10 sign-ins 10 comments on KBA

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

Anonymous
Not applicable

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:

pastedImage_7.png

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

pastedImage_8.png

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

0 Likes

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

andrew997

0 Likes

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 );
0 Likes
Anonymous
Not applicable

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;



0 Likes

let me look at it and get back to you.

0 Likes
Anonymous
Not applicable

Any updates?

0 Likes

hey andrew997

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

0 Likes