Fix BTserial memory leaks (#1801)
- Delete queue at end - Close BT connection before end - DeInit SPP
This commit is contained in:
parent
80c110ece7
commit
a0f0bd930c
@ -152,6 +152,9 @@ static bool _init_bt(const char *deviceName)
|
|||||||
static bool _stop_bt()
|
static bool _stop_bt()
|
||||||
{
|
{
|
||||||
if (btStarted()){
|
if (btStarted()){
|
||||||
|
if(_spp_client)
|
||||||
|
esp_spp_disconnect(_spp_client);
|
||||||
|
esp_spp_deinit();
|
||||||
esp_bluedroid_disable();
|
esp_bluedroid_disable();
|
||||||
esp_bluedroid_deinit();
|
esp_bluedroid_deinit();
|
||||||
btStop();
|
btStop();
|
||||||
@ -172,6 +175,7 @@ BluetoothSerial::BluetoothSerial()
|
|||||||
BluetoothSerial::~BluetoothSerial(void)
|
BluetoothSerial::~BluetoothSerial(void)
|
||||||
{
|
{
|
||||||
_stop_bt();
|
_stop_bt();
|
||||||
|
vQueueDelete(_spp_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BluetoothSerial::begin(String localName)
|
bool BluetoothSerial::begin(String localName)
|
||||||
@ -262,6 +266,7 @@ void BluetoothSerial::flush()
|
|||||||
void BluetoothSerial::end()
|
void BluetoothSerial::end()
|
||||||
{
|
{
|
||||||
_stop_bt();
|
_stop_bt();
|
||||||
|
vQueueDelete(_spp_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user