//PBAP deinitialization code goes here
result = bt_pbap_client_unset_connection_state_changed_cb();
RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_unset_connection_state_changed_cb fail > Error = %s", get_bluetooth_error(result));
- result = bt_pbap_client_disconnect(view->selected_device_info->remote_address);
- RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_disconnect fail > Error = %s", get_bluetooth_error(result));
+ if(view->selected_device_info && view->selected_device_info->remote_address)
+ {
+ result = bt_pbap_client_disconnect(view->selected_device_info->remote_address);
+ RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_disconnect fail > Error = %s", get_bluetooth_error(result));
+ }
result = bt_pbap_client_deinitialize();
RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_deinitialize fail > Error = %s", get_bluetooth_error(result));
}