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

send data from msp430

Now i try to send many data from external device. I can send it for 4 times. But after that,the device will be disconnection. I used analog discovery and I was able to confirm that the data is coming. I want to solve the problem,but I don't know what is cause.

thank you in advanced

the picture is shown in below. gyazo.com/ba22bef2273e66ca23d5105f556e0a43 gyazo.com/a4ef65861f6cbba748fdc2225ae0210d

  • thank you for your reply! I am planning to create a program to send external data to iphone by changing nus_data_handler () program!! if (p_evt-> params.rx_data.p_data [p_evt-> params.rx_data.length - 1] == '\ r') Do you send data all the time if you insert the ble_nus_string_send function in the while statement in the above if statement? regards!

  • Ok, then you should instead change the function uart_event_handle(). This is the function that receive the external data over UART, and then it will sent it over BLE to the phone/central.

  • Oh i see!! if that,should Should I add ble_nus_string_data function in uart_event_handler ()? regards!

  • By default, the uart_event_handle() function should already have the ble_nus_string_send() function. You dont need to add it again.

    By default the function looks like this:

    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] == '\n') || (index >= (m_ble_nus_max_data_len)))
                {
                    NRF_LOG_DEBUG("Ready to send data over BLE NUS");
                    NRF_LOG_HEXDUMP_DEBUG(data_array, index);
    
                    do
                    {
                        uint16_t length = (uint16_t)index;
                        err_code        = ble_nus_string_send(&m_nus, data_array, &length);
                        if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY))
                        {
                            APP_ERROR_CHECK(err_code);
                        }
                    } while (err_code == NRF_ERROR_BUSY);
    
                    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;
        }
    }
    
  • thank you for your reply! i see! if that,Shouldn't i change the contents of nus_data_handler? ragards!

Related