This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE break loop on new command received

Hello, 

I am creating my first bluetooth application and am having difficulties figuring out the interrupts. The application is working and is very simple - please see pseudo code example below

case byte received = 0x01 execute loop1 

case byte received = 0x02 execute loop2 

case byte received = 0x03 execute loop3

ect .... 

What I would like to do is keep the selected loop going and break on new command. So, if 0x01 is received loop1 will continue until until a new command is received. Everything i've tried thus far cannot break the loop and device stops accepting new commands because the processor isn't correctly checking to see if a new command is available within the loop. Does anyone have any suggestions or example that could be used as reference? 

If I set a short execution time on each loop and allow it to finish then I can send a new command but I would like to have the currently selected loop keep going until a new command is received. Any help is appreciated. 

Related