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

how to autoconnect with the bonded smartphone

hi ,,, nrf52832 , at first for bonding i will connect my device manually by scanning and after passing the data to flash , i will disconnect . in program i have set the timer , if it 20 mins , it should auto connect to the phone app (which is bonded previously), device has to autoconnect . how to do this ?

suggest me 

Parents
  • Hi,

    Not much you can do on the peripheral side. Just make sure you start advertising again after 20 minuttes. If this is a service that is natively supported by the peer (bonded smartphone) it would normally autoconnect. If it is not natively supported by the peer, your phone application will have to enable autoreconnect / background scanning.

  • how to do that ? which one command is used to connect to peer device , for disconnect 

     err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); please have a look at below code , i am advertising after 20 minutes , after connect and i am getting fatal error 

    static void timer_sensor_event_handler(void)
    {
        advertising_start();
        if(connected==true)
        {
    nrf_gpio_pin_toggle(19);
    ret_code_t err_code= ble_nus_data_send(&m_nus,"hello",25,m_conn_handle);
    nrf_delay_ms(10000);
        err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    }
    }
    

  • What error code are you getting?

    Not sure I would do all of this in the  timer handler. Try to only start adveertising. Then start to send data after the connection is established and notification has been enabled. Similar to what we do in most/all our examples. i.e. I look at one of the simper examples such as ble_app_uart.

Reply Children
No Data
Related