arduino / nicla-sense-me-fw

Arduino Nicla Sense ME resources (libraries, bootloader, host pc utilities)

Repository from Github https://github.comarduino/nicla-sense-me-fwRepository from Github https://github.comarduino/nicla-sense-me-fw

[AE-51] BHY2.delay() only works when NiclaConfig set to NICLA_BLE

aliphys opened this issue · comments

Describe the Problem

An alternative delay function is provided as part of the ArduinoBHY2 library. Defined as follows:

void Arduino_BHY2::delay(unsigned long ms)
{
unsigned long start = millis();
unsigned long elapsed = 0;
if (_niclaConfig & NICLA_BLE) {
while (elapsed < ms) {
bleHandler.poll(ms - elapsed);
elapsed = millis() - start;
}
}
}

The while segment is only activated when the NiclaConfig enumerator is set to NICLA_BLE.

enum NiclaConfig {
NICLA_I2C = 0x1, /*!< I2C */
NICLA_BLE = 0x2, /*!< Bluetooth via ANNA-B112 module */
NICLA_BLE_AND_I2C = NICLA_I2C | NICLA_BLE, /*!< Enable I2C and BLE simultaneously */
NICLA_STANDALONE = 0x4 /*!< Operate in standalone, without external data transfer */
};

Expected behaviour

🙂 While loop does not rely on the bleHandler class
🙂 Regardless of the NiclaConfig enumeration, the delay loop will operate as intended.