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
  • Well it's not a coincidence that it's connecting to the same device, you're telling it to connect to it.

    Can you post your code for the adv report event?

  • here is the code : 85776.main.c

    yes i am telling to connect and after discovery i want to disconnect and never connect again if service is discovered. but even after service found its connecting same device.

    if the service is not found flow control goes to next device for connection. here i dont have any problem.

    Thanks.

  • 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;
        }
    }

Reply
  • 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;
        }
    }

Children
Related