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).

  • Hello,

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

    Is the nRF52832 peripheral device a DK, or custom hardware?
    If it is a DK you can connect it to a computer and see the data it has received written out on a serial terminal. The default function of the ble_app_uart application is to output any data it receives over BLE to its UART.

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

    You can then use the peripheral's RX characteristic, instead of the TX characteristic. So the central will perform a write to the peripheral.

    Should I connect the j link to nrf52840 for checking if the sent data is writtien to it or not?

    BLE is a lossless protocol, so data can not be lost in the link. Either it will make it across to, and be acknowledged by the peer device, or the connection will be terminated (by the connection supervision timeout). So, if the connection persists, and you keep feeding data into your Central UART successfully, then you can be reasonably sure that this data makes it across to the other device.
    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?

    Best regards,
    Karl

  • 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

Related