@@ -15,9 +15,10 @@ limitations under the License.
15
15
16
16
/*
17
17
* @author Rikard Lindstrom <rlindsrom@google.com>
18
- *
19
18
*/
20
19
20
+ // Ported to Adafruit_nRF52_Arduino core by hathach for Adafruit
21
+
21
22
#define VERSION 5
22
23
#define FLOAT_BYTE_SIZE 4
23
24
@@ -147,11 +148,7 @@ void updateLed()
147
148
{
148
149
149
150
case FILE_TRANSFER:
150
- #if 0
151
151
if (ble_file_transfer::isTransfering ())
152
- #else
153
- if (0 )
154
- #endif
155
152
{
156
153
// Rapid blink while transfering is in progress
157
154
millis () % 100 > 50 ? rgbLedOff () : rgbLedYellow ();
@@ -225,9 +222,7 @@ void setState(State state)
225
222
prevState = currentState;
226
223
}
227
224
currentState = state;
228
- #if 0
229
- stateTxChar.writeValue((unsigned char)state);
230
- #endif
225
+ stateTxChar.notify8 ((unsigned char )state);
231
226
switch (currentState)
232
227
{
233
228
case IDLE_DISCONNECTED:
@@ -350,9 +345,7 @@ void handleFileTransferTypeWritten(uint16_t conn_hdl, BLECharacteristic* chr, ui
350
345
void model_tester_onInference (unsigned char classIndex, unsigned char score, unsigned char velocity)
351
346
{
352
347
const byte buffer[]{classIndex, score, velocity};
353
- #if 0
354
- inferenceTxChar.setValue(buffer, 3);
355
- #endif
348
+ inferenceTxChar.notify (buffer, 3 );
356
349
Serial.print (" Inference - class: " );
357
350
Serial.print (classIndex);
358
351
Serial.print (" score: " );
@@ -549,18 +542,17 @@ inline void updateIMU()
549
542
model_tester::update (buffer);
550
543
}
551
544
}
552
- # if 0
545
+
553
546
if (currentState == IMU_DATA_PROVIDER || currentState == INFERENCE_AND_DATA_PROVIDER){
554
547
// provide data to IMU trainer
555
- dataProviderTxChar.writeValue (buffer, bufferSize * FLOAT_BYTE_SIZE);
548
+ dataProviderTxChar.notify (buffer, bufferSize * FLOAT_BYTE_SIZE);
556
549
}
557
- # endif
550
+
558
551
}
559
552
}
560
553
561
554
inline void updateFileTransfer ()
562
555
{
563
- #if 0
564
556
// Update file transfer state
565
557
ble_file_transfer::updateBLEFileTransfer ();
566
558
@@ -572,19 +564,17 @@ inline void updateFileTransfer()
572
564
Serial.println (" done reloading model" );
573
565
newModelFileData = nullptr ;
574
566
575
- hasModelTxChar.writeValue (true);
567
+ hasModelTxChar.notify8 (true );
576
568
577
569
// We have a new model, always enter INFERENCE mode
578
570
setState (INFERENCE);
579
571
}
580
- #endif
581
572
}
582
573
583
574
void loop ()
584
575
{
585
- #if 0
586
576
// Make sure we're connected and not busy file-transfering
587
- if (BLE .connected())
577
+ if (Bluefruit .connected ())
588
578
{
589
579
switch (currentState)
590
580
{
@@ -607,7 +597,6 @@ void loop()
607
597
} else if (currentState != IDLE_DISCONNECTED){
608
598
setState (IDLE_DISCONNECTED);
609
599
}
610
- #endif
611
600
612
601
// Update led based on state
613
602
updateLed ();
0 commit comments