Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0d564d7

Browse filesBrowse files
mouridisme-no-dev
authored andcommitted
Limit the number of simultaneously connected devices to BluetoothSerial to only 1 (espressif#2061)
1 parent 44ca2ee commit 0d564d7
Copy full SHA for 0d564d7

File tree

1 file changed

+12
-2
lines changed
Filter options

1 file changed

+12
-2
lines changed

‎libraries/BluetoothSerial/src/BluetoothSerial.cpp

Copy file name to clipboardExpand all lines: libraries/BluetoothSerial/src/BluetoothSerial.cpp
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static xQueueHandle _spp_tx_queue = NULL;
5050
static SemaphoreHandle_t _spp_tx_done = NULL;
5151
static TaskHandle_t _spp_task_handle = NULL;
5252
static EventGroupHandle_t _spp_event_group = NULL;
53+
static boolean secondConnectionAttempt;
5354

5455
#define SPP_RUNNING 0x01
5556
#define SPP_CONNECTED 0x02
@@ -162,13 +163,22 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
162163
break;
163164

164165
case ESP_SPP_SRV_OPEN_EVT://Server connection open
165-
_spp_client = param->open.handle;
166+
if (!_spp_client){
167+
_spp_client = param->open.handle;
168+
} else {
169+
secondConnectionAttempt = true;
170+
esp_spp_disconnect(param->open.handle);
171+
}
166172
xEventGroupSetBits(_spp_event_group, SPP_CONNECTED);
167173
log_i("ESP_SPP_SRV_OPEN_EVT");
168174
break;
169175

170176
case ESP_SPP_CLOSE_EVT://Client connection closed
171-
_spp_client = 0;
177+
if(secondConnectionAttempt) {
178+
secondConnectionAttempt = false;
179+
} else {
180+
_spp_client = 0;
181+
}
172182
xEventGroupClearBits(_spp_event_group, SPP_CONNECTED);
173183
log_i("ESP_SPP_CLOSE_EVT");
174184
break;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.