Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

MCU hangs after connecting disconnecting and again connecting

Hi, there

I am using nrf52832 chip on a custom hardware and also using softdevice 132 to send data to an app.

I need to send data from app to MCU and vice-versa and it is working fine but the problem is that after disconnecting if I again try to connect to the app the MCU hangs.

This is my main function below

int main(void)
{
  uint8_t cntr = 0, kk;

  peripheral_init();
    Time_Read();
    UID_read();
    ble_init();
    advertising_start();
    Clear_Screen(0);

    while (1)
    {
      if (!ble_con_sta)
      {        
        home_scrn();
        cntr++;

        if ((cntr % 10) == 0)
        {
          Time_Read();
          if (scan_fingerprint())
          {
            advertising_start();
            match_fingerprint();
            while (scan_fingerprint());
            Clear_Screen(0);
          }
        }

        if (cntr > 200)
        {
          idle_state_handle();
          cntr = 0;
        }
        nrf_delay_ms(1);
      }
      else
      {
        display_app_acess();
      }
    }
  
  //for (;;)
  //{
  //  idle_state_handle();
  //}
}

As you can see I called the advertising_start() function before while loop once and after I have used finger print sensor as button to match fingerprint and also to start advertising again.

In my application  I have to send/receive data from app 3 or 4 times a day,but while testing I am connecting and disconnecting from app frequently to test but MCU hangs after multiple connecting and disconnecting.

I am facing two issues

1. Multiple connecting and disconnecting hangs MCU

2. After APP_ADV_DURATION completed and I try to call advertising_start function MCU hangs

3. I have to call match fingerprint function multiple time if my fingerprint doesn't match and that will call the advertising_start function again

Please suggest something to solve this problem

Related