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

How to change the peripheral depends on battery level?

Hello All,

We have One central device and four peripheral devices. From every peripheral device we are transmitting battery level.

I want to change the peripheral or want to connect to other peripheral when the battery level of connected peripheral goes goes below threshold value.

currently I am trying with HRS central code and Nordic SDK14.1 Can you please guide me on the same.

Best Regards, Hrushi

Parents
  • Hello Peter,

    I enables the static bool is_connect_per_addr = true; and I also modified below code:

    if (is_connect_per_addr)
            {
                if (find_peer_addr(&p_gap_evt->params.adv_report, &m_target_periph_addr1))
                {
                    NRF_LOG_INFO("Address match send connect_request to peripheral1.");
    	    printf("\n\rAddress match send connect_request to peripheral1.\n\r");
                    do_connect = true;
                }
    
            if (find_peer_addr(&p_gap_evt->params.adv_report, &m_target_periph_addr2))
                {
                    NRF_LOG_INFO("Address match send connect_request peripheral2.");
    	    printf("\n\rAddress match send connect_request to peripheral2.\n\r");
                    do_connect = true;
                }
    
    	  if (find_peer_addr(&p_gap_evt->params.adv_report, &m_target_periph_addr3))
                {
                    NRF_LOG_INFO("Address match send connect_request peripheral2.");
    	    printf("\n\rAddress match send connect_request to peripheral2.\n\r");
                    do_connect = true;
                }
    
            }
    

    Will it work?

Reply
  • Hello Peter,

    I enables the static bool is_connect_per_addr = true; and I also modified below code:

    if (is_connect_per_addr)
            {
                if (find_peer_addr(&p_gap_evt->params.adv_report, &m_target_periph_addr1))
                {
                    NRF_LOG_INFO("Address match send connect_request to peripheral1.");
    	    printf("\n\rAddress match send connect_request to peripheral1.\n\r");
                    do_connect = true;
                }
    
            if (find_peer_addr(&p_gap_evt->params.adv_report, &m_target_periph_addr2))
                {
                    NRF_LOG_INFO("Address match send connect_request peripheral2.");
    	    printf("\n\rAddress match send connect_request to peripheral2.\n\r");
                    do_connect = true;
                }
    
    	  if (find_peer_addr(&p_gap_evt->params.adv_report, &m_target_periph_addr3))
                {
                    NRF_LOG_INFO("Address match send connect_request peripheral2.");
    	    printf("\n\rAddress match send connect_request to peripheral2.\n\r");
                    do_connect = true;
                }
    
            }
    

    Will it work?

Children
No Data
Related