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
  • Hi,

    Here in Norway we have had the Easter holidays, causing the delay in the answer. But we are all back in office now.

    To learn how to add new services to a BLE device, I recommend our Bluetooth Low Energy Fundamentals guide.

    Regards,
    Sigurd Hellesvik

  • Hi

    Sorry i was completely occupied with multiple objects. Did not get time to look into this.

    Got some breathing time. This we are planing initially as POC.

    THe requirement is: Custom service where

    1.From APP to NRF initially one request comes to send the data

    2.As the request comes the data will be sent from NRF to Android App.

    3.One main thing is this service and characteristics should run parallelly with the SMP service which as part of other PRIVATE case is handled.

    SO DFU and this custom service should work parallelly.

    For Both to work, how two services need to be implemented and what should be the custom service characteristics.

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

Reply
  • 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.

Children
  • Srikara said:

    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.

    These sound like custom requirements for Bluetooth LE operations.
    I suggest that you take the DevAcademy Bluetooth Course and learn how to implement your own Bluetooth LE applications so you can make it custom to match your requirements.

    EDIT:
    And when I say "custom", I mean that we do not have any samples that does exactly this

  • These sound like custom requirements for Bluetooth LE operations.
    I suggest that you take the DevAcademy Bluetooth Course and learn how to implement your own Bluetooth LE applications so you can make it custom to match your requirements.

    Actually what i mean to say is uart0 is already engaged with iMX, and also uart0 is getting used in peripheral UART.

    So for both to work together it is not possible right?

    Because we have only one uart is exposed in our custom HW.

  • Could you give a brief summary of what you need the UART for? I understand from the discussion that you use it as an interface between the nRF5 and IMX, but I'm not sure what else you need it for.

  • we need UART for DFU. For DFU he suggested serial recovery and other method. I need to test that in our board. Serial recovery I have tested in DK.

    Also we want to have one option of BLE peripheral UART. This we have tested in DK and in OUR board. But when we interface ot iMX the same UART will not be there for BLE peripheral UART purpose and DFU.

    As of now you can ignore DFU, as we are verifying serail recovery method.

  • Serial recovery is perfomed within the bootloader which does not run concurrently with the main app, so I wouldn't expect the DFU process to interfere with your regular UART comminucation. 

    Srikara said:
    interface ot iMX the same UART will not be there for BLE peripheral UART purpose

    It is up to the application to decide what data to relay over the BLE link.

Related