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.

Parents
  • Hello,

    When you say: "while I am connected to a device that I am transferring data via TX". Do you mean a physical UART, or UART over BLE (Nordic Uart Service/NUS)?

     

    Either way, I don't think you have to use the Timeslot API. You can connect to a device, and start advertising again. You can also start advertising non-connectable while in a connection. All you need to do is to wait for the connected event, set up a non-connectable advertising set (like it is done in the beacon examples), and start advertising again. However, you can't advertise with two advertising sets at the same time. If you want to advertise with the non-connectable advertising at the same time as regular/connectable advertising (for the NUS service), you must manually swap between these, but that is absolutely doable.

     

    So do you want to advertise with the non-connectable advertisements while in a BLE connection, or while connected to the physical UART?

     

    Best regards,

    Edvin

  • Thanks for getting back Edvin,

    I am referring to UART over BLE such as with the ble_app_uart example. What I tried that is pretty much what you are saying. I took the advertising_init and advertising_start methods from the ble_app_uart example and changed their names (advertising_init_beacon and advertising_start_beacon), brought them into the the ble_app_uart example, and when the gap_evt signals that a connection has been initiated, I call the advertising_init_beacon and advertising_start_beacon methods for the beacon in that order. It's failing after I'm calling this method:

    sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);

    which is at the end of the advertising_init_beacon method. This is the entire method:

    static void advertising_init_beacon(void)
    {
    uint32_t err_code; ble_advdata_t advdata; uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED; ble_advdata_manuf_data_t manuf_specific_data; manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER; manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info; manuf_specific_data.data.size = APP_BEACON_INFO_LENGTH; // Build and set advertising data. memset(&advdata, 0, sizeof(advdata)); advdata.name_type = BLE_ADVDATA_NO_NAME; advdata.flags = flags; advdata.p_manuf_specific_data = &manuf_specific_data; // Initialize advertising parameters (used when starting advertising). memset(&m_adv_params, 0, sizeof(m_adv_params)); m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED; m_adv_params.p_peer_addr = NULL; // Undirected advertisement. m_adv_params.filter_policy = BLE_GAP_ADV_FP_ANY; m_adv_params.interval = NON_CONNECTABLE_ADV_INTERVAL; m_adv_params.duration = 0; // Never time out. err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len); APP_ERROR_CHECK(err_code);
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    }
  • 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

  • Ok. Then your setup is working (listening to the beacon). Is it possible to send the project, so that I can take a look?

    Best regards,

    Edvin

Reply Children
Related