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

Help in nRF51 ble_app_uart_c_S120

Hi every one,

I work on application that read continuous analog signal with 500 sample/second and send it from nRF51822 board (1) to nRF51822 board (2) and read this value in pc via UART, i found the example for auto scanning and pairing works on master mode and based on S120 soft device in this link github.com/.../ble_app_uart_c_S120. I flash it in nRF51 dongle, it is work fine , the starting scanning and pairing, but there is a time delay after pairing (about 1 to 2 minutes) in this period i cannot receive any thing, after this the process work fine and the data received in board (2) and i can read it by using any UART terminal software. Is this case is normal ? or there is an additional setting should be done.

Thanks for your help

Regards

tests.pcapng

  • @ahmed: I tried to reproduce the issue here but couldn't, no delay observed. Could you try to record a sniffer trace so that we can see what happens over the air ? Which board did you used for testing? Which chip version is on that board?

  • Dear Hung,

    I used the RBL NanoBLE for reading analog signal and program it by using MBED on line compiler(work as peripheral), and use the nRF51 Nordic Dongle(program it with github example and work as central) for receiving the data and show it via UART. As i mentioned above, there is a delay in reading the UART data for (1 to 2 minutes) at starting then it is work fine, i try to use wireshark in sniffer but there it doesnt work. The code that i used for RBL NanoBLE is listed below:

    #include <string.h>
    #include "mbed.h"
    #include "BLEDevice.h"
    
    #include "UARTService.h"
    #include "nrf_temp.h"
    
    #define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console;
                                   * it will have an impact on code-size and power consumption. */
    #define UART_BAUD_RATE          (38400UL)
    
    
    #if NEED_CONSOLE_OUTPUT
    #define DEBUG(STR) { if (uart) uart->write(STR, strlen(STR)); }
    #else
    #define DEBUG(...) /* nothing */
    #endif /* #if NEED_CONSOLE_OUTPUT */
    
    BLEDevice  ble;
    DigitalOut led1(LED1);
    UARTService *uart;
    Serial      m_serial_port(p9, p11);  // TX pin, RX pin
    //UARTService *m_uart_service_ptr;
    
    AnalogIn   ain1(A5);
    AnalogIn   ain2(A4);
    AnalogIn   ain3(A3);
    uint16_t kk;
    uint16_t kk2;
    uint16_t kk3;
    char buf [15];
    
    
    
    void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
    {
        DEBUG("Disconnected!\n\r");
        DEBUG("Restarting the advertising process\n\r");
        ble.startAdvertising();
    }
    
    void periodicCallback(void)
    {
       // led1 = !led1;
        kk = ain1.read_u16();
        kk2 = ain2.read_u16();
        kk3 = ain3.read_u16();
        
      
      sprintf (buf, "%d,%d,%d,\r\n", kk, kk2,kk3);
      
          DEBUG(buf);
         
    
    }
    
    int main(void)
    {   
        m_serial_port.baud(UART_BAUD_RATE);
        
        led1 = 1;
        Ticker ticker;
        ticker.attach(periodicCallback, 0.005);
    
        DEBUG("Initialising the nRF51822\n\r");
        ble.init();
        ble.onDisconnection(disconnectionCallback);
        
        uart = new UARTService(ble);
    
        /* setup advertising */
        ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
        ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
        ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
                                         (const uint8_t *)"BLE UART", sizeof("BLE UART") - 1);
        ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,
                                         (const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));
    
        ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */
        ble.startAdvertising();
    
        while (true) {
            ble.waitForEvent();
        }
    }
    
  • @ahmed: I was testing with this project on mbed board. Seeing no issue. I think I would need a sniffer trace to tell what could be wrong on your board.

  • Dear Hung, I try to use sniffer for tracing BLE packet, but it doesn't respond ? i don't know why ?

  • @ahmed: Please let me know more on the issue with the sniffer. Take a screenshot when you have the issue. Have you tried the project I mentioned in the above comment ?

Related