BLE NANO 33 SENSE Rev2 RegisterForByte crash

Hi Osmany.
This is what i tried:

Unfortunately i get the same result.
You're idea works though it would handle the bytes just fine, but my issue is that as soon as the RegisterForInteger block is called my app crash, i dont even reach the IntegerReceived block.

I've tried a few different things and it always comes back to the same result, as soon as RegisterForInteger is called the app crash, even if i have a completely scrapped down simple program that simply connects to the NANO and calls RegisterForInteger.

I think there's no way around it, i have to get adb logcat up and running so i can see what crashes the app.

Dear @App_novice,
Kindly please, don't use RegisterForIntegers, instead use RegisterForBytes. The first one never worked for me.

If you are still sure that when BytesReceived never happens after RegisterForBytes then I don't know what to tell you. Please remove all the BytesReceived code and only leave code that lets you know what happened there (notification or write a label). Calling RegisterForBytes will call BytesReceived async when data arrive.

My point was to check that if you register to receive data, and when receiving it if you use an index out of range the app will crash.

The code I sent you works for when 4 bytes arrive and convert it to an integer, not 4 integers.
Don't give up, keep looking for the cause of the problem.

Best regards,
Osmany

1 Like

Thank you for the advice Osmany.
The app still crash if i change to bytes.
I have also tried altering the code running on the NANO33 dev board so that it never sends any data, but my app still crash as soon as RegisterForBytes or RegisterForInteger is called... any RegisterForXxxxx will crash the app, even if no data is sent/received.
I will have to find some time and get the adb logcat up and running so i can get more information about what is causing the crash, right now my problem is that i get zero feedback... the app just crash.

I also tried adding a clock that waits 10 seconds and then calls the RegisterForBytes. If i do that then the app connects correctly and then after 10 seconds the app crash.

Hi @App_novice
Also try test CanRegisterForCharacteristic before call RegisterForBytes.
Although I read in one of your messages that you were able to register for notifications from nRF Connect.
(Make sure to test that everything works from nRFConnect and remember to disconnect before run your app).

I kindly wish you luck,
Osmany

Oh no !
I found the issue, i had quotation marks around my characteristic UUID in the
BLEIntCharacteristic function, but it was already declared a string in the define above.

The reason I was so focused on the app crashing was that if i use LightBlue or nRFConnect they both worked without issues - but i suppose they must have something that can handle this situation.

Sorry for the hassle @ABG , @ChrisWard, @Osmany_Ferrer_Borges and @ewpatton

//----------------------------------------------------------------------------------------------------------------------
// BLE UUIDs
//----------------------------------------------------------------------------------------------------------------------
#define BLE_UUID_TEST_SERVICE               "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define BLE_UUID_ACCELERATION               "beb5483e-36e1-4688-b7f5-ea07361b26a8"
//----------------------------------------------------------------------------------------------------------------------
// BLE
//----------------------------------------------------------------------------------------------------------------------
BLEService testService( BLE_UUID_TEST_SERVICE );
BLEIntCharacteristic accelerationCharacteristic( "BLE_UUID_ACCELERATION" , BLERead | BLENotify);
1 Like

Ouch! Your Sketch compiled OK so I assume the quotation marks are tolerated by the function too.

It is quite something to find your own tiny bug like that, usually it's very difficult, so I award you this trophy: :trophy:

In C, macro expansion happens on tokens. "BLE_UUID_ACCELERATION" would be a string so wouldn't be subject to token expansion by the preprocessor. In theory, the library handling the UUIDs on the Arduino should have indicated some sort of error, but that's much harder to do in an embedded environment since that's not a valid UUID.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.