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

Heart Rate Collector with Custom Service

Hi there,

Using mbed i have currently programmed an nRF51 DK to transmit data through a custom service with 6 read only characteristics. Is there a simple way i can alter the Heart Rate collector example with an nRF51 Donge to recieve this data and log it on UART?

Thanks in advance

  • Hi

    I would recommend to look at the ble_app_uart_c_S120 example available on Nordic's Github. Received data is already logged on the UART in this example. To handle UART client functionality a new ble_uart_c module is created in the project. To get you started, the procedure is as follows:

    In the main function, the

    uart_c_init 
    

    function is called which defines the base Nordic UART Service (nus) UUID and registers it in the UUID database. Also the UART UUID is registered in the ble_evt_discovery module which enables services with UART UUID to be discovered. The db_discover_evt_handler is also registered as an event handler for the ble_db_discovery module, which means that once service discovery is complete the db_discover_evt_handler is called.

    Scanning is started in the main function in order to scan for peripherals with:

    scan_start();
    

    When an advertising packet is recieved, the application gets a callback with ID:

    BLE_GAP_EVT_ADV_REPORT
    

    If the UUID from the peripheral matches the Nordic UART Service (nus) UUID, then the central will connect to the peripheral. When connection establishment is complete, the application receives a callback from the Device Manager with event ID:

    DM_EVT_CONNECTION
    

    There the service discovery procedure is started by calling

    ble_db_discovery_start
    

    Since the Nordic UART Service (nus) UUID has already been registered in the ble_db_discovery module, this call starts discovery process of the Nordic UART service. When service discovery is complete the uart_c_evt_handler is called (the ble_db_discovery module calls the registered handler in ble_uart_c, which in turn calls the uart_c_evt_handler) with event ID

    BLE_uart_C_EVT_DISCOVERY_COMPLETE
    

    Here notification is enabled in order to receive data from the peripheral. At this point data can be received from the peripheral device in the uart_c_evt_handler with event ID

    BLE_UART_C_EVT_HRM_NOTIFICATION
    

    Received data is forwarded to the UART with call to

    app_uart_put
    

    Hopefully, this description gives you an idea of what needs to be done in your case. Let me know of followup questions.

  • after downloading the github project i cannot get it to compile. I have tried adding all the necessary software componants to the project such that it mimics that of the heart rate collector example. It still will not compile, i have managed to narrow it down to 3 errors all in the main.c stating the use of undeclared identifier 'ble_enable_params_t' (line 469) and unknown type name 'ret_code_t' (line 150). Is there a file missing? how i can resolve these issues so the project will work?

  • Have you resolved your compile issues yet? You should flash the S120 2.0 softdevice and insert the example into \nRF51_SDK_8.0.0_5fc2c3a\examples\ble_central. I unzipped the file and experienced that the folder tree in the zip file was two levels too deep. I erased the two folders at the top of the tree and then the references were all working when I opened the project in Keil.

  • yes i have since resolved my issues and since made my intended application, the problem was as you described, i had to open a seperate question but recieved a very helpful reply, devzone.nordicsemi.com/.../, thanks

Related