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

Concurrent Central/Peripheral UART

Hi,

I'am actually trying to develop a BLE based remote, with NRF52832, S132.

This remote must be configured by a smartphone (the remote act as peripheral) and be able to control one equipement (and act as Central).

As i only need to use uart on each side, i've started mixing demo programs ble_app_uart_c.c (central) and ble_app_uart.c (peripheral) without success.

As peripheral: The board advertise correctly, i can connect to it on my smartphone with the app nRF UART v2.0 but the NUS_data_handler seems not receive any message.

As central: When the board try to connect with another board flashed with ble_app_uart.c, the conn_handle indicate 65532 and the role is BLE_GAP_ROLE_INVALID instead of BLE_GAP_ROLE_CENTRAL.

RAM configuration: start: 0x20003DB0, size: 0xC250

My program: ble_app_uart_c.zip

Thanks a lot for your advice to correct these errors !!!

Parents Reply Children
  • Hi Jorgen,

    Sorry for late reply, I flashed the correct softdevice only but still it is not working.

  •  */
    static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
    {	
    	  uint16_t conn_handle_nb;
    	  uint16_t role;
    	  
    	  ble_conn_state_on_ble_evt(p_ble_evt);
    	
    	  conn_handle_nb = p_ble_evt->evt.gap_evt.conn_handle;
        role        = ble_conn_state_role(conn_handle_nb);
    	
    	  SEGGER_RTT_printf(0,"EVT conn handle num %u!!\r\n", conn_handle_nb);
    	
    	 if(role != BLE_GAP_ROLE_INVALID)
    		{
    			    if (role == BLE_GAP_ROLE_PERIPH) //MAX
    					{
    							SEGGER_RTT_printf(0,"PERIPH\r\n");
    							on_ble_peripheral_evt(p_ble_evt);
    							ble_advertising_on_ble_evt(p_ble_evt);
    							ble_conn_params_on_ble_evt(p_ble_evt);
    						//dispatch to peripheral application
    						ble_nus_on_ble_evt(&m_nus, p_ble_evt);
    					}
    					
    				else	if (role == BLE_GAP_ROLE_CENTRAL)
    					{
    							SEGGER_RTT_printf(0,"CENTRAL\r\n");
    							on_ble_central_evt(p_ble_evt);
    							bsp_btn_ble_on_ble_evt(p_ble_evt);
    							ble_db_discovery_on_ble_evt(&m_ble_db_discovery, p_ble_evt);
    							ble_nus_c_on_ble_evt(&m_ble_nus_c,p_ble_evt);
    					
    					// If the peer disconnected, we update the connection handles last.
            if (p_ble_evt->header.evt_id == BLE_GAP_EVT_DISCONNECTED)
            {
                on_ble_central_evt(p_ble_evt);
            }
    		  }
    					
    					
    		else 
    		{
    					SEGGER_RTT_printf(0,"INVALID\r\n");
    		}
    
    }
    		
    }
    		
    

    Is this the change you suggested to Maxim?

Related