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

UART + non-connectable advertisement

I am trying to broadcast a non-connectable advertisement (such as a beacon) while I am connected to a device that I am transferring data via TX. I am working with a nRF52840 on Segger Embedded Studio v3.4 with the nRF5_SDK_15 as the base for my code manipulation. More specifically I'm going off the ble_app_uart example for pca10040 s132. I don't care about receiving data through RX from the device I am connected to. By the way, I have tried using the Time Slot API where I try to initiate the advertising of the beacon when the device connects through UART. It is my understanding from projects such as the nRF51-multi-role-protocol-conn-observer-advertiser example on github but this is for nrf51 devices. I have tried to mimick this project as well as articles showing how the time slot api can be used to implement non-connectable advertising during a connection as a peripheral. I have also tried doing this without the Time Slot API but to no avail. My thinking is that the buffer transferring data out of the device can only handle 31 bytes of data per interval, but both the advertising and uart protocols take up 31 bytes so its not possible to do at the same time. There must be a way to switch between the two protocols (uart and advertisement) when the radio interrupt occurs. Please help.

  • Edvin,

    I am not trying to advertise more than 31 bytes. I am performing the exact same advertising_init and advertising_start functions from ble_app_beacon example along with the needed variables which I bring into the ble_app_uart example. I am going to try altering the advertising handle that is used to setup the UART connection and will let you know how that goes because it sounds like that is the problem. What is confusing is the setup for both advertisements (UART and beacon) are completely different such as with the UART advertising_init method there is no explicit handle: 

    static void advertising_init(void)
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance = false;
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }
    There is a evt_handler while with the other advertising method there is m_adv_handle variable but those are performing different functions.
  • In ble_app_uart, the sd_ble_gap_adv_set_configure is done in advertising_start(); The advertising handle is inside the m_advertising variable

    BLE_ADVERTISING_DEF(m_advertising).

    the m_advertising is a ble_advertising_t variable. you can find the advertising handle:

    m_advertising.adv_handle;

     

    Best regards,
    Edvin

  • I'm able to connect to the device via UART, but the beacon non-connectable advertisement isn't being triggered. This is clear based on the fact that the device can't detect the beacon, but also because of the fact that the advertising led is not blinking. The connected led is on though.

  • Hello,

    Sorry for the late reply. I have been out of office.

    Can you send the project, and I can check it.

    The led will not start to blink unless it is told to, and obviously, it can't blink and be solid at the same time. is err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING); called at any point? It is usually in the on_adv_evt() event handler.

    When you start to advertise again, does any of the function calls return an err_code not equal to NRF_SUCCESS (==0).

    What device are you scanning the beacon advertising with? Do you see them if you run the beacon example on another DK next to the one you are working on now?

    Best regards,

    Edvin

  • No worries, I really appreciate all the help you have done. There are two LEDs on my device (Adafruit Feather nRF52 Pro) one for determining a connection (blue), and the other for determining whether it is advertising (red). There are no errors so I would assume I'm getting only NRF_SUCCESS==0. The device I am scanning for the beacon is an iPhone 7 Plus, and it can determine if a beacon is advertising while it is connected to a device via UART, as I've tested this with separate devices (one beacon and another UART). 

    -Hudson

Related