Arduino Nano BLE 33 mBed OS Crash When Transmitting as iBeacon

I am working on a project to transmit data over ble as a beacon. The data is supposed to be in the major and minor fields. Right now I am having trouble with getting the arduino to run without the mBed OS crashing. The below code is one that I am running just to troubleshoot and see where I could get to but it runs a few cycles and the L led goes into the 4 fast 4 slow error mode for the mBed OS crash. From what I was reading this is typically caused by writing to too many pins at once but I am not sure how I would be doing that here. The other odd thing is if I change the UUID to something stupid like "test" it will run fine.

#include <ArduinoBLE.h>
#include <BeaconNano.h>
BeaconNano Beacon;
int count = 0;

void setup() {
  Beacon.setUuid("A495BB20C5B14B44B5121370F02D74DE");
  
}

void loop() {
  unsigned int major = count;
  unsigned int minor = count;
  Beacon.setMajor(major);
  Beacon.setMinor(minor);
  Beacon.startBeacon();
  delay(5000);
  Beacon.stopBeacon();
  count = count + 1;
  delay(5000);
}

The other thing that I changed in the BeaconNano library is the way that data is broken up. Since it was only supporting a single byte for major and minor (I need two bytes for at least the minor field) I had to edit the BeaconNano.cpp file as follows. I am looking for guidance on how I am causing the device to crash or if its a possible hardware issue.

Original:

void BeaconNano::startBeacon(){
   if (!BLE.begin()) {
      while (1);
  }


  
  byte uuidByte[16],majByte[2],minByte[2];
  convertStringToByte(_uuid,uuidByte);
  byte data[25]={
    0X4C,0x00, //setting for iBeacons
    0x02,0x15,
    uuidByte[0],
    uuidByte[1],
    uuidByte[2],
    uuidByte[3],
    uuidByte[4],
    uuidByte[5],
    uuidByte[6],
    uuidByte[7],
    uuidByte[8],
    uuidByte[9],
    uuidByte[10],
    uuidByte[11],
    uuidByte[12],
    uuidByte[13],
    uuidByte[14],
    uuidByte[15],
    0,
    _major,
    0,
    _minor,
    _tx
  };
  BLE.setManufacturerData(data, 25);// AGGIUNGE IL MANUFACT
  BLE.advertise();

My Edits:

byte uuidByte[16],majByte[2],minByte[2];
  majByte[0] = (_major >>8) ,majByte[1] =_major, minByte[0] =(_minor >>8), minByte[1] = _minor; 
  convertStringToByte(_uuid,uuidByte);
  byte data[25]={
    0x4C,0x00,0x02,0x15,
    uuidByte[0],
    uuidByte[1],
    uuidByte[2],
    uuidByte[3],
    uuidByte[4],
    uuidByte[5],
    uuidByte[6],
    uuidByte[7],
    uuidByte[8],
    uuidByte[9],
    uuidByte[10],
    uuidByte[11],
    uuidByte[12],
    uuidByte[13],
    uuidByte[14],
    uuidByte[15],
    majByte[0],
    majByte[1],
    minByte[0],
    minByte[1],
    _tx
  };
  BLE.setManufacturerData(data, 25);// AGGIUNGE IL MANUFACT
  BLE.advertise();
}
  majByte[0] = (_major >>8) ,majByte[1] =_major, minByte[0] =(_minor >>8), minByte[1] = _minor;

This doesn't do what you think it does. Separate these assignment statements by semicolons, not commas.

https://en.cppreference.com/w/cpp/language/operator_other#Built-in_comma_operator

Connect a 3.3V USB-to-Serial converter to the TX pin and read what the Mbed os error tells you. If you want to know exactly what causes the error, attach a debugger to the SWD pads on the bottom of the board.

Pieter

I updated the library and I am going to get a debugger. Right now the loop consistently errors out on the 5 cycle through which makes me think there is an issue with data or something piling up. I simplified the code further and it still fails on the 5th cycle. Is there anything I need to be clearing in the BLE library each time the beacon is ended?

#include <ArduinoBLE.h>
#include <BeaconNano.h>
BeaconNano Beacon;
//A495BB20C5B14B44B5121370F02D74DE
void setup() {

}

void loop() {
  Beacon.setUuid("A495BB20C5B14B44B5121370F02D74DE");
  Beacon.setMajor(10);
  Beacon.setMinor(10);
  Beacon.setTx(0);
  delay(1000);
  Beacon.startBeacon();
  delay(5000);
  Beacon.stopBeacon();
  delay(500);
}