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

ble app uart problems

hi i have a problem with ble app uart.i used nRF5_SDK_12.3.0_d7731ad and Eclipse Mars 2. I had build main.c in hex ble_app_uart\pca10040\s132 . And after that a maked mergehex with s132_nrf52_3.0.0_softdevice.hex.i flashed into my BLE nitrogen. i can conect to BLE. But any messages what i sended on Bluetooth from my Phone Do not return in my phone but function can do it.And more when i put in condition code for togle blinky i had not any bkinky when i sended mesage from my phone

void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint8_t index = 0;
    uint32_t       err_code;

    switch (p_event->evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&data_array[index]));
            index++;

            if ((data_array[index - 1] == 'q') || (index >= (BLE_NUS_MAX_DATA_LEN)))
            {
                //send mesage as resived
                err_code = ble_nus_string_send(&m_nus, data_array, index);
                if (err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }

                index = 0;
            }
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_code);
            break;

        default:
            break;
    }
}
Parents
  • When i modified main

    int main(void)
    {
        uint32_t err_code;
        uint8_t dat_array[5]={'a','a','a','a','a'};
        bool erase_bonds;
        // Initialize.
        APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
        uart_init();
    
        buttons_leds_init(&erase_bonds);
        ble_stack_init();
        gap_params_init();
        services_init();
        advertising_init();
        conn_params_init();
    
        printf("\r\nUART Start!\r\n");
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
       	nrf_gpio_cfg_output(29);
        // Enter main loop.
        for (;;)
        {
        	ble_nus_string_send(&m_nus, dat_array, 5);
        	nrf_delay_ms(50);
            power_manage();
        }
    }
    

    i had mesage on my phone

Reply
  • When i modified main

    int main(void)
    {
        uint32_t err_code;
        uint8_t dat_array[5]={'a','a','a','a','a'};
        bool erase_bonds;
        // Initialize.
        APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
        uart_init();
    
        buttons_leds_init(&erase_bonds);
        ble_stack_init();
        gap_params_init();
        services_init();
        advertising_init();
        conn_params_init();
    
        printf("\r\nUART Start!\r\n");
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
       	nrf_gpio_cfg_output(29);
        // Enter main loop.
        for (;;)
        {
        	ble_nus_string_send(&m_nus, dat_array, 5);
        	nrf_delay_ms(50);
            power_manage();
        }
    }
    

    i had mesage on my phone

Children
Related