<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>BLE break loop on new command received</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79059/ble-break-loop-on-new-command-received</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 31 Aug 2021 16:41:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79059/ble-break-loop-on-new-command-received" /><item><title>RE: BLE break loop on new command received</title><link>https://devzone.nordicsemi.com/thread/327481?ContentTypeID=1</link><pubDate>Tue, 31 Aug 2021 16:41:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30efe6a4-745b-46bc-b88f-27f4076392ba</guid><dc:creator>vkx5221</dc:creator><description>&lt;p&gt;Thank you for your help Jared. Was able to quickly adapt my code with your suggestion and it works flawlessly.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE break loop on new command received</title><link>https://devzone.nordicsemi.com/thread/327212?ContentTypeID=1</link><pubDate>Mon, 30 Aug 2021 12:19:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53fc069f-466c-426b-8ea8-95081bbac70c</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;You can set a flag in the ble event handler that is set based on content that is received. You can then check the status of this flag for each iteration of the loop in main. Something like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int flag = 0;

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    Case BLE_GATTC_EVT_HVX:
    
    //Check payload and set flag

    break:

}


int main(void)
{

    while()
    {
        while( flag == loop1){}
        
        while(flag == loop2){}
        
        while(flag == loop3){}
    
    }




}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>