send data from ble to ble with UART

I'd like to know whether the cetnral get the data from peripheral or not.
I'm using UART, it connects mcu(stm32f4) to ble module (nrf52832) and ble module gets the sensed data.
Those data should be sent to other ble module (nrf52840) with NUS.
I'm checking the data is sent from nrf52832 (peripehral) to nrf52840 (central) with RTT viewer.
Using BLE in nrf connect program, I make the nrf52840 is central (adapter) and the nrf52832 is peripheral, after scanning and connecting.
I send the hex data in peripheral, such as 31 (0x31) in TX (Write) characteristic, I can see this value in RTT viewer, it is printed there.
Should I connect the j link to nrf52840 for checking if the sent data is writtien to it or not?
I don't know how to know it.

Also, what should I do if I want to send the data from central to peripheral?

And, is it correct that using UART/NUS for sending the data from ble to another ble? it should be bidirectional (read and write).

Parents
  • Thanks for reply, Karl.

    Is the nRF52832 peripheral device a DK, or custom hardware?

    It is the custom circuit.

    The thing is, is the UART service okay to communicate with central to peripheral with wireless connection?
    It is really confusing for me because it seems like wireed connection. Can I use uart service even though there is no wire connection?

    However, to be sure, could you perhaps scope the UART pins of your peripheral device, to see what it is outputting? Or, could you blink a LED whenever data is received, perhaps?


    I'm testing on it, I check the write characteristic with nrf connect app.
    After I wrote the data in the app, the ble is connected with J link and I can watched the same data I wrote in app.

    After this, I'm moving on to make the communication ble with ble with uart service.

  • Bi_ said:
    Thanks for reply, Karl.

    No problem at all, I am happy to help! :) 

    Bi_ said:
    The thing is, is the UART service okay to communicate with central to peripheral with wireless connection?
    It is really confusing for me because it seems like wireed connection. Can I use uart service even though there is no wire connection?

    As, yes, this can be a little confusing. The ble_app_uart is made as a 'emulated UART over BLE', but it also actually uses the hardware UART peripheral. So, the ble_app_uart is like a 'wireless UART', in essence :) 
    Please do not hesitate to let me know if any part of this still should be unclear, or if you have any additional questions about this!

    Best regards,
    Karl

  • Thanks, again, it's helpful Slight smile

    Could I ask one more thing?

    The ble module is connected with h/w uart with mcu, and it should be connected to other ble with wireless uart.
    Is it okay to use same uart event handler?

    I've allocated the RX, TX pin and other settings(eg. flow control) to connect it to mcu in uart_init() function.
    There is some hard fault error when I make 2 uarts setting to seperate them (wired uart with mcu and wireless uart with ble).

    The ble isn't confused? What should I do to set them seperately?

  • Hello again,

    Bi_ said:
    Could I ask one more thing?

    Of course! :) Just keep in mind that if the questions diverge from the question in the original ticket it is better to open up a separate ticket for this question, so that other domain-expert Nordic engineers can work on it in parallel.

    Bi_ said:
    The ble module is connected with h/w uart with mcu, and it should be connected to other ble with wireless uart.
    Is it okay to use same uart event handler?

    The unmodified example actually already has separate event handlers for the BLE UART and the Hardware UART - which is the bt_receive_cb and uart_cb respectively.

    Bi_ said:
    There is some hard fault error when I make 2 uarts setting to seperate them (wired uart with mcu and wireless uart with ble).

    I am not sure that I understand what you mean by this, could you elaborate?
    Do you intend to use 2 UART instances? If so, please share the code you have used to do this, and what you intend to achieve.

    Bi_ said:
    The ble isn't confused? What should I do to set them seperately?

    The BLE should not be confused, no - the uart_cb is registered to the 'uart' instance, and it is the uart_cb function that calls the bt_nus_send function (which sends the received data over BLE). So long as you have a different cb registered for your second instance, this will not be an issue.

    Best regards,
    Karl

  • Of course! :) Just keep in mind that if the questions diverge from the question in the original ticket it is better to open up a separate ticket for this question, so that other domain-expert Nordic engineers can work on it in parallel.

    Thanks!

    The unmodified example actually already has separate event handlers for the BLE UART and the Hardware UART - which is the bt_receive_cb and uart_cb respectively.

    I don't use zephyr, but I can understand and I've solved it by seperating the event handle. Nus event handle and uart event handle are initialized in service init function, and define ble_nus_string_send. 

    It was confusing because I'd like to watch the sent data with serial monitor (pc) that is connected with uart lol, uart with mcu, uart with ble, and uart with pc :( 

    Anyway, I can send the data from app, and the ble is receiving it and it is shown in RTT viewer. Also, that data is sent to mcu, either, I can watch it on serial monitor. 

    Now, I can send the data from nrf connect app to ble, the reverse sequence (sending the data from mcu to ble, and app) isn't work, even though the notify is enable. It is a different issue, I'll open other thread after I'm trying to solve it :) 

  • Bi_ said:
    I don't use zephyr, but I can understand and I've solved it by seperating the event handle. Nus event handle and uart event handle are initialized in service init function, and define ble_nus_string_send. 

    Ah, my apologies for the incorrect assumption. I am glad to read that the understanding carried over to the nRF5 SDK application nevertheless, great! :) 

    Bi_ said:
    It was confusing because I'd like to watch the sent data with serial monitor (pc) that is connected with uart lol, uart with mcu, uart with ble, and uart with pc :( 

    Hehe, yes, there is a lot of UART going on.. Perhaps it could be helpful to read through the ble_app_uart example documentation, to better the understanding?
    In essence, the device hardware UART peripheral communicates with the serial terminal on your pc. Additionally, it transmits whatever it receives in its communication with the PC, to its connected peer device, as well as echoing whatever it receives from the connected peer device over BLE to the serial terminal on the computer, through the hardware UART connection.

    Bi_ said:
    Anyway, I can send the data from app, and the ble is receiving it and it is shown in RTT viewer. Also, that data is sent to mcu, either, I can watch it on serial monitor. 

    So it now works as intended, great!
    I notice that you view it in RTT Viewer, did you change the outputting of the data received over BLE to instead be output by the logger over RTT?

    Bi_ said:
    the reverse sequence (sending the data from mcu to ble, and app) isn't work, even though the notify is enable. It is a different issue, I'll open other thread after I'm trying to solve it :) 

    This works in the unmodified example - what changes have you made to the application, on either side of the BLE link?

    Best regards,
    Karl

Reply
  • Bi_ said:
    I don't use zephyr, but I can understand and I've solved it by seperating the event handle. Nus event handle and uart event handle are initialized in service init function, and define ble_nus_string_send. 

    Ah, my apologies for the incorrect assumption. I am glad to read that the understanding carried over to the nRF5 SDK application nevertheless, great! :) 

    Bi_ said:
    It was confusing because I'd like to watch the sent data with serial monitor (pc) that is connected with uart lol, uart with mcu, uart with ble, and uart with pc :( 

    Hehe, yes, there is a lot of UART going on.. Perhaps it could be helpful to read through the ble_app_uart example documentation, to better the understanding?
    In essence, the device hardware UART peripheral communicates with the serial terminal on your pc. Additionally, it transmits whatever it receives in its communication with the PC, to its connected peer device, as well as echoing whatever it receives from the connected peer device over BLE to the serial terminal on the computer, through the hardware UART connection.

    Bi_ said:
    Anyway, I can send the data from app, and the ble is receiving it and it is shown in RTT viewer. Also, that data is sent to mcu, either, I can watch it on serial monitor. 

    So it now works as intended, great!
    I notice that you view it in RTT Viewer, did you change the outputting of the data received over BLE to instead be output by the logger over RTT?

    Bi_ said:
    the reverse sequence (sending the data from mcu to ble, and app) isn't work, even though the notify is enable. It is a different issue, I'll open other thread after I'm trying to solve it :) 

    This works in the unmodified example - what changes have you made to the application, on either side of the BLE link?

    Best regards,
    Karl

Children
No Data
Related