wiced_bt_rfcomm_create_connection return WICED_BT_RFCOMM_NO_RESOURCES

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

cross mob
aglier
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

Hi there,

 

I'm trying to connect via HCI commands to a SPP capable device.

I merged two examples but I always receive WICED_BT_RFCOMM_NO_RESOURCES code inside spp_rfcomm_start_server();

Registration setup:

/* SPP SEVER1 */
wiced_bt_spp_reg_t spp_reg1 =
{
    SPP_RFCOMM_SCN1,                    /* RFCOMM service channel number for SPP connection */
    MAX_TX_BUFFER,                      /* RFCOMM MTU for SPP connection */
    spp_connection_up_callback,         /* SPP connection established */
    spp_connection_failed_callback,     /* SPP connection establishment failed */
    spp_service_not_found_callback,     /* SPP service not found */
    spp_connection_down_callback,       /* SPP connection disconnected */
    spp_rx_data_callback,               /* Data packet received */
};

 App cfg buffer pools: 

const wiced_bt_cfg_buf_pool_t wiced_app_cfg_buf_pools[WICED_BT_CFG_NUM_BUF_POOLS] =
{
/*  { buf_size, buf_count } */
    { 64,       16        }, /* Small Buffer Pool */
    { 360,      5         }, /* Medium Buffer Pool (used for HCI & RFCOMM control messages, min recommended size is 360) */
    { 1024,     9         }, /* Large Buffer Pool (used for HCI ACL messages and GATT DB) */
    { 2048,     2         }, /* Extra Large Buffer Pool - Used for GATT DB and miscellaneous */
};

Spp init:

/*
 * SPP initialization
 */
void hci_spp_init()
{

	/* Make device connectable (enables page scan) using default connectability window/interval.
	 * The corresponding parameters are contained in 'wiced_bt_cfg.c' */
	/* TODO: Make sure that this is the desired behavior. */
	wiced_bt_dev_set_connectability(BTM_CONNECTABLE, BTM_DEFAULT_CONN_WINDOW, BTM_DEFAULT_CONN_INTERVAL);

	/* Make device discoverable (enables inquiry scan) over BR/EDR using default discoverability window/interval.
	 * The corresponding parameters are contained in 'wiced_bt_cfg.c' */
	/* TODO: Make sure that this is the desired behavior. */
	wiced_bt_dev_set_discoverability(BTM_GENERAL_DISCOVERABLE, BTM_DEFAULT_DISC_WINDOW, BTM_DEFAULT_DISC_INTERVAL);

    // Initialize 1st SPP Server
    wiced_bt_spp_startup(&spp_reg1);

    wiced_init_timer(&spp_transport_flow_control_timer, spp_transport_flow_control_timeout, 0, WICED_MILLI_SECONDS_TIMER);
    wiced_init_timer(&spp_ota_flow_control_timer, spp_ota_flow_control_timeout, 0, WICED_MILLI_SECONDS_TIMER);
}

 

What causes this issue WICED_BT_RFCOMM_NO_RESOURCES?

 

Best regards

Alex

0 Likes
1 Solution
aglier
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

Sorry, my mistake.

If somebody comes accross this issue:

I had a mistake in my wiced_bt_cfg_settings_t.

.rfcomm_cfg =                                                                                    // RFCOMM configuration
    {
        .max_links                      = 1,                                                         // Maximum number of simultaneous connected remote devices*/
        .max_ports                      = 1                                                          // Maximum number of simultaneous RFCOMM ports
    },

These parameters were set to 0....

 

View solution in original post

3 Replies
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

Kindly check wiced_bt_rfcomm_create_connection documentation in wiced_bt_rfcomm.h. It says:

 

wiced_bt_rfcomm_result_t wiced_bt_rfcomm_create_connection (uint16_t uuid, uint8_t scn,
wiced_bool_t is_server, uint16_t mtu,
wiced_bt_device_address_t bd_addr,
uint16_t *p_handle,
wiced_bt_port_mgmt_cback_t *p_mgmt_cb);

@return

WICED_BT_RFCOMM_SUCCESS: If successful
WICED_BT_RFCOMM_ALREADY_OPENED : If the client tries to establish a connection to the same BD_ADDR
WICED_BT_RFCOMM_NO_RESOURCES : If there is not enough memory to allocate a control block structure

 

In short, it seems like the application couldnt register wiced_bt_spp_reg_t properly.

Below APIs will help you to monitor the memory usage. Please try to modify the allocated buffers, if you see any buffer overflow. If there is no enough RAM, then please optimize the code.

  • wiced_memory_get_free_bytes
  • wiced_bt_get_buffer_usage

 

Thanks,

-Dheeraj.P.K

0 Likes

HI @DheerajPK_41 ,

 

thank you for your tipps.

 

Here is the output of :

WICED_BT_TRACE("Free mem:%d\n", wiced_memory_get_free_bytes());
		wiced_bt_get_buffer_usage (buffer_stats, sizeof(buffer_stats));

		WICED_BT_TRACE("0:%d/%d 1:%d/%d 2:%d/%d 3:%d/%d\n", buffer_stats[0].current_allocated_count, buffer_stats[0].max_allocated_count,
					   buffer_stats[1].current_allocated_count, buffer_stats[1].max_allocated_count,
					   buffer_stats[2].current_allocated_count, buffer_stats[2].max_allocated_count,
					   buffer_stats[3].current_allocated_count, buffer_stats[3].max_allocated_count);

        rfcomm_result = wiced_bt_rfcomm_create_connection(UUID_SERVCLASS_SERIAL_PORT,
                                                           p_scb->p_spp_reg->rfcomm_scn, WICED_TRUE, p_scb->p_spp_reg->rfcomm_mtu,
                                                           bd_addr_any, &p_scb->rfc_serv_handle,
                                                           (wiced_bt_port_mgmt_cback_t *)spp_rfcomm_control_callback);

 

Free mem:70656<LF>
0:256/0 1:0/0 2:8663/0 3:33/42629<LF>

 

Does this make sense?

0 Likes
aglier
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

Sorry, my mistake.

If somebody comes accross this issue:

I had a mistake in my wiced_bt_cfg_settings_t.

.rfcomm_cfg =                                                                                    // RFCOMM configuration
    {
        .max_links                      = 1,                                                         // Maximum number of simultaneous connected remote devices*/
        .max_ports                      = 1                                                          // Maximum number of simultaneous RFCOMM ports
    },

These parameters were set to 0....