File tree 5 files changed +102
-12
lines changed
5 files changed +102
-12
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,16 @@ void setup() {
42
42
Serial.println (" Bluetooth® Low Energy Central - LED control" );
43
43
44
44
// start scanning for peripherals
45
- BLE.scanForUuid (" 19b10000-e8f2-537e-4f6c-d104768a1214" );
45
+ int ret = 1 ;
46
+ do
47
+ {
48
+ ret = BLE.scanForUuid (" 19b10000-e8f2-537e-4f6c-d104768a1214" );
49
+ if (ret == 0 )
50
+ {
51
+ BLE.end ();
52
+ BLE.begin ();
53
+ }
54
+ } while (ret == 0 );
46
55
}
47
56
48
57
void loop () {
@@ -64,12 +73,30 @@ void loop() {
64
73
}
65
74
66
75
// stop scanning
67
- BLE.stopScan ();
76
+ int ret = 1 ;
77
+ do
78
+ {
79
+ ret = BLE.stopScan ();
80
+ if (ret == 0 )
81
+ {
82
+ BLE.end ();
83
+ BLE.begin ();
84
+ }
85
+ } while (ret == 0 );
68
86
69
87
controlLed (peripheral);
70
88
71
89
// peripheral disconnected, start scanning again
72
- BLE.scanForUuid (" 19b10000-e8f2-537e-4f6c-d104768a1214" );
90
+ ret = 1 ;
91
+ do
92
+ {
93
+ ret = BLE.scanForUuid (" 19b10000-e8f2-537e-4f6c-d104768a1214" );
94
+ if (ret == 0 )
95
+ {
96
+ BLE.end ();
97
+ BLE.begin ();
98
+ }
99
+ } while (ret == 0 );
73
100
}
74
101
}
75
102
Original file line number Diff line number Diff line change @@ -29,7 +29,16 @@ void setup() {
29
29
Serial.println (" Bluetooth® Low Energy Central - Peripheral Explorer" );
30
30
31
31
// start scanning for peripherals
32
- BLE.scan ();
32
+ int ret = 1 ;
33
+ do
34
+ {
35
+ ret = BLE.scan ();
36
+ if (ret == 0 )
37
+ {
38
+ BLE.end ();
39
+ BLE.begin ();
40
+ }
41
+ } while (ret == 0 );
33
42
}
34
43
35
44
void loop () {
@@ -49,7 +58,16 @@ void loop() {
49
58
// see if peripheral is a LED
50
59
if (peripheral.localName () == " LED" ) {
51
60
// stop scanning
52
- BLE.stopScan ();
61
+ int ret = 1 ;
62
+ do
63
+ {
64
+ ret = BLE.stopScan ();
65
+ if (ret == 0 )
66
+ {
67
+ BLE.end ();
68
+ BLE.begin ();
69
+ }
70
+ } while (ret == 0 );
53
71
54
72
explorerPeripheral (peripheral);
55
73
Original file line number Diff line number Diff line change @@ -25,8 +25,17 @@ void setup() {
25
25
26
26
Serial.println (" Bluetooth® Low Energy Central scan" );
27
27
28
- // start scanning for peripheral
29
- BLE.scan ();
28
+ // start scanning for peripherals
29
+ int ret = 1 ;
30
+ do
31
+ {
32
+ ret = BLE.scan ();
33
+ if (ret == 0 )
34
+ {
35
+ BLE.end ();
36
+ BLE.begin ();
37
+ }
38
+ } while (ret == 0 );
30
39
}
31
40
32
41
void loop () {
Original file line number Diff line number Diff line change @@ -31,7 +31,16 @@ void setup() {
31
31
BLE.setEventHandler (BLEDiscovered, bleCentralDiscoverHandler);
32
32
33
33
// start scanning for peripherals with duplicates
34
- BLE.scan (true );
34
+ int ret = 1 ;
35
+ do
36
+ {
37
+ ret = BLE.scan (true );
38
+ if (ret == 0 )
39
+ {
40
+ BLE.end ();
41
+ BLE.begin ();
42
+ }
43
+ } while (ret == 0 );
35
44
}
36
45
37
46
void loop () {
Original file line number Diff line number Diff line change @@ -30,8 +30,17 @@ void setup() {
30
30
Serial.println (" Bluetooth® Low Energy Central - SensorTag button" );
31
31
Serial.println (" Make sure to turn on the device." );
32
32
33
- // start scanning for peripheral
34
- BLE.scan ();
33
+ // start scanning for peripherals
34
+ int ret = 1 ;
35
+ do
36
+ {
37
+ ret = BLE.scan ();
38
+ if (ret == 0 )
39
+ {
40
+ BLE.end ();
41
+ BLE.begin ();
42
+ }
43
+ } while (ret == 0 );
35
44
}
36
45
37
46
void loop () {
@@ -52,12 +61,30 @@ void loop() {
52
61
// "CC2650 SensorTag"
53
62
if (peripheral.localName () == " CC2650 SensorTag" ) {
54
63
// stop scanning
55
- BLE.stopScan ();
64
+ int ret = 1 ;
65
+ do
66
+ {
67
+ ret = BLE.stopScan ();
68
+ if (ret == 0 )
69
+ {
70
+ BLE.end ();
71
+ BLE.begin ();
72
+ }
73
+ } while (ret == 0 );
56
74
57
75
monitorSensorTagButtons (peripheral);
58
76
59
77
// peripheral disconnected, start scanning again
60
- BLE.scan ();
78
+ ret = 1 ;
79
+ do
80
+ {
81
+ ret = BLE.scan ();
82
+ if (ret == 0 )
83
+ {
84
+ BLE.end ();
85
+ BLE.begin ();
86
+ }
87
+ } while (ret == 0 );
61
88
}
62
89
}
63
90
}
You can’t perform that action at this time.
0 commit comments