implementing custom service

product details:

nRF52840 custom board

nRFConnectSDK 2.2.0

we want to implement custom service interacting with the Android app.

Where we will receive on command from Android app and we will do some processing and sending the data back to the android app.

For this what and all we need to do.

for ex: service

what characteristics and what descriptors are needed and their properties.

All we need to know is how to write custom service and for our requirement what we need to add.

Parents Reply Children
  • we have two different products where in 1 it goes as USB CDCACM.

    In another we have UART interface. In this we want to tap the data to BLE connected to Android app/ios app. In the same we want UART communication to iMX.

    Ofcourse currently testing this with laptop instead of iMX where UART driver send data to COM(testing with tera term). Final thing will be iMX.

    Is this both possible in single application. Currently as you suggested we are in process to move UART method to serial recovery method. But before that making our code work with BLE over UART has become priority. So requesting this in paralllel to other ticket.

    adding to the above query, UARTE is taking uart0 i think.

    Just now found nelw lines from:

    config NRFX_UART0
        bool "UART0 driver instance"
        depends on $(dt_nodelabel_has_compat,uart0,$(DT_COMPAT_NORDIC_NRF_UART))
        select NRFX_UART

    config NRFX_UARTE
        bool

    config NRFX_UARTE0
        bool "UARTE0 driver instance"
        depends on $(dt_nodelabel_has_compat,uart0,$(DT_COMPAT_NORDIC_NRF_UARTE))
        select NRFX_UARTE

    C:\ncs\v2.2.0\zephyr\modules\hal_nordic\nrfx\kconfig

    So will uart0 is available for BLE and also COM/shell connection.

    for shell/data communication we are using below"

    #define UART_DEVICE_NODE DT_CHOSEN(zephyr_shell_uart)
    struct device *uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);

    Peripheral UART uses:

    static const struct device *uart = DEVICE_DT_GET(DT_CHOSEN(nordic_nus_uart));
    Both can be used in same application?
    Sorry for multiple edits.
    I thought one thing, so added the UART code to BLEperipheral UART code which i tested on nRF52840 DK.
    On to the same I tested echo_bot code seperately to test serial code.
    ow I merged both, and see only BLE code works as it took over the UART first.
    In main.c the code in #if 1 ... #endif belongs to serial.
    Attaching here.BLEperipheraUART.zip
  • Srikara said:
    Still we need CONFIG_NRFX_UARTE0=y with CDC_ACM interface to iMX and also UART interface?

    I do not think you need UARTE drivers to do CDC_ACM, no.

    Srikara said:
    Is this both possible in single application. Currently as you suggested we are in process to move UART method to serial recovery method. But before that making our code work with BLE over UART has become priority. So requesting this in paralllel to other ticket.

    MCUmgr only supports one interface at a time for its DFU, unfortunally. It is probably possible to work around this somehow, but I do not think it will be easy.
    I think that generally, it will be easier to make the app if you have different application code for the UART device and the CDC ACM device.

  • Hi

    Sorry, ithink misunderstood.

    I am asking about second picture where it is UART interface to iMX.

    In this case UARTE0 is needed and it uses uart0 and in actual communication case also

    #define UART_DEVICE_NODE DT_CHOSEN(zephyr_shell_uart)
    struct device *uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);

    uart0 is used.

    So we want both BLE and uart communication need to be worked.

    Please gothrough the code i ahve shared. YOu will have a clue what i am asking.

    This code is merging of two nRF connect SDK sample applications.

    C:\ncs\v2.2.0\nrf\samples\bluetooth\peripheral_uart

    and C:\ncs\v2.2.0\zephyr\samples\drivers\uart\echo_bot

    these two together should work on uart communication.

  • Srikara said:

    This code is merging of two nRF connect SDK sample applications.

    C:\ncs\v2.2.0\nrf\samples\bluetooth\peripheral_uart

    and C:\ncs\v2.2.0\zephyr\samples\drivers\uart\echo_bot

    The peripheral_uart sample already does UART for your.
    I do not think merging these two samples makes much sense.

    You have two alternatives, and I am not sure which one you need. Here they are, with suggested solutions:

    1. Receive data over UART from iMX and send directly over BLE without changing data:
      1. Run Peripheral UART sample as is. Minor changes needed.
    2. Receive data over UART from iMX. Do operations with data on nRF. Then send something else over BLE.
      1. Learn how to implement Bluetooth applications from DevAcademy Bluetooth course. Specifically its Lesson on Bluetooth and UART will be useful for you.

    Do I understand correctly? Does my suggestions make sense?

  • we need both, same customer may send the data from iMX and android app.

    If he is sending request from android app, he will receive response to android app.

    for example: read command is sent

    then all the nearby RFID tags details will be sent to android app

    If he is sending from iMX he will be received to iMX

    for example: read command is sent

    then all the nearby RFID tags details will be sent to iMx

    Like read we have lot of commands so usage may be iMX/Android app.

    This is our requirement. Will this can be done? If so How we will do it.

    You have two alternatives, and I am not sure which one you need. Here they are, with suggested solutions:

    1. Receive data over UART from iMX and send directly over BLE without changing data:
      1. Run Peripheral UART sample as is. Minor changes needed.
    2. Receive data over UART from iMX. Do operations with data on nRF. Then send something else over BLE.
      1. Learn how to implement Bluetooth applications from DevAcademy Bluetooth course. Specifically its Lesson on Bluetooth and UART will be useful for you.

    Based on our requirement i think this is not useful i Believe.

Related