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

Characteristics when connecting a peripheral to central

Hi, I have a peripheral device which has buttons that connects to a central device which is the NRF52 board. When the peripheral device is connected and buttons are inputted, the characteristics of the button are not displayed on the UART terminal when I press it. I was not sure why because I have the correct UUID and the RX and TX characteristics. I have implemented the UART example to the HRS example, but it was because I wanted to have the board act as both the central and the peripheral but connect to any or multiple peripheral. I know that inside the ble_nus_c_evt_handler() method there is ble_nus_c_rx_notif_enable(), but it does not work.

Here is my code so far. Please let me know if there are any errors.

gist.github.com/.../41be2f1584a462dd2c2971764595305f

Any help would be appreciated. Thanks.

Parents
  • This is how I have it set up:

    case BLE_GAP_EVT_ADV_REPORT: {

            if (strlen(m_target_periph_name) != 0)
            {
                if (find_adv_name(&p_gap_evt->params.adv_report, m_target_periph_name))
                {
                    // Initiate connection.
                    err_code = sd_ble_gap_connect(&p_gap_evt->params.adv_report.peer_addr,
                                                  &m_scan_params,
                                                  &m_connection_param);
                    if (err_code != NRF_SUCCESS)
                    {
                        NRF_LOG_INFO("Connection Request Failed, reason %d\r\n", err_code);
                    }
                }
            }
    					
    					
            else
            {
               /** We do not want to connect to two peripherals offering the same service, so when
                *  a UUID is matched, we check that we are not already connected to a peer which
                *  offers the same service. */
    						
    						const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;
    						
                if ((is_uuid_present(&m_adv_uuids[0], p_adv_report)))
    								
                {
                    // Initiate connection.
                    err_code = sd_ble_gap_connect(&p_adv_report->peer_addr,
                                                  &m_scan_params,
                                                  &m_connection_param);
    								
    								
                    if (err_code == NRF_SUCCESS)
                {
                    
                    printf("Connecting to target %02x%02x%02x%02x%02x%02x\r\n",
                             p_adv_report->peer_addr.addr[0],
                             p_adv_report->peer_addr.addr[1],
                             p_adv_report->peer_addr.addr[2],
                             p_adv_report->peer_addr.addr[3],
                             p_adv_report->peer_addr.addr[4],
                             p_adv_report->peer_addr.addr[5]
                             );
                }
                }
            }
        } 
    			
    			
    			break; // BLE_GAP_ADV_REPORT
    

    The problem is trying to get the UUID characteristics to show up in the UART terminal such as Termite when inputting buttons on a peripheral device. The NRF52 board should act as a central and peripheral.So that is why I am trying to incorporate the UART example with HRS relay example.

Reply
  • This is how I have it set up:

    case BLE_GAP_EVT_ADV_REPORT: {

            if (strlen(m_target_periph_name) != 0)
            {
                if (find_adv_name(&p_gap_evt->params.adv_report, m_target_periph_name))
                {
                    // Initiate connection.
                    err_code = sd_ble_gap_connect(&p_gap_evt->params.adv_report.peer_addr,
                                                  &m_scan_params,
                                                  &m_connection_param);
                    if (err_code != NRF_SUCCESS)
                    {
                        NRF_LOG_INFO("Connection Request Failed, reason %d\r\n", err_code);
                    }
                }
            }
    					
    					
            else
            {
               /** We do not want to connect to two peripherals offering the same service, so when
                *  a UUID is matched, we check that we are not already connected to a peer which
                *  offers the same service. */
    						
    						const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;
    						
                if ((is_uuid_present(&m_adv_uuids[0], p_adv_report)))
    								
                {
                    // Initiate connection.
                    err_code = sd_ble_gap_connect(&p_adv_report->peer_addr,
                                                  &m_scan_params,
                                                  &m_connection_param);
    								
    								
                    if (err_code == NRF_SUCCESS)
                {
                    
                    printf("Connecting to target %02x%02x%02x%02x%02x%02x\r\n",
                             p_adv_report->peer_addr.addr[0],
                             p_adv_report->peer_addr.addr[1],
                             p_adv_report->peer_addr.addr[2],
                             p_adv_report->peer_addr.addr[3],
                             p_adv_report->peer_addr.addr[4],
                             p_adv_report->peer_addr.addr[5]
                             );
                }
                }
            }
        } 
    			
    			
    			break; // BLE_GAP_ADV_REPORT
    

    The problem is trying to get the UUID characteristics to show up in the UART terminal such as Termite when inputting buttons on a peripheral device. The NRF52 board should act as a central and peripheral.So that is why I am trying to incorporate the UART example with HRS relay example.

Children
No Data
Related