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

NUS with Scanner

I can scan beacons with Scanner. and can use NUS (ble_periperall\ble_app_uart ) to get connect with device.

My goal is to combine both application Have NUS Service to connect with Mobile and Scanner for scanning and sending beacon data to Uart.

After combining code, I can connect to device using Mobile. and Device also receives the beacon.

When when I connect with device it stops Scanner. I want to make connection to configure device and Scanner should also work at this time.

Thank You

Bivay   



  • Hello,

    You must start scanning again after the connection has been made. You probably need to increase the number of central connections that the device has, or else you will get an error when you try to start the scan when you are already connected. 

    Search for NRF_SDH_BLE_CENTRAL_LINK_COUNT and NRF_SDH_BLE_TOTAL_LINK_COUNT. They should both be set to 2.

    Best regards,

    Edvin

  • Thanks for response.

    I want to send beacon data using NUS to mobile. and its only possible if scanner and NUS works simultaneously.

    Please consider above statement to help me.

    Thank You

    Bivay

  • Sorry, I mixed the nus_c and nus. 

    Either way, you need to start scanning in addition to advertising. In that case, you must set NRF_SDH_BLE_CENTRAL_LINK_COUNT to 1, NRF_SDH_BLE_PERIPHERAL_LINK_COUNT to 1 and NRF_SDH_BLE_TOTAL_LINK_COUNT to 2.

    Then you start scanning like it is done in the ble_central examples, and you start advertising like it is done in the ble_perpheral examples.

    If you want some further inspiration, you can check out the example found in:

    SDK\exapmles\ble_central_and_peripheral\experimental\ble_app_hrs_rscs_relay, which does both scanning and advertising.

    Best regards,

    Edvin

  • Dear,

    Thanks for support, From our help I get one step ahead. When I connect to NUS Device with scanner, Scanner works as expected, I can see data of beacon on logger even after connection. But There is another issue After connection when I transmit data from Mobile to Device, It doesn't receive data and scanner is also stopped for some time about 9 seconds.

    In mobile I get Two Errors:

    ERROR 133 (0x85): GATT ERROR

    ERROR 8 (0x8) : GATT CONN TIMEOUT

    After this message device again start scanning of beacon and advertise.

    If I didn't send data on NUS Bus then Scanner works but NUS get disconnect with below error after nearby 9 seconds.

    ERROR 8 (0x8) : GATT CONN TIMEOUT

    But when at event BLE_GAP_EVT_CONNECTED, if I stop scanning using sd_ble_gap_scan_stop(), NUS Bus works. and at event BLE_GAP_EVT_DISCONNECTED I start scanning again.

    Please Help me regarding this.

    Thank You

    Bivay

  • It looks like your nRF application is crashing. Have you tried monitoring the log from the nRF5840?

    If it says "Fatal error" somewhere, try to add DEBUG in your preprocessor definitions. (Let me know what IDE you are using if you are not sure how to do this).

    BR,

    Edvin

Related