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

Using BLE NUS SERVICE without UART

Hello

I would like to send my sensor data to a mobile application using BLE SDK 15. Someone suggested me to go through the BLE NUS SERVICE example which was a good one. I understood a lot of things but now my sensor values are coming on analog pins and not on UART pins. How do i send those values? Would i have to create a whole new service for doing this or could i somehow modify the same example to work according to my needs. Thanks!  

Parents
  • Hello,

    What type of sensor do you use? Do they communicate using the UART protocol? If they do, then you can only change the uart_init() function in main.c to use the pins that you use. If they use some other protocol, then you have to read using the correct protocol, and then pass them on to the UART service. 

     

    You don't need to create anything else.

    Whatever is passed on into ble_nus_data_send() will be sent to the connected device, as long as notifications is enabled.

     

    Best regards,

    Edvin

  • Hello Edvin, Thank you for your response. I have a couple of more doubts  on UART service example before closing out on this string. I would highly appreciate if you could help me out with those. My sensors give values on analog pins using SAADC without using any other serial interface protocol. Now, i do not need to keep uart_init() function in my program and inside uart_event_handle(app_uart_evt_t * p_event) function, instead of using app_uart_get function i would call my custom function to fetch sensor values and use ble_nus_data_send() function to send that value to my connected mobile application . is that right or am i missing something here?

    Lastly, In this example my nrf52840 board is a peer and application is nordic uart mobile application. So, when i send data from my application to the board, then void nus_data_handler function is called?? and when i send data from board to mobile application then uart_event_handle() function is called???is that right?? or is it vice-versa.  I am sorry, i tried to put breakpoints to analyze this behavior but was not able to crack it.

    It would be great if i could get answers these questions. 

    Thanks and Regards,

  • Yes, as you can see in the image. I have enabled the notification. I believe there is a bug in my code. Thanks,

  • Ok, good.

    Can you check the return value of ble_nus_data_send()? Does it return NRF_SUCCESS, or one of the other values that are filtered out, NRF_ERROR_INVALID_STATE or NRF_ERROR_BUSY?

     

    If not NRF_SUCCESS, I suspect NRF_ERROR_INVALID_STATE. If so, I think you are missing something that needs to be set up in the ble_nus_c setup. Compare your project with the ble_app_uart example. A keyword is p_client->is_notification_enabled in ble_nus.c.

     

    But first check what ble_nus_data_send() returns.

     

    BR,

    Edvin

  • Hello Edvin,

    How can i check the return value ? I am getting 0x00000005 as error code in te return value. 

    Thanks,

  • Hello Edvin and Arshdeep!

    I am following to this thread. I want to know how to remove UART from the NUS example. In sdk_config.h, I did "#define APP_UART_ENABLED 0" and "#define UART_ENABLED 0". In main.c, I commented out "uart_event_handle()" and "uart_init()" functions. Still I get following errors in retarget.c file:

    .\_build\nrf52810_xxaa.axf: Error: L6218E: Undefined symbol app_uart_get (referred from retarget.o).
    .\_build\nrf52810_xxaa.axf: Error: L6218E: Undefined symbol app_uart_put (referred from retarget.o).

    How to handle this?

  • It sounds like you have removed the uart related .c-files, but still have some references to them. Make sure that you comment out all functions using app_uart_get() and app_uart_put, in addition to commenting out the lines that include "app_uart.h", "app_fifo.h" and "nrf_drv_uart.h".

    BR,

    Edvin

Reply Children
No Data
Related