Great! I did see the snippet above where you check the length less than 60. But lets say that tomorrow the team decides that a 32-byte serial buffer is a better overall trade off but you are waiting for 59 bytes to be available. This can never be true. Just a point for the future.
ArthurGuy, I looked at the BLEmini sketch you used as a model and I am a bit confused. If I understand correctly, data from the BLEmini is structured with the first three bytes defining "type, āevent_codeā and ādata_lenā. The remainder of the message is of length ādata_lenā so the entire message can be received and processed. The arduino sample sketch is very structured and āsynchronousā processing entire messages and their even_codes.
It seems to me that waiting on the first three bytes with a proper timeout is enough to tell you if a device is available or not. On top of that, the received āevent_codeā seems to come as a response to a discovery request being sent to the BLEmini. Again, a timeout will tell you if a device is there or not. So I am not sure how your detectDevice() function is supposed to work. Everything you need is already in the arduino libraries.
At the moment I believe everything is working reliably, I still donāt know what triggered the system crash which is worrying along with the fact that the system didnāt appear to recover properly after the crash which again is a concern.
I will monitor the system this week and see how it performs.