@@ -63,26 +63,7 @@ BLELocalDevice::~BLELocalDevice()
6363
6464int BLELocalDevice::begin ()
6565{
66- #if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT)
67- // reset the NINA in BLE mode
68- pinMode (SPIWIFI_SS , OUTPUT );
69- pinMode (NINA_RESETN , OUTPUT );
70-
71- digitalWrite (SPIWIFI_SS , LOW );
72- #endif
73-
74- #if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_AVR_UNO_WIFI_REV2)
75- digitalWrite (NINA_RESETN , HIGH );
76- delay (100 );
77- digitalWrite (NINA_RESETN , LOW );
78- delay (750 );
79- #elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT)
80- // inverted reset
81- digitalWrite (NINA_RESETN , LOW );
82- delay (100 );
83- digitalWrite (NINA_RESETN , HIGH );
84- delay (750 );
85- #elif defined(PORTENTA_H7_PINS) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
66+ #if defined(PORTENTA_H7_PINS) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
8667 // BT_REG_ON -> HIGH
8768 pinMode (BT_REG_ON , OUTPUT );
8869 digitalWrite (BT_REG_ON , LOW );
@@ -125,7 +106,10 @@ int BLELocalDevice::begin()
125106
126107 if (HCI .reset () != 0 ) {
127108 end ();
128-
109+ #if defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(TARGET_NANO_RP2040_CONNECT)
110+ Serial.println (" The initialization of the Bluetooth® Low Energy module failed." );
111+ Serial.println (" Please ensure your NINA firmware is version 3.0.0 or higher." );
112+ #endif
129113 return 0 ;
130114 }
131115
@@ -187,10 +171,10 @@ int BLELocalDevice::begin()
187171 // }
188172 // Serial.println();
189173
190- // // save this
174+ // // save this
191175 // uint8_t zeros[16];
192176 // for(int k=0; k<16; k++) zeros[15-k] = 0;
193-
177+
194178 // // HCI.leAddResolvingAddress((*BADDR_Type)[i],(*BADDRs)[i],(*IRKs)[i], zeros);
195179
196180 // delete[] (*BADDRs)[i];
@@ -202,7 +186,7 @@ int BLELocalDevice::begin()
202186 // delete BADDRs;
203187 // delete[] (*IRKs);
204188 // delete IRKs;
205-
189+
206190 // memcheck = new uint8_t[1];
207191 // Serial.print("nIRK location: 0x");
208192 // Serial.println((int)memcheck,HEX);
@@ -221,15 +205,9 @@ void BLELocalDevice::end()
221205
222206 HCI .end ();
223207
224- #if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_AVR_UNO_WIFI_REV2)
225- // disable the NINA
226- digitalWrite (NINA_RESETN , HIGH );
227- #elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT)
228- // disable the NINA
229- digitalWrite (NINA_RESETN , LOW );
230- #elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
208+ #if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
231209 digitalWrite (BT_REG_ON , LOW );
232- #endif
210+ #endif
233211 _advertisingData.clear ();
234212 _scanResponseData.clear ();
235213}
@@ -315,7 +293,7 @@ bool BLELocalDevice::setManufacturerData(const uint16_t companyId, const uint8_t
315293
316294bool BLELocalDevice::setLocalName (const char *localName)
317295{
318- return _scanResponseData.setLocalName (localName);
296+ return _scanResponseData.setLocalName (localName);
319297}
320298
321299void BLELocalDevice::setAdvertisingData (BLEAdvertisingData& advertisingData)
@@ -360,7 +338,7 @@ int BLELocalDevice::advertise()
360338{
361339 _advertisingData.updateData ();
362340 _scanResponseData.updateData ();
363- return GAP .advertise ( _advertisingData.data (), _advertisingData.dataLength (),
341+ return GAP .advertise ( _advertisingData.data (), _advertisingData.dataLength (),
364342 _scanResponseData.data (), _scanResponseData.dataLength ());
365343}
366344
0 commit comments