Bluetooth Classic Congestion after few minutes

Jonathan
Posts: 1
Joined: Fri Jul 20, 2018 10:24 am

Bluetooth Classic Congestion after few minutes

Postby Jonathan » Fri Jul 20, 2018 10:49 am

Hello,

I am sending data over SPP classic bluetooth between esp32 and androïd phone. The ESP32 send 500 bytes every 100ms. My problem is that I am entering in congestion after few minutes and the bluetooth communication fails after that. The problem is the same with multiple android supports (tablet or phone).

Thanks for your help.

My code for init the bluetooth :

Code: Select all

void btc::_initBt() 
{    
    // init nvs flash
    if (nvs_flash_init() == ESP_ERR_NVS_NO_FREE_PAGES) {
        nvs_flash_erase();
        nvs_flash_init();
    }    

    // initialize controller stack (low level)
    if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) {
        esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
        
        esp_bt_controller_init(&bt_cfg);
        esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT);
        esp_bredr_tx_power_set(ESP_PWR_LVL_N2, ESP_PWR_LVL_P1);       
    }

    // init bluedroid host stack (high level)
    if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
        esp_bluedroid_init();
        esp_bluedroid_enable();
    }    

    // register callback btc event
    esp_spp_register_callback(_static_esp_spp_cb);
    esp_spp_init(ESP_SPP_MODE_CB);  
}

void btc::_static_esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
{
    esp_spp_cb_event_t ev = event;
    switch (event) {
        case ESP_SPP_INIT_EVT:   
            // set scan mode
            esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
            esp_bt_dev_set_device_name("ESP_BT");                            
            esp_spp_start_srv(ESP_SPP_SEC_NONE, ESP_SPP_ROLE_SLAVE, 0, "SPP_SERVER");
            break;  
        case ESP_SPP_START_EVT:        
            break;  
        case ESP_SPP_WRITE_EVT:
            break;    
        case ESP_SPP_SRV_OPEN_EVT:         
            g_btc->_connected(param->srv_open.handle); 
            break;        
        case ESP_SPP_DISCOVERY_COMP_EVT:        
            break;
        case ESP_SPP_OPEN_EVT:    
            break;        
        case ESP_SPP_CLOSE_EVT:  
            g_btc->_disconnected();
            break;
       
        case ESP_SPP_CL_INIT_EVT:     
            break;
        case ESP_SPP_DATA_IND_EVT:
            break;
        case ESP_SPP_CONG_EVT:  // CONGESTION          
            if (param->cong.cong == true) {
                g_btc->m_bCongest = true;
            }
            else {
                g_btc->m_bCongest = false;
            }
            break;               
        default:
            break;              
    }
}

FCT_IOT
Posts: 37
Joined: Fri Jan 26, 2018 11:15 am

Re: Bluetooth Classic Congestion after few minutes

Postby FCT_IOT » Sat Jul 21, 2018 10:24 am

Dear @Jonathan,

I could not find the AT commands for classic bluetooth communication. Request you to let me know how you have gone about implementing the Classic Bluetooth communication.

Thanks in advance.

DXK_1987
Posts: 2
Joined: Fri May 22, 2020 3:33 pm

Re: Bluetooth Classic Congestion after few minutes

Postby DXK_1987 » Fri May 22, 2020 3:37 pm

I have the same problem with the classic bluetooth, at the moment of connecting it to android everything works correctly, but when I get too far away it loses the signal and the esp32 crashes. and I can not do anything the communication is cut and I can only restart it manually. any solution?

Who is online

Users browsing this forum: No registered users and 107 guests