@@ -30,22 +30,22 @@ rtos::Thread thread_update_sensors;
30
30
31
31
#ifdef ESP32
32
32
TaskHandle_t update_base;
33
+ TaskHandle_t update_ble;
33
34
#endif
34
35
35
36
bool ble_is_connected = false ;
36
37
37
38
38
39
39
40
void setup (){
41
+ pinMode (6 ,OUTPUT);
40
42
science_kit.begin (NO_AUXILIARY_THREADS); // Doesn't start the BME688 and external temperature threads for the moment
41
43
42
44
if (!BLE.begin ()){
43
45
while (1 );
44
46
}
45
47
46
- #ifdef ESP32
47
- BLE.setConnectionInterval (6 , 12 );
48
- #endif
48
+ // BLE.setConnectionInterval(6, 12);
49
49
50
50
String address = BLE.address ();
51
51
@@ -125,13 +125,16 @@ void setup(){
125
125
#endif
126
126
#ifdef ESP32
127
127
xTaskCreatePinnedToCore (&freeRTOSUpdate, " update_base" , 10000 , NULL , 1 , &update_base, 1 ); // starts the update sensors thread on core 1 (user)
128
+ xTaskCreatePinnedToCore (&freeRTOSble, " update_ble" , 10000 , NULL , 1 , &update_ble, 0 ); // starts the ble thread on core 0 (internal)
128
129
#endif
129
130
}
130
131
131
132
132
133
void update (void ){
133
134
while (1 ){
135
+ digitalWrite (6 ,HIGH);
134
136
science_kit.update (ROUND_ROBIN_ENABLED);
137
+ digitalWrite (6 ,LOW);
135
138
delay (25 );
136
139
}
137
140
}
@@ -140,10 +143,16 @@ void update(void){
140
143
static void freeRTOSUpdate (void * pvParameters){
141
144
update ();
142
145
}
143
- #endif
144
146
147
+ static void freeRTOSble (void * pvParameters){
148
+ while (1 ){
149
+ updateBle ();
150
+ delay (1 );
151
+ }
152
+ }
153
+ #endif
145
154
146
- void loop (){
155
+ void updateBle (){
147
156
BLEDevice central = BLE.central ();
148
157
if (central) {
149
158
ble_is_connected = true ;
@@ -155,6 +164,9 @@ void loop(){
155
164
if (millis ()-lastNotify>10 ){
156
165
updateSubscribedCharacteristics ();
157
166
lastNotify=millis ();
167
+ #ifdef ESP32
168
+ delay (1 );
169
+ #endif
158
170
}
159
171
}
160
172
}
@@ -167,6 +179,13 @@ void loop(){
167
179
}
168
180
}
169
181
182
+
183
+ void loop (){
184
+ #ifdef ARDUINO_NANO_RP2040_CONNECT
185
+ updateBle ();
186
+ #endif
187
+ }
188
+
170
189
void updateSubscribedCharacteristics (){
171
190
/* ________________________________________________________________CURRENT */
172
191
if (currentCharacteristic.subscribed ()){
0 commit comments