@@ -15,9 +15,10 @@ limitations under the License.
1515
1616/*
1717* @author Rikard Lindstrom <[email protected] > 18- *
1918*/
2019
20+ // Ported to Adafruit_nRF52_Arduino core by hathach for Adafruit
21+
2122#define VERSION 5
2223#define FLOAT_BYTE_SIZE 4
2324
@@ -147,11 +148,7 @@ void updateLed()
147148 {
148149
149150 case FILE_TRANSFER:
150- #if 0
151151 if (ble_file_transfer::isTransfering ())
152- #else
153- if (0 )
154- #endif
155152 {
156153 // Rapid blink while transfering is in progress
157154 millis () % 100 > 50 ? rgbLedOff () : rgbLedYellow ();
@@ -225,9 +222,7 @@ void setState(State state)
225222 prevState = currentState;
226223 }
227224 currentState = state;
228- #if 0
229- stateTxChar.writeValue((unsigned char)state);
230- #endif
225+ stateTxChar.notify8 ((unsigned char )state);
231226 switch (currentState)
232227 {
233228 case IDLE_DISCONNECTED:
@@ -350,9 +345,7 @@ void handleFileTransferTypeWritten(uint16_t conn_hdl, BLECharacteristic* chr, ui
350345void model_tester_onInference (unsigned char classIndex, unsigned char score, unsigned char velocity)
351346{
352347 const byte buffer[]{classIndex, score, velocity};
353- #if 0
354- inferenceTxChar.setValue(buffer, 3);
355- #endif
348+ inferenceTxChar.notify (buffer, 3 );
356349 Serial.print (" Inference - class: " );
357350 Serial.print (classIndex);
358351 Serial.print (" score: " );
@@ -549,18 +542,17 @@ inline void updateIMU()
549542 model_tester::update (buffer);
550543 }
551544 }
552- # if 0
545+
553546 if (currentState == IMU_DATA_PROVIDER || currentState == INFERENCE_AND_DATA_PROVIDER){
554547 // provide data to IMU trainer
555- dataProviderTxChar.writeValue (buffer, bufferSize * FLOAT_BYTE_SIZE);
548+ dataProviderTxChar.notify (buffer, bufferSize * FLOAT_BYTE_SIZE);
556549 }
557- # endif
550+
558551 }
559552}
560553
561554inline void updateFileTransfer ()
562555{
563- #if 0
564556 // Update file transfer state
565557 ble_file_transfer::updateBLEFileTransfer ();
566558
@@ -572,19 +564,17 @@ inline void updateFileTransfer()
572564 Serial.println (" done reloading model" );
573565 newModelFileData = nullptr ;
574566
575- hasModelTxChar.writeValue (true);
567+ hasModelTxChar.notify8 (true );
576568
577569 // We have a new model, always enter INFERENCE mode
578570 setState (INFERENCE);
579571 }
580- #endif
581572}
582573
583574void loop ()
584575{
585- #if 0
586576 // Make sure we're connected and not busy file-transfering
587- if (BLE .connected())
577+ if (Bluefruit .connected ())
588578 {
589579 switch (currentState)
590580 {
@@ -607,7 +597,6 @@ void loop()
607597 } else if (currentState != IDLE_DISCONNECTED){
608598 setState (IDLE_DISCONNECTED);
609599 }
610- #endif
611600
612601 // Update led based on state
613602 updateLed ();
0 commit comments