Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@ jobs:
- fqbn: arduino:samd:mkrwifi1010
platforms: |
- name: arduino:samd
libraries: ""
libraries: |
- name: Arduino_SpiNINA
artifact-name-suffix: arduino-samd-mkrwifi1010
- fqbn: arduino:samd:nano_33_iot
platforms: |
- name: arduino:samd
libraries: ""
libraries: |
- name: Arduino_SpiNINA
artifact-name-suffix: arduino-samd-nano_33_iot
- fqbn: arduino:megaavr:uno2018:mode=on
platforms: |
- name: arduino:megaavr
libraries: ""
libraries: |
- name: Arduino_SpiNINA
artifact-name-suffix: arduino-megaavr-uno2018
- fqbn: arduino:mbed_nano:nano33ble
platforms: |
Expand All @@ -54,7 +57,8 @@ jobs:
- fqbn: arduino:mbed_nano:nanorp2040connect
platforms: |
- name: arduino:mbed_nano
libraries: ""
libraries: |
- name: Arduino_SpiNINA
artifact-name-suffix: arduino-mbed_nano-nanorp2040connect
- fqbn: arduino:mbed_portenta:envie_m7
platforms: |
Expand Down Expand Up @@ -175,6 +179,8 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fqbn: ${{ matrix.fqbn }}
libraries: |
${{ matrix.libraries }}
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Expand Down
6 changes: 5 additions & 1 deletion examples/Central/LedControl/LedControl.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ void setup() {
pinMode(buttonPin, INPUT);

// initialize the Bluetooth® Low Energy hardware
BLE.begin();
if (!BLE.begin()) {
Serial.println("starting Bluetooth® Low Energy module failed!");

while (1);
}

Serial.println("Bluetooth® Low Energy Central - LED control");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ void setup() {
while (!Serial);

if (!BLE.begin()) {
Serial.println("failed to initialize BLE!");
Serial.println("starting Bluetooth® Low Energy module failed!");

while (1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ void setup() {
while (!Serial);

if (!BLE.begin()) {
Serial.println("failed to initialize BLE!");
Serial.println("starting Bluetooth® Low Energy module failed!");

while (1);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/Peripheral/BatteryMonitor/BatteryMonitor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void setup() {

// begin initialization
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
Serial.println("starting Bluetooth® Low Energy module failed!");

while (1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ void setup() {
while(1){
// begin initialization
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
delay(200);
continue;
Serial.println("starting Bluetooth® Low Energy module failed!");

while (1);
}
Serial.println("BT init");
delay(200);
Expand Down
1 change: 1 addition & 0 deletions library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ category=Communication
url=https://www.arduino.cc/en/Reference/ArduinoBLE
architectures=*
includes=ArduinoBLE.h
depends=Arduino_SpiNINA
46 changes: 12 additions & 34 deletions src/local/BLELocalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,7 @@ BLELocalDevice::~BLELocalDevice()

int BLELocalDevice::begin()
{
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT)
// reset the NINA in BLE mode
pinMode(SPIWIFI_SS, OUTPUT);
pinMode(NINA_RESETN, OUTPUT);

digitalWrite(SPIWIFI_SS, LOW);
#endif

#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_AVR_UNO_WIFI_REV2)
digitalWrite(NINA_RESETN, HIGH);
delay(100);
digitalWrite(NINA_RESETN, LOW);
delay(750);
#elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT)
// inverted reset
digitalWrite(NINA_RESETN, LOW);
delay(100);
digitalWrite(NINA_RESETN, HIGH);
delay(750);
#elif defined(PORTENTA_H7_PINS) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
#if defined(PORTENTA_H7_PINS) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
// BT_REG_ON -> HIGH
pinMode(BT_REG_ON, OUTPUT);
digitalWrite(BT_REG_ON, LOW);
Expand Down Expand Up @@ -125,7 +106,10 @@ int BLELocalDevice::begin()

if (HCI.reset() != 0) {
end();

#if defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(TARGET_NANO_RP2040_CONNECT)
Serial.println("The initialization of the Bluetooth® Low Energy module failed.");
Serial.println("Please ensure your NINA firmware is version 3.0.0 or higher.");
#endif
return 0;
}

Expand Down Expand Up @@ -187,10 +171,10 @@ int BLELocalDevice::begin()
// }
// Serial.println();

// // save this
// // save this
// uint8_t zeros[16];
// for(int k=0; k<16; k++) zeros[15-k] = 0;

// // HCI.leAddResolvingAddress((*BADDR_Type)[i],(*BADDRs)[i],(*IRKs)[i], zeros);

// delete[] (*BADDRs)[i];
Expand All @@ -202,7 +186,7 @@ int BLELocalDevice::begin()
// delete BADDRs;
// delete[] (*IRKs);
// delete IRKs;

// memcheck = new uint8_t[1];
// Serial.print("nIRK location: 0x");
// Serial.println((int)memcheck,HEX);
Expand All @@ -221,15 +205,9 @@ void BLELocalDevice::end()

HCI.end();

#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_AVR_UNO_WIFI_REV2)
// disable the NINA
digitalWrite(NINA_RESETN, HIGH);
#elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT)
// disable the NINA
digitalWrite(NINA_RESETN, LOW);
#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
digitalWrite(BT_REG_ON, LOW);
#endif
#endif
_advertisingData.clear();
_scanResponseData.clear();
}
Expand Down Expand Up @@ -315,7 +293,7 @@ bool BLELocalDevice::setManufacturerData(const uint16_t companyId, const uint8_t

bool BLELocalDevice::setLocalName(const char *localName)
{
return _scanResponseData.setLocalName(localName);
return _scanResponseData.setLocalName(localName);
}

void BLELocalDevice::setAdvertisingData(BLEAdvertisingData& advertisingData)
Expand Down Expand Up @@ -360,7 +338,7 @@ int BLELocalDevice::advertise()
{
_advertisingData.updateData();
_scanResponseData.updateData();
return GAP.advertise( _advertisingData.data(), _advertisingData.dataLength(),
return GAP.advertise( _advertisingData.data(), _advertisingData.dataLength(),
_scanResponseData.data(), _scanResponseData.dataLength());
}

Expand Down
Loading
Loading