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

my application is reconnecting the same device even after service discovery.

Hi I am working on nRF52832 using SDK15.02 i have below query:

During discovery I am connecting each device which is advertising and then discover for services offered by peripheral device.
Disconnect after the discovery. If required service found then again its connecting to the same device and discovery process is continued again. but i want to connect to other device after disconnection.

db_discovery_module.docx

I have attached file which contains flowchart of how my application should work. 

please guide me how to solve this issue?

Thanks in advance

Rekha

Parents Reply Children
  • You should print some logs and figure out why that's happening. I'm pretty sure it's a small logic error somewhere.

    I would look into the saving and comparison of the addresses.

    Why doesn't this code return? Shouldn't the address be already saved if you already connected to it? It seems to me that something is going wrong there.

    for ( idx = 0; idx < DEVICE_TO_FIND_MAX; idx++)
    {
        // If address is duplicated, then return.
        if (memcmp(p_adv_report->peer_addr.addr,
                   m_device[idx].addr,
                   sizeof(p_adv_report->peer_addr.addr)) == 0)
        {
             /* update rssi value */
            memcpy(&m_device[idx].RSSI_value_RK, 
                   &p_adv_report->rssi, 
                   sizeof(p_adv_report->rssi));
            return;
        }
    }

  • Hi I modified my code. if service is found then my device starts connecting to next device.

    i have added a loop to check if service is found then do not connect device again. now problem is if service is not found then device reconnects more than 3 times and then check for next device.

    is there any way to optimize it still more.

    Thanks.

Related