rgot-org cec3fca4ad Fix BluetoothSerial crash when restart (#3471)
* Update esp32-hal-bt.c

BluetoothSerial crash when restart:  this is because the BT controller remains in state  ESP_BT_CONTROLLER_STATUS_INITED instead of state  ESP_BT_CONTROLLER_STATUS_IDLE after the end() method.
in file esp_bt.h it is specified

> @brief Enable BT controller.
>                Due to a known issue, you cannot call esp_bt_controller_enable() a second time
>                 to change the controller mode dynamically. To change controller mode, call
>                esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.

after **esp_bt_controller_disable()** the controller remains in state INITED so we do call the **esp_bt_controller_deinit()** function to put the controller into state IDLE.

i have modified the **esp32-hal-bt.c** file
line 57 and next
(i have insert the esp_bt_controller_deinit() function so the controller go into Idle state)
```c++
bool btStop(){
    if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE){
		log_i("bt stopped");
        return true;
    }
    if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED){
		log_i("bt enabled");
        if (esp_bt_controller_disable()) {
            log_e("BT Disable failed");
            return false;
        }
        while(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED);
    }
    if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_INITED){
		log_i("inited");
		if (esp_bt_controller_deinit()) {
			log_e("BT deint failed");
			return false;
		}
		while (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_INITED);
        return true;
    }
    log_e("BT Stop failed");
    return false;
}
```

* Update esp32-hal-bt.c

remove while to avoid infinite loop
2019-11-11 18:31:09 +01:00
..
2016-10-06 07:09:44 -06:00
2016-10-06 07:09:44 -06:00
2018-12-28 19:14:15 +02:00
2017-01-09 18:05:30 +02:00
2016-10-06 07:09:44 -06:00
2016-10-06 07:09:44 -06:00
2019-05-01 20:10:41 +03:00
2019-09-24 19:25:27 +03:00
2016-12-09 17:47:30 +02:00
2016-12-12 01:32:55 +02:00
2016-12-12 01:32:55 +02:00
2017-01-06 00:54:50 +02:00
2017-01-06 00:54:50 +02:00
2019-10-04 12:49:39 +03:00
2016-10-06 07:09:44 -06:00
2016-10-06 07:09:44 -06:00
2016-10-06 07:09:44 -06:00
2018-06-27 09:01:06 +02:00
2016-10-06 07:09:44 -06:00
2019-05-11 11:16:05 +03:00
2016-10-06 07:09:44 -06:00
2016-10-06 07:09:45 -06:00
2017-01-20 21:49:17 +02:00
2019-06-05 13:48:13 +02:00