Lock up with ble discover attributes

I have a new Nano 33 IOT. I am trying to connect to a ble sensor, I can connect then when I try to discover attributes it just locks up. I have to reset it to download an edited sketch. It never discovers any attributes. Im using ArduinoBLE 1.4.0 library. Ive tested with LightBlue and it has the service and characteristic available to subscribe to. I tested with my cell phone and MIT Ai2 and it connected and was able to get the data so I know the sensor is working. If I try to subscribe directly to the cUUID directly it says it doesnt exist?

#include <ArduinoBLE.h>
#include "Timer.h"

void setup() {
 Serial.begin(9600);
 BLE.begin();
 Serial.println("BLE Starting");
 BLE.scan();

}

void loop() {
  BLEDevice bSensor = BLE.available();

  if (bSensor) {
    // discovered a , print out address, local name, and advertised service
    Serial.print("Found ");
    Serial.print(bSensor.address());
    Serial.print(" '");
    Serial.print(bSensor.localName());
    Serial.print("' ");
    Serial.print(bSensor.advertisedServiceUuid());
    Serial.println();

    if (bSensor.localName() != "WTBatSensor") {
      return;
    }
     // stop scanning
    BLE.stopScan();

    hitDetect(bSensor);

   while (1) {}
    }
}


void hitDetect(BLEDevice bSensor) {

Serial.println ("Connecting......");
if (bSensor.connect()) {
    Serial.print("Connected to: ");
    Serial.println(bSensor.address());
    Serial.print("Advertised Service: ");
    Serial.println(bSensor.advertisedServiceUuid());
       
  } else {
    Serial.println("Failed to connect!");
    return;
  }

 BLEService service = bSensor.service("0000ffe4-0000-1000-8000-00805f9a34fb");

Serial.println("Discovering Attributes");

 if (!bSensor.discoverAttributes()) {
  Serial.println("Attributes discovered");
  
  // Print discovered attributes
   
    for (int i = 0; i < bSensor.characteristicCount(); i++) {
     BLECharacteristic characteristic = bSensor.characteristic(i);
      Serial.print("Characteristic ");
      Serial.print(i);
      Serial.print(": ");
      Serial.println(characteristic.uuid());
      delay(10);
    }
  } 
 // if (!bSensor.discoverAttributes()){
 //   Serial.println("Attribute discovery failed!");
 //   bSensor.disconnect();
 //   return;
  //}
Serial.println("step");
bSensor.discoverAttributes();
Serial.print("Number of Char: ");
Serial.println(bSensor.characteristicCount());
if (!bSensor.hasCharacteristic("0000ffe4-0000-1000-8000-00805f9a34fb")){
  Serial.print("Has Char: ");
  Serial.println("No");
}
  // retrieve the characteristic
  BLECharacteristic notify = bSensor.characteristic("0000ffe4-0000-1000-8000-00805f9a34fb");
 if (!notify.canRead()){
  Serial.println("Cant READ");
 }
 
  if (!notify.canSubscribe()) {

    Serial.print("Can Subscribe: ");
    Serial.println(notify.descriptorCount());
    bSensor.disconnect();
    return;
  } 
if (notify.canSubscribe()) {
   Serial.println("Subscribe found");

}

notify.subscribe();
if (notify.subscribed()){
  Serial.print("Subscribed ");
 
}


}
When monitoring the serial monitor it gets to the discovery then just sits and I have to reboot it, then it will do it again but never actually do the discovery. 
Im most likely doing something wrong, but i don't know where.  

Here is the Serial output...

17:28:24.785 -> BLE Starting

17:28:24.854 -> Found 98:06:3c:3c:e5:39 '[TV] Samsung 8 Series (85)'

17:28:24.987 -> Found 0c:07:bc:49:b6:11 ''

17:28:25.021 -> Found 54:a5:03:47:8a:7e 'LE-Bose Revolve II SoundLi' febe

17:28:25.621 -> Found 33:17:93:88:23:d6 ''

17:28:25.815 -> Found cd:e1:f0:9a:a7:5d 'WTBatSensor' 0000ffe5-0000-1000-8000-00805f9a34fb

17:28:25.815 -> Connecting......

17:28:27.815 -> Connected to: cd:e1:f0:9a:a7:5d

17:28:27.815 -> Advertised Service: 0000ffe5-0000-1000-8000-00805f9a34fb

17:28:27.815 -> Discovering Attributes

Can you run the library example code PeripheralExplorer.ino with a local name change for the sensor can you discover the attributes?

Why is Timer.h included, and can you provide a link to that library?

I will try it, I have timer.h for use later on in the project.

I have timer.h for use later on in the project.

Get the BLE code working before including that library. There are internal hardware timers used by BLE and you want to make certain there are no conflicts.

Same thing happens, using the Peripheral example sketch, no timer.h included. it gets to detecting the attributes and just stops and is unresponsive...
18:52:18.609 -> Bluetooth® Low Energy Central - Peripheral Explorer
18:52:19.243 -> Found cd:e1:f0:9a:a7:5d 'WTBatSensor' 0000ffe5-0000-1000-8000-00805f9a34fb
18:52:19.243 -> Connecting ...
18:52:21.264 -> Connected
18:52:21.264 -> Discovering attributes ...

Do you have a link to the sensor and documentation on the protocol it is using.

Its a WIT motion Accelerometer and inclinometer. [Bluetooth 5.0 Accelerometer+Inclinometer] WT9011DCL MPU9250 High-Precision 9-axis Gyroscope+Angle(XY 0.2° Accuracy)+Magnetometer with Kalman Filter, Low-Power 3-axis AHRS IMU Sensor for Arduino: Amazon.com: Industrial & Scientific
Like I said I connected with MIT AI2 using the RegisterforBytes block in their BT library. I can also connect with LightBlue.


After looking at the sample code, it should be erroring out or working, but it just hangs!

I think you have connected with the Arduino BLE code.

I have written central code for a notify only sensor previously, and it finds the attributes before subscribing.

I see this in the Amazon reviews for the sensor

Customer 245
1.0 out of 5 stars Bluetooth 5.0 is misleading
Reviewed in the United States on October 19, 2024
Verified Purchase
The product has some proprietary interface procedures that uses BT5 internally but doesn't adhere to it at the host interfaces. It wouldn't pair as a standard BT5. The custom implementation they have is very specific to Windows PC. Won't have much luck with other platforms.

Have you tried the phone apps they provide or the Windows app?

Yes I have used their App, Mit App inventor, lightBlue, and they all work just fine. Just the Arduino wont. Like I said the Arduino locks up when discovering. That review is not worth much as its a BLE device. Like saying its Ethernet but then say it doesn't support TCP so its not doesn't adhere.
But thanks for the input, Ill have to figure out what's causing the discover to hang rather than at least erroring out.