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

about uart interrupt callback and mobile phone receive data in nRF52810

Sorry Nordic engineers , I'm asking urgently , goods need to come out quickly

chip:nRF52810

SDK:nRF5_SDK_15.0.0_a53641a

examples:ble_peripheral \ ble_app_uart

external chip (UART Tx) ---> (UART Rx) nRF52810 (BLE) ---> mobile phone

【1】This example should not have UART interrupt callback How should I add it ? ( If you can, the details can not be specific. ) 

【2】Function【static void nus_data_handler (ble_nus_evt_t * p_evt) 】,this should be the transfer of data to the mobile phone

Parameter (p_evt) is pointer , should it be associated in the interrupt callback?

【3】Mobile phone APP must be opened 【Notify】, then nRF52810 can send data , so these three conditions can achieve the function I want to achieve?

Thanks

  • Hi Tony,

    [1] See uart_event_handle() in that example's main.c for the UART receiver. It's called with an APP_UAR_DATA_READY event when the UART receives data.  

    [2] nus_data_handler handles data going in the opposite direction, from the mobile phone ----> BLE ---> nRF52810

    [3] How to do this depends on the app.  The nRF Connect Android app allows you to connect and turn notifications on. Your own Android app will need to do something like this:

           // If nordic nus device
            if (UUID_NRF_UART_SERVICE.equals(characteristic.getUuid())) {
                BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
                        UUID.fromString(CLIENT_CHARACTERISTIC_CONFIG));
                descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
                mBluetoothGatt.writeDescriptor(descriptor);
            }

    in BluetoothLeService.java's setChaacteristicNotification function

    Best Regards, Howard

  • Thank you for answer , but I have some questions.

    【1】Board power on ,  UART Debug tool can print 【UART Started】 , but send data , inability to enter uart_event_handle() (callback) , is enable need to open, or other settings?

    【2】UART Debug tool can print the data from the phone ,  if enter uart_event_handle() , this function ble_nus_data_send() is send data to mobile phone ?

    【3】Want to receive data from nRF52810 , mobile phone only needs to open the notify ,  other things should not be done?

  • What mobile app are you using to connect to the nRF52 chip? I assume you are using the nRF Connect app

    [1] How do you know that it doesn’t enter uart_event_handle(..)? Have you tried to debug, and setting a breakpoint inside the function? Toggling a LED would also work.

    Does the value of “TX Characteristics →Value” inside the nRF Connect app change after sending a message over the terminal (assuming you have enabled notifications by clicking the 3 arrows marked with green in the image below)?

    [2] The terminal (UART Debug tool) should print the data sent from the phone, you can test it out by enter in a message by clicking the arrow up in the nRF Connect app beside RX Characteristic (marked with red in image below).

    “if enter uart_event_handle() , this function ble_nus_data_send() is send data to mobile phone ?”: Yes, you are right. When entering uart_event_handle(), the data received over UART will be sent over BLE to the phone through the ble_nus_data_send() function.

    [3] No, you only need to enable notifications (in addition to connecting to the device). Then you should be able to send messages from the nRF52 chip to the phone

    Cheers, Simon

  • Thank you for answer , 

    UART debug tool all the printed messages are APP_UART_TX_EMPTY

    But I want to print a message from the UART debug tool 

    In the end I'll send the data to mobile phone

    Mobile app is my design, I've done it before

    probably know that must to turn on notify ,

    then to receive data from nRF52810.

  • Do the pin assignments in uart_init() match your configuration? If you are using for ex one of the nice Fanstel modules you may need to change off the default pins.

Related