How to send information from the Nicla Voice Systiant processor via Bluetooth to an app?

I made a crash classification model that detects two labels: ADL or FALL, download the binary which gives me edge impulse and it works correctly.

I want the label that comes out to be sent to an app via Bluetooth, that’s why I made the following sketch in Aruino IDE

#include "NDP.h"
#include "Nicla_System.h"
#include <ArduinoBLE.h>

// Alert Service
BLEService alertService("b6a9c10a-b242-4397-9afe-2688a86c8b5c");  // Bluetooth® Low Energy LED Service
BLEUnsignedCharCharacteristic alertCharacteristic("d86af06b-228d-4300-8f9f-ca30db6ee3ac", BLERead | BLENotify);

void blesend(char* label) {
  Serial.print("Label received: ");
  Serial.println(label);

  if (strcmp(label, "NN0:ADL") == 0) {
    alertCharacteristic.writeValue(1);
    Serial.println("ADL Detected!!!");
    NDP.noInterrupts();
    nicla::leds.begin();
    nicla::leds.setColor(green);
    delay(200);
    nicla::leds.end();
    NDP.interrupts();
  } else if (strcmp(label, "NN0:FALL") == 0) {
    alertCharacteristic.writeValue(2);
    Serial.println("FALL Detected!!!");
    NDP.noInterrupts();
    nicla::leds.begin();
    nicla::leds.setColor(green);
    delay(200);
    nicla::leds.end();
    NDP.interrupts();
  } else {
    Serial.println("No match found.");
  }
}

void ledGreenOn() {
  nicla::leds.begin();
  nicla::leds.setColor(green);
  delay(200);
  nicla::leds.setColor(off);
  nicla::leds.end();
}

void ledRedBlink() {
  while (1) {
    nicla::leds.begin();
    nicla::leds.setColor(red);
    delay(200);
    nicla::leds.setColor(off);
    delay(200);
    nicla::leds.end();
  }
}

void ledBlueBlink() {
  for (int i = 0; i <= 2; i++) {
    nicla::leds.begin();
    nicla::leds.setColor(blue);
    delay(200);
    nicla::leds.setColor(off);
    delay(200);
    nicla::leds.end();
  }
}

void setup() {
  Serial.begin(115200);
  // while (!Serial);

  // Nicla System setup
  nicla::begin();
  nicla::disableLDO();
  // nicla::enableCharging(100);  // enabling the battery charger
  nicla::leds.begin();

  // Neural Decision Processor callbacks setup
  NDP.onError(ledRedBlink);
  NDP.onMatch(blesend);
  NDP.onEvent(ledGreenOn);

  Serial.println("Loading synpackages");

  // Neural Decision Processor firmware and ML model files loading
  NDP.begin("mcu_fw_120_v91.synpkg");
  NDP.load("dsp_firmware_v91.synpkg");
  NDP.load("ei_model.synpkg");
  Serial.println("packages loaded");
  NDP.getInfo();
  nicla::leds.end();
  // NDP.configureInferenceThreshold(1088);
  NDP.interrupts();

  // Initialize BLE
  if (!BLE.begin()) {
    Serial.println("Starting BLE failed!");
    while (1)
      ;
  }

  // BLE service and characteristics setup
  BLE.setLocalName("FallDetection");                    // Device Name
  BLE.setAdvertisedService(alertService);               // add the service UUID
  alertService.addCharacteristic(alertCharacteristic);  // add the alert level characteristic
  BLE.addService(alertService);                         // add the alert service

  // start advertising
  BLE.advertise();

  Serial.println("BLE advertising started");
  nicla::leds.end();
}

void loop() {
  BLEDevice central = BLE.central();

  if (central) {
    Serial.println("Connected to central device.");
    ledBlueBlink();
    //Test
    alertCharacteristic.writeValue(0);
    Serial.println("Sent test message.");
    NDP.interrupts();  // Start inferencing

    while (central.connected()) {
      delay(1000);
    }

    Serial.println("Disconnected from central device.");
  } else {
    nicla::leds.setColor(red);
    Serial.println("Waiting for central device...");
    delay(1000);
  }
}

First I uploaded the binary generated by edge impulse and then the sketch I made with arduino ide and the result is the following:

Loading synpackages
packages loaded
dsp firmware version: 19.2.0
package version: Model generated by Edge Impulse
pbi version: 3.2.3-0
num of labels: 2
labels: NN0:ADL, NN0:FALL
total deployed neural networks: 1
BLE advertising started
Waiting for central device...
Waiting for central device...
Waiting for central device...
Waiting for central device...
Connected to central device.
Sent test message.

In the app I have I only get 0 , no 1 (ADL) or 2 (FALL), any idea how I could fix this?. Thanks in advance

Hi @pgudino,

I don’t have much experience with Bluetooth or app development. It looks like inference is working, so I might recommend trying to make a simple Arduino sketch and app without the Edge Impulse library at first to see if you can transmit/receive simple messages first. If you’re running into trouble getting Bluetooth to work, you’ll probably have better luck getting help from folks in the Arduino forums: https://forum.arduino.cc/