@@ -196,32 +196,34 @@ class AdvertisedDeviceCallbacks : public NimBLEAdvertisedDeviceCallbacks
196
196
protected:
197
197
void onResult (NimBLEAdvertisedDevice *advertisedDevice)
198
198
{
199
- if (enableConnection) // not begin() or end()
199
+ if (! enableConnection) // not begin() or end()
200
200
{
201
- DEBUGCLIENT (" Advertised Device found: " );
202
- DEBUGCLIENT (advertisedDevice->toString ().c_str ());
203
- if (advertisedDevice->isAdvertisingService (NimBLEUUID (SERVICE_UUID)))
204
- {
205
- DEBUGCLIENT (" Found MIDI Service" );
206
- if (!specificTarget || (advertisedDevice->getName () == nameTarget.c_str () || advertisedDevice->getAddress () == nameTarget))
207
- {
208
- /* * Ready to connect now */
209
- doConnect = true ;
210
- /* * Save the device reference in a public variable that the client can use*/
211
- advDevice = *advertisedDevice;
212
- /* * stop scan before connecting */
213
- NimBLEDevice::getScan ()->stop ();
214
- }
215
- else
216
- {
217
- DEBUGCLIENT (" Name error" );
218
- }
219
- }
220
- else
221
- {
222
- doConnect = false ;
223
- }
201
+ return ;
202
+ }
203
+
204
+ DEBUGCLIENT (" Advertised Device found: " );
205
+ DEBUGCLIENT (advertisedDevice->toString ().c_str ());
206
+ if (!advertisedDevice->isAdvertisingService (NimBLEUUID (SERVICE_UUID)))
207
+ {
208
+ doConnect = false ;
209
+ return ;
210
+ }
211
+
212
+ DEBUGCLIENT (" Found MIDI Service" );
213
+ if (!(!specificTarget || (advertisedDevice->getName () == nameTarget.c_str () || advertisedDevice->getAddress () == nameTarget)))
214
+ {
215
+ DEBUGCLIENT (" Name error" );
216
+ return ;
224
217
}
218
+
219
+ /* * Ready to connect now */
220
+ doConnect = true ;
221
+ /* * Save the device reference in a public variable that the client can use*/
222
+ advDevice = *advertisedDevice;
223
+ /* * stop scan before connecting */
224
+ NimBLEDevice::getScan ()->stop ();
225
+
226
+ return ;
225
227
};
226
228
};
227
229
0 commit comments