WICED 3.7.0 - Bug in Smartbridge BLE notifications ?

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

cross mob
Not applicable

As I am working with Smartbridge, I need to use BLE notifications. The first thing I've done for it is to specify a pointer to my notification callback in the wiced_bt_smartbridge_connect() arguments as following :

wiced_bt_smartbridge_connect( &sb_socket, &device, &sb_connection_settings, custom_disconnection_delegate, custom_notification_delegate );

But my callback is never called. So, I checked the content of this function, and I've seen that it calls the following one :

wiced_result_t smartbridge_bt_interface_connect( const wiced_bt_smart_device_t* remote_device, const wiced_bt_smart_connection_settings_t* settings, wiced_bt_smartbridge_disconnection_callback_t disconnection_callback, wiced_bt_smartbridge_notification_callback_t notification_callback )


    wiced_bool_t gatt_connect_result;



    /* Update the Stack's configuration */

    wiced_bt_cfg_settings.ble_scan_cfg.conn_min_interval = settings->interval_min;

    wiced_bt_cfg_settings.ble_scan_cfg.conn_max_interval = settings->interval_max;

    wiced_bt_cfg_settings.ble_scan_cfg.conn_latency = settings->latency;

    wiced_bt_cfg_settings.ble_scan_cfg.conn_supervision_timeout = settings->supervision_timeout;

    /* Send connection request */

    gatt_connect_result = wiced_bt_gatt_le_connect( (uint8_t *)remote_device->address, remote_device->address_type, BLE_CONN_MODE_HIGH_DUTY, WICED_TRUE);

    WPRINT_LIB_INFO(("[Smartbridge] LE-connect, result:%d\n", gatt_connect_result));

    return gatt_connect_result;


Here we have UNUSED_PARAMETER(notification_callback) which means, I suppose, that notifications are not supported yet ?

But as I really want notifications, I decided to try to find a workaround, and I declared myself the notification callback in the socket structure :

sb_socket.notification_callback = custom_notification_delegate;

And then I investigated a little bit more to find where this callback is called. I noticed that the notification is first processed by smartbridge_gatt_notification_indication_handler() in wiced_bt_smartbridge.c, and then delegated to the user's callback through this line :

wiced_rtos_send_asynchronous_event( WICED_NETWORKING_WORKER_THREAD, smartbridge_app_notification_handler, (void*)socket );

And this is exactly where the issue comes from : the smartbridge_app_notification_handler() is never performed/processed by the given thread.

I can't explain why, so as a workaround (not a very elegant one, I should admit), I decided to replace the dispatch mechanism by a direct call to the handler, and it works like a charm so I'll keep it like this for now, but I would like your advice to change this in a more convenient way.

Thanks for your help !

1 Reply
250 sign-ins 25 comments on blog 10 comments on blog

Thanks for the feedback romain

I went ahead a created a bug tracking request internally so that the SW team could review and consider this fix for the next release of the SDK.