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

Ble central- BLE app multilink using UART for other MCU connections

Hi NordicS,

We have a project that uses multiple BT peripheral devices connected to various sensors, and 3 BT centrals that are connected to a MCU that acts as the "mainframe" for collecting the data that is retrieved from the peripherals via the BT centrals. As such, we need to modify the BT centrals to be able to use UART for communicating with the external mainframe MCU. The reason for using UART is so that we could use terminals and send AT like commands to control the BT centrals.

I have tested the BLE app multilink example and made sure it is able to connect to peripheral device. works fine. Specified the slave device name and upon reboot it searches for the slave and conects automatically.

After that I tried to integrate the "peripheral\UART -  example" to the central app, which failed. Next i disabled the nRF log feature, which also does not help. The BT central cannot automatically connect to the slave device anymore. Any clue would be appreciated. thx

Parents
  • Could you try to debug your program, and figure out exactly where it's failing? Also, could you provide some logs as well? Either through printf() or NRF_LOG with RTT as backend, I think NRF_LOG with UART as a backend interferes with the peripheral/uart example.

    Best regards,

    Simon

  • thx Simon. did as suggested, and unsurprisingly the program halts right  where the UART needs to be initialized  ( const app_uart_comm_params_t comm_params ). Below is the modified code.

    int main(void)
    {
        // Initialize.
        //log_init();
        timer_init();
        leds_init();
        buttons_init();
        power_management_init();
        ble_stack_init();
        gatt_init();
        db_discovery_init();
        lbs_c_init();
        ble_conn_state_init();
        scan_init();
        scan_start();
    //////////////////////////
        bsp_board_init(BSP_INIT_LEDS);
        uint32_t err_code;

        const app_uart_comm_params_t comm_params =
          {
              ARDUINO_SDA_PIN, //RX_PIN_NUMBER,
              ARDUINO_SCL_PIN, //TX_PIN_NUMBER,
              RTS_PIN_NUMBER,
              CTS_PIN_NUMBER,
              UART_HWFC,
              false,
    #if defined (UART_PRESENT)
              NRF_UART_BAUDRATE_115200
    #else
              NRF_UARTE_BAUDRATE_115200
    #endif
          };
                   
        APP_UART_FIFO_INIT(&comm_params,
                             UART_RX_BUF_SIZE,
                             UART_TX_BUF_SIZE,
                             uart_error_handle,
                             APP_IRQ_PRIORITY_LOWEST,
                             err_code);

        APP_ERROR_CHECK(err_code);


        
        /*// Start execution.
        //NRF_LOG_INFO("Multilink example started.");
        for (;;)
        {
            idle_state_handle();
        }*/
            
        printf("\r\nUART example started.\r\n");

        while (true)
        {
            uint8_t cr,hr,lr, total_cmd_length = 0;
            uint8_t received_cmd[BUF_LENGTH] ;
          
                while (true)
                {
                    while (app_uart_get(&cr) != NRF_SUCCESS );
                   ................

                      //do sth
                        printf(" received %x !",cr);
                                        
                    }
                };
                    
                    for (int i=0; i < total_cmd_length; i++ ){
                        printf(" \r\n received %0.2x,total length of cmd %0.2x !\r\n",received_cmd[i],total_cmd_length);
                    }
                        printf(" \r\n received %0.2x!\r\n",received_cmd[0]+received_cmd[1]+received_cmd[2]);
                    
            if (cr == 'q' || cr == 'Q')
            {
                printf(" \r\nExit!\r\n");

                while (true)
                {
                    // Do nothing.
                }
            }
        }    
            
    }

    As seen above, the code has been changed so that log is not inited, the sdk_config has been updated accordingly and disabled the nRF log. Then right where the idle_state_handle is to be called has been replaced by the UART app_uart_get loop. The code compiles , but halts right where UART is to be initialized. Any ideas would be appreciated, thx.

  • still trying. what is the error: use of undeclared identifier 'NRFX_UARTE1_INST_IDX' implying ?

    what needs to be set ? thx

  • I was able to initialize the UART, without any errors. I didn't test the actual UART (app_uart_get(..) and app_uart_put(..) ), but I think that should work fine. I have attached the project down below.

    ble_app_multilink_central_with_uart.zip

    Best regards,

    Simon

Reply Children
Related