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

Hello I am using Uart exampl

image description

I want to send data without a computer from 3 ADC sensors.

using de ble uart.

How do I set my variable to send data?

I should use in ble_nus_string_send(&m_nus, data_array, index);?

Thank you

Parents
  • So you will read your sensors with SPI or TWI and eventually you will be ready to send the data you collected. This data will be sent over uart using

    err_code = ble_nus_string_send(&m_nus, data_array, index);

    Here m_nus is the structure to identify the Nordic UART Service. This is important but you shouldn't have to touch it as it has been initialized in the example code.

    All you need to do is make sure the data you want to send is correctly stored in data_array. (Also note that the maximum number of data bytes you can send is 20 bytes at a time using ble_nus_string_send, unless you implement ble long write).

    index will be the number of bytes you are sending in this packet. So if you are sending 10 bytes of data (maybe 5 sensor readings) then index will equal 10.

    You shouldn't have to mess with the ble_uart example code much at all to get this working. Just look at the contents of this function /**@snippet [Handling the data received over UART] */ void uart_event_handle(app_uart_evt_t * p_event) where the send data over ble_uart.

    and this function /**@snippet [Handling the data received over BLE] */ static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length) where they receive data over ble_uart

Reply
  • So you will read your sensors with SPI or TWI and eventually you will be ready to send the data you collected. This data will be sent over uart using

    err_code = ble_nus_string_send(&m_nus, data_array, index);

    Here m_nus is the structure to identify the Nordic UART Service. This is important but you shouldn't have to touch it as it has been initialized in the example code.

    All you need to do is make sure the data you want to send is correctly stored in data_array. (Also note that the maximum number of data bytes you can send is 20 bytes at a time using ble_nus_string_send, unless you implement ble long write).

    index will be the number of bytes you are sending in this packet. So if you are sending 10 bytes of data (maybe 5 sensor readings) then index will equal 10.

    You shouldn't have to mess with the ble_uart example code much at all to get this working. Just look at the contents of this function /**@snippet [Handling the data received over UART] */ void uart_event_handle(app_uart_evt_t * p_event) where the send data over ble_uart.

    and this function /**@snippet [Handling the data received over BLE] */ static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length) where they receive data over ble_uart

Children
No Data
Related