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

receive data from the peripheral

hello everybody!

i want to sample an analog signal with  the board and send the 0/1 data with ble to the receiver .

i created my on service with rx and tx like in ble uart example but i don't now how to read the data received from the board . how could i do??

thans a lot for your answer!

marikalp.

Parents Reply
  • OK - I think I see what you want to do. Here is what I think you should try:

    SDK 15.2.0:
    File: nRF5_SDK_15.2.0_9412b96/examples/ble_peripheral/ble_app_uart/main.c
    functon: void uart_event_handle(app_uart_evt_t * p_event), line 521

    This is where normally Nordic is gettng 'data ready' from their UART device.
    You want to replace this with 'data ready' events from your ADC device.

    If you are using their SAADC, then those events will be EVENTS_END event. This signals that the SAADC has completed the conversion across all channels. In the SAADC device the converted data is held in the buffer NRF_SAADC_Type->RESULT_PTR.

    As a first start, the easiest way to get the ADC conversion across your BLE connection would be to directly call the function

    uint32_t error_code = ble_nus_data_send(&m_nus, your_data_pointer, your_data_length, m_conn_handle);
    Line 545 in that file.

    This should give you immediate results. These results will not be optimized for throughput. If you send your data too fast you will get the return code NRF_ERROR_RESOURCES from the call. At this point you will have to concern yourself with the connection interval and fitting your data chunks into the link layer payload or MTU size optimally. But this should get you started.

Children
Related